Lately I've been...

Front cover of The Tao of Pooh and the Te of Piglet...reading The Tao of Pooh and the Te of Piglet by Benjamin Hoff. I thought it might be a pretty interesting read - what better way to learn about a religion than through irreverent Winnie the Pooh quotes? Well, I've been enjoying the quotes immensely, but so far the book itself hasn't impressed me in the slightest. It's full of snide remarks about "dessicated scientists" and basically makes the point that you can't understand the natural world unless you completely avoid studying it in depth. The idea that further knowledge about a thing makes it less beautiful is truly abhorrent to me as a scientist... and as a human being.

...not so much reading as flipping through Cooking For Geeks by Jeff Potter - which, in contrast, is a wonderful book that completely demystifies all of the processes that we use in the kitchen.

...listening to podcasts of Marcus du Sautoy's Radio 4 series, A Brief History of Mathematics. He very approachably describes the key ideas in the history of maths, and the people who came up with them (or discovered them, I suppose, depending on your viewpoint). They've come in handy while I've been...

...running the Couch to 5k Program for the last three months or so. I'm only at the end of Week 7 of the schedule (I've had to repeat a lot of days!) but I've ran further and longer than I ever have before, and I feel great!

...programming some bioinformatics applications in Python. One which converts an amino acid's pKa to the fraction which will be protonated at a range of pHs (source code), one which uses a whole protein sequence to find the pH at which it will have zero charge (source code) and, most recently, taking biological data from several databases and collating them into linked HTML pages (source code and essential module). The programming lessons section of my degree has been fantastic, I'm quite sad that it's nearly over.

...knitting Christmas decorations for my house and making some homemade Christmas presents. But let's not spoil the surprise :)

...

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.

...