Awk! Awk! Awk!

This week in between lots of Python and maths and things, I have been learning about awk. Awk is a programming language for doing stuff to text files that consist of columns of data. You can use awk at the command line.

awk '<condition> {<command>}' ./<filename>

will execute <command> on lines in the file called <filename> that meet <condition>. So if you want to print out all the lines that contain the word "banana", you would type

awk '/banana/ {print $0}' ./<filename>

Enclosing "banana" in / asks awk to search for it. Awk uses dollar symbols to refer to columns. $1 is the first column, $2 the second, and so on. $0 refers to the entire line.

awk '$1 == "10"{print $2}' ./<filename>

will print out the second column of all the lines on which the first column says "10"

...

My first ever C program!

Well, the first one that wasn't an exercise from Kernighan and Ritchie, anyway. I have made an implementation of the Sieve of Erastothenes, which is a way of finding prime numbers. (Wikipedia has a good explanation, and an animation!)

I am rather proud of myself. The source code is here and the executable is here. If you run it at the command line, type in a number and then press enter, it will tell you all the prime numbers that are smaller than your number.

My next post will be more about hearts, unless I write any cool programs before then.

...

Things I've been up to in 2011

"Bring It, Don't Bin It" happened: we collected a load of clothes, toiletries, kitchenware and bedding (which, as you can see above, we promptly sat on) from departing Erasmus students and had a yard sale at the union. The profits and the rest of the stuff went to St. Vincent's, a Sheffield homeless charity. We got the electrical stuff PAT-tested, too! There was a second collection in June as the rest of the students left - unfortunately I couldn't attend, as I was at BarnCamp. I'm really pleased with how this project turned out.

I played in the National Concert Band Festival with the Sheffield University Wind Orchestra. We won a gold award, which sounds great until you realise that there was also a platinum award, and somehow managed to get to Glasgow and back in a single day. What madness.

BarnCamp - the annual techheads-go-camping-and-drink-too-much-cider extravaganza - was awesome (if very, very wet). My favourite workshop was on fractals, by Mike Harris. He was showing us the <canvas> element in HTML5, and how it can be used to make things like Mandelbrot sets. There are some great photos on flickr.

Incidentally, the person who coined the term "fractals", Benoit B Mandelbrot died last year. The B in his name stands for Benoit B Mandelbrot.

Lots of people I like have died recently. Janet McCleery, my awesome singing teacher - Dennis MacDonald, a fellow volunteer at the BitFixit Cafe (and a million other community projects) - Charlie Dickinson, a cracking lad I knew at school - and my lovely friend Brian Jackson, who I miss rather a lot. So that's not been great.

I found out today I have a confirmed place on my Mechanistic Biology Masters course for next year, so that's me sorted until next September. Last week I started my internship for the summer at Oxford Uni working on computer models of heart cells. I didn't know much at all about electrophysiology until last week so it's been a pretty steep learning curve! I'm really enjoying the challenge. Happy summer, everybody.

...