Varrqnuht.net


SecondLife on Linux

Posted in Geek by Felius on the January 19th, 2006

Sounds like there’s been progress on the Linux native client for SecondLife.

SecondLife is fun. Well, to be more accurate it shows the potential to be fun. I spent a little bit of time playing around in there, but my main interest is in being able to script the world around me, and this will require a fair bit of time to get to grips with it all. Having a Linux client would make it easier for me to find the time to get in there, so that I might start visiting again.

I asked to be added to the list of testers for the alpha trial, so I guess there’s nothing more I can do now except to sit back and see what happens.

Old diary entries imported; (a love letter to Python)

Posted in Geek by Felius on the January 16th, 2006

In September last year I attended a course on the Python programming language, which was held online via the AccessGrid - a sort of video-conferencing system on steroids. It was a really enjoyable course - pretty fast paced, and a great way to get an introduction to a language. The notes from the course are online here.

Anyway, I’ve been playing with Python on and off since - I have one project on the go which I really need to get moving on as I’m giving a talk on it in just over a month, but over the weekend I decided to tackle the problem of importing my old diary entries using python.

Here’s a brief list of the things I’ve decided I really like about python.

  • It has a huge standard library, like PHP, but unlike PHP it starts off with the bare minimum included at runtime. The extra modules are easy to import, and the import command lets you choose how to bring them into your namespace. The inconsistent naming conventions and pollution of the global namespace in PHP are one of its less attractive features, and the python solution is much nicer.
  • The interactive shell is wonderful. It’s hard to describe why this is such a nice feature, and when I heard people talk about it I thought they were a little nuts. But the truth is that it actually changes the way you write code. Normally if you’re trying out something new you’ll have a file open with your bit of code in it, you make some changes and then re-run it to see the effects. Sometimes you may have a command line open as well, and be trying out things quickly with a cli interpreter. But python’s interactive shell effectively lets you do all of this in the same place - letting you keep state in between experiments, with a searchable command history buffer.
  • The thing that put me off (that puts everyone off) about starting to learn python was the whole concept of whitespace having syntactic meaning. The reality is that it’s just a non-issue. I mean, we all use auto-indenting editors anyway - in python the indentation is just made an explicit part of the language, allowing you to do away with a whole lot of braces around blocks. What’s more, forcing indentation to be part of the language syntax means that indentation styles must be consistent between programmers. And if you don’t indent your code at all, I don’t want to know you. ;)

So, yeah. It’s not going to be the direct cause of world peace or anything, but I like it.

As an example, here’s the code I used to import my old diary entries into Wordpress:

import MySQLdb, MySQLdb.cursors
import xmlrpclib

server = xmlrpclib.ServerProxy(”http://varrqnuht.net/xmlrpc.php“)
db=MySQLdb.connect(user=”oldblog”,passwd=”PASSWORD”,db=”oldblog”,cursorclass=MySQLdb.cursors.DictCursor)

c=db.cursor()
c.execute(”SELECT * FROM Diary WHERE user = ‘john’ and Private = 0″);
for oldEntry in c.fetchall():
newEntry = {’categories’: [’Old Diary’], ‘dateCreated’:xmlrpclib.DateTime(oldEntry[’DiaryDate’].isoformat().replace(’-',”)), ‘title’: oldEntry[’DiarySubject’], ‘description’: oldEntry[’DiaryText’]}
response = server.metaWeblog.newPost(1,’admin’,'PASSWORD’, newEntry,‘true’)

That’s nine lines of code to read entries from a database, reformat them, and submit them to an XMLRPC web service. And I was able to develop it all inside the shell. This is a language which lets you write elegant, readable code, but which also recognises that in the real world you frequently write once-off throwaway bits of code too.

One of the real world issues I ran across while doing this was that the ‘isoformat’ dates returned by MySQL contain hyphens separating the year, month and day, while the iso format dates expected by the Wordpress XMLRPC interface don’t contain the separators. This was easy to fix using replace(’-',”) as shown above, but I still don’t know who’s at fault here. The point is I don’t care - it’s a once off script. There’s only one other instance of my diary software lying around that I know of, and that person just finished importing all their old entries into Wordpress by hand, just before I wrote this bit of code. ;)

P.S. You can read the old entries using the Archive links on the right. They start in February 2001 and continue until October 2002. I need to look at better navigation between posts.. I also need to go through them all checking for problems, and fixing image links. I also need to actually find a backup of the old images and reupload them..

P.P.S. I should have another look for a simple plugin to make embedding code excerpts in a post a bit neater.

P.P.P.S. Apologies to anyone reading this for whom almost the entire post appeared to be in a foreign language. Hi Mum!

Site updates

Posted in Geek by Felius on the January 11th, 2006

I’ve just upgraded Wordpress (the software I use to run this site) from version 1.5 to 2.0. I also chucked a new theme on just to make things look a bit different. I’ve been running the default theme since I originally installed Wordpress almost a year ago. I started work on doing my own theme, but didn’t finish it. I’d still prefer to have my own design for the site, but seeing as it’s looked like every other wordpress install for the past year I can’t really complain.

Maybe I’ll do something about it soon.. or maybe this one will stay in place for another year.

Birthday Wrap-up

Posted in Photos, Work by Felius on the January 6th, 2006

Someone complained that I haven’t updated yet to say what I got for my birthday. The amazing thing here is that someone read my blog two days in a row! ;)

Tux gets decapitated! ©2006Well, the cake was very well received. It was gobbled up in no time at all. Louise and Sebastian came along too (as Lou was delivering the cake) and Sebastian was pretty popular.

I wasn’t expecting to get a present because I received a remote control Yacht as my combined Christmas/birthday present. More on the yacht at some point in the future! However Lou surprised me by giving me the debut album from Wolfmother, which I’ve been wanting for a while.

All in all it was a good day, and to top it off tonight I’m going out to dinner with a bunch of friends - life is good.

Birthday Cake

Posted in Photos, Work, Geek by Felius on the January 5th, 2006

Happy Birthday to meeee, Happy Birthday to meeeee!

At my work it is customary to bring your own birthday cake on your birthday. I recently bought a book called Kids’ Party Cakes which had a recipe for a cake which looked suspiciously familiar.

I normally try to avoid displaying any operating system bias at work (despite the fact that I’m employed as a Unix admin), and I definitely don’t get involved in OS wars. But hey, it’s my birthday - I’m sure they can all cut me some slack!

Tux cake, decorated by Louise! ©2006Here’s the cake that Louise is bringing in for afternoon tea. I’d planned to make it myself but didn’t get organised in time, so Lou decorated it for me this morning. I’m hoping that my work colleagues will be suitably impressed!

If you have no idea what I’m talking about, then take a look at Tux the Penguin!

Christmas Baz! (and a Dad’s obsession with his Son’s toys)

Posted in Photos, Family, Geek by Felius on the January 4th, 2006

Note: This post is horribly overdue! I started it on December 18th.. Still, I’ve got one even older in the queue.


It’s Christmas time, but I’ve been feeling a bit like Scrooge this year. We have a tree up and decorated, though only because Lou did it. Still, it’s hard not to feel christmassy with this little fella around:

Sebastian getting into the mood for his first Christmas! ©2004

I’m still not sure how I’m going to deal with Christmas in future years. Louise was aghast at my suggestion that we “not do the Santa thing”. I’ll probably get more into it as Sebastian gets old enough to be excited.

Updated after Christmas: He got tons of presents, but I think the one he was most excited by at the time of unwrapping was a ball of cellophane I wrapped up in a a scroogy attempt to very quietly prove a point.

The Horn Peek-a-Block ©2005As for other presents, he’s been building up quite a collection of Fisher-Price Peek-a-Blocks. These are very cool. They’re building blocks with transparent sides that have little things inside for babies to look at and interact with.

There are a whole series of toys that work with the Peek-a-Blocks in different ways. For Christmas he got the Gobble & Go Hippo, which rolls along the floor and eats up a set of food related blocks. However my favourite toy so far is the Incrediblock - this has lots of things to play with, lots of ways to put blocks in it, and comes with a set of special blocks that can be pressed into the top to have a description of the contents and a related sound effect played.

The Peek-a-Blocks are all the same size, and consequently any block can be pressed into the special spot at the top of the Incrediblock. However blocks other than the ones that came with it just cause it to play a random tune.

Naturally, being the geek that I am, I immediately wondered how it knew which block was which. The answer was pretty obvious on inspection, but the bonus is that I realised I might be able to use the block to teach Sebastian how to count in binary!

Louise rolled her eyes when I told her this (a tad too excitedly, perhaps). She already knows of my plan to try and teach him decimal, binary, octal and hexadecimal as soon as he’s old enough to do basic written maths. I think he might get off to a better start than I did if he learns the properties common to various number systems right from the beginning.

0101 - the bottom of the dog block  ©20051100 - the bottom of the cow block ©2005Anyway, back to the point. The Incrediblock has a dome in the top with a square indentation containing a number of plastic pins sticking up out of it. There are six of these - two on outside corners which act as “key” pins, and four in the middle which allow it to detect which block is inserted. The special blocks that the Incrediblock recognises have a circular indentation underneath, which can contain four concentric raised circles. the innermost circle is solid, while the others form rings around it. The reason for using circles is that it doesn’t matter which way the block is facing, as long as it’s the right way up. Each of the pins intersects the path of one of the circles. If a block has a circle in that position the pin is pushed down, otherwise it stays up.

Eight special blocks were included, but four pins with two possible states each allows for 16 combinations. I decided to try all the combinations by hand, so I made up this chart - counting each ring as one digit starting from the outside and moving left to right, so that 0001 means a block with only the innermost circle on the bottom.

* = “phantom” blocks (not included)
t = plays a random tune

0000
0001 * bird
0010 * lamb
0011 * pig
0100 t
0101 - dog
0110 - cat
0111 - guitar
1000 t
1001 - horn
1010 - drum
1011 * airplane
1100 - cow
1101 - car
1110 - boat
1111 t

You can see from the chart that there are four extra combinations recognised by the Incrediblock. Three of the other four combinations just cause it to play a random tune, and the very first one (holding down the key pins but none of the other pins) does nothing at all.

I’ve done a bit of googling for information on the “missing” blocks - it seems I’m not the first to discover them, but I haven’t yet found out if you can buy the missing ones anywhere. Or if they were even made available at all!