March 31, 2005
My Desk

You can't say that you weren't warned.


(Click on the image to zoom.)

So, what does my desk say about me?

Posted to Apropos of nothing by Simon Brunning at 05:52 PM
Python Cookbook

I recieved my copy of the 2nd edition of The Python Cookbook yesterday, too. Nice to see my name in print, however miniscule my contribution. Nice to get a free copy, too. ;-)

I've not had much chace to look through it yet, but it looks interesting. The new chapters on generators, descriptors and metaclasses look particularly useful. More later.

Posted to Python by Simon Brunning at 05:02 PM
Mum's visit

Mum came down on Tuesday night for a visit. She met up with Steve and I at The Alex, which was nice - they've been reading each other's blogs for ages. Steve was much as she expected, except that she "didn't expect him to be such a sweetie".

Well, that's a first. Steve being called a sweetie, that is - Mum calls people sweeties all the time.

Anyway, as usual, Steve and I sorted out all the world's problems over a few pints, with Mum's assistance this time. And as usual, some bugger screwed it all up again by morning.

Yesterday we had a day in town. We went to the Apple Store first. We got away with just an iPod remote each. A lucky escape - you could spend ten grand there and still have a wish list.

Then we went to The British Museum. Amazingly, Mum's never been before. As ever, you can only see a tiny fraction on any one visit, so we concentrated on the Asian section. If you've ever visited Mum's blog, you can't help but have noticed that she has more than a passing interest in Buddhism.

Oh, yes, and I got a lovely early birthday present - a Sony DSC-P72. So expect to be bored rigid by loads of bad photos, and flickr and/or picasa related posts. ;-)

Posted to Apropos of nothing by Simon Brunning at 04:55 PM
March 26, 2005

My post to the Python for Kids thread is something I've been meaning to get around to with Freja for a while. She's only eight, but the's confident with and facinated by computers, so I thought that giving her a go wouldn't do any harm if I didn't push her.

So far, she's having a blast. At first, she just drove the turtle around, changing its colour on the way. But towards the end, I suggested that she make a square, and she managed that easily enough. I'll have a bash at loops with her soon, but I really don't want to overload her.

There was another script that I knocked up for her that she had fun with, first just running it, then making simple modifications:

your_name = raw_input("What's your name? ")
if your_name.lower() == "freja":
    print "You're very stinky,", your_name
    print "You smell lovely, ", your_name

She worked out for herself how to replace 'freja' with 'daddy'. Ah, simple pleasures. ;-)

Note to self: Check out PyLogo.

Posted to Python by Simon Brunning at 04:25 PM
March 24, 2005
Code limerick

Michael Spencer's code limerick is, well, I don't think that superb is too strong a word. It's not just that it's a limerick itself, it's what it outputs that makes it so cool.

Yes, I know; I really need to get out more.

Posted to Python by Simon Brunning at 01:36 PM
My Review

Surprisingly enough, my last review wasn't allowed to stand, so I had another one today. I didn't come out of this one quite so well. ;-)

They aren't going to sack me. Too much paperwork, apparently.

It wasn't too bad, though. I was brought up on my admin, as I was expecting. They are keen on the fact that I try too keep the company up to date, but I need to work a lot harder to getting buy-in from the team, too.

I'll be getting a new PC ;-) But not a Mac. :-(

There might be - shudder - public speaking training coming up too...

Posted to Apropos of nothing by Simon Brunning at 01:34 PM
March 22, 2005
I have to do something about my dress sense

I've just been accused of looking like a geography teacher.

But what gets me is who is criticising me. If it was just the clothes horses, I wouldn't mind, but no - this was from a man wearing a black shirt and a Hong Kong Phooey tie.

Posted to Apropos of nothing by Simon Brunning at 02:43 PM
The Power of Open Source

Four days the lists have been up, and already people are helping one another out on them. Nice.

Posted to Python by Simon Brunning at 02:38 PM
Lambda revisited

There's me saying that I'd be happy to see the back of lambda, and the effbot goes and posts ElementPlist, a beautiful use for them. Nothing there you couldn't do without lambda, but not so elegantly.

He only does it to make me look stupid, you know. ;-)

Posted to Python by Simon Brunning at 02:06 PM
March 18, 2005
Attention all WATSUP users

Tim and I are getting a steadily increasing number of emails regarding WATSUP and, so we thought that now would be the time to set up a mailing list or two.

Now if someone can just help Tim to put the files up on Sourceforge, we'll be in motion. ;-)

Posted to Python by Simon Brunning at 04:31 PM
A whole different species

Female chromosome has X factor and Why X Marks the Gender. "Effectively there are two different human genomes, one male and one female." Like I've always said, a whole different species.

Posted to Science and technology by Simon Brunning at 12:56 PM
Jolt 2005 awards

Congratulations to the Jolt 2005 award winners (PDF). I've read, used or will use a number of the winners:

But where's Spring?

Posted to Software development by Simon Brunning at 09:39 AM
Google Code

Check out Google Code. Google is open sourcing some cool stuff. First featured project: PyGoogle, a Python wrapper for the Google Web APIs. There are RSS feeds, too, so you can keep up to date with what they are up to.

As EP said over on, this is great PR for Python.

Posted to Python by Simon Brunning at 09:02 AM
March 17, 2005
Python meetup at The Stage Door, Waterloo on the 13th of April

The last meetup went very well, from what little I can remember. I'm organising another for April the 13th, again at The Stage Door. Pythonistas (or is that Pythoneers?) and the Python curious all welcome.

Posted to Python by Simon Brunning at 04:21 PM
Little black book

My Mum and my sister have really taken my holiday problem to heart, and have organised a whole bunch of stuff for me to do. So much, in fact, that for the first time in several years, I've actually had to go and buy a diary to remember it all. I've just send off a holiday request for 18 days to El Presidente.

BTW, mum is coming down to visit soon. I'm meeting Mum and Steve for a beer on the 29th. They've not met in meatspace before. All welcome...

(This has the additional advantage of getting me out of Salsa yet again. That's now postponed to April the 12th.)

Posted to Apropos of nothing by Simon Brunning at 04:18 PM

Oooh, a nice big pile of books has just arrived:

The first two are mine, but I managed to convince the company to spring for the rest. ;-)

Posted to Java by Simon Brunning at 04:05 PM
St Patrick's Day

A Happy Guinness St Patrick's Day to all my readers, if any.

Posted to Beer by Simon Brunning at 03:54 PM
March 11, 2005
De-functionalising Python

Guido's thinking about ditching lambda, reduce(), filter() and map(). I don't use any of them, so I'd be quite happy to see them go, and the proposed product(), any() and all() functions look really good.

I'm with Peter, though - they shoudn't be builtins. We have enough of those already. I seem to remember the martellibot proposing a reductions module at some point. That would be a much better place for them - and for sum(), for that matter. Not only would that avoid bloating the builtins, it would also help to avoid the problem of people already having objects named 'any' or 'all'.

Posted to Python by Simon Brunning at 01:36 PM
Roar With Laughter

Last night's Roar With Laughter was, uh, interesting.

Chambers & Nettleton were, well, rubbish. Perhaps it's just me - I really can't stand comedy songs.

Tim Vine came on for a brief 10 minute set. He wasn't on the bill, and the material was a bit rough. I think he was just using us to try out some new stuff. He's welcome to do so again - he was fantastic.

Johnny Candon's set was very funny, but rather uncomfortable. He asked if there were any parents in the audience, and I was the only one to respond. He proceeded to interrogate me for several minutes about my family history, my children, my relationships and my ex's relationships for what felt like ten minutes (but was probably only a minute or two) in front of sixty or seventy people. Still, very funny, though, and when he asked another audience member if she was a "proper nanny, or a shaky nanny", it was one of the high points of the night for me.

Sarah Kendall; well, what can I say? She pretty much died. She got off to a bad start being heckled about the size of her watch(!) before she'd even started, and she never really recovered. It didn't help that half the (generally good natured) heckling came from a Scot whose accent she didn't understand. And at one point she was accused be being an aggressive racist. The 'aggressive' bit was just absurd, and I really don't believe the racism accusation to be fair, either. She might have been a little naive in her choice of language, though. So, Sarah, on the million to one chance that you read this, here's a couple of rules to keep you out of trouble.

  1. If you aren't black, don't use the word 'nigger'. Ever. I know that you were only mentioning the name of a band, but just say NWA next time, OK?
  2. Never claim that you aren't a racist. That's complacent - none of us are perfect. You may despise racism, and you may strive to eradicate it from yourself. But if you aren't willing to accept that you might still bear the odd prejudice or two, you'll never see them and have no chance to fix them.
  3. Avoid referring to members of other racial groups as 'them'.
Anyway, despite the fact that I really don't think she recovered, she struggled on bravely, there were some very funny moments, and she came across as very likable. She's stunning to look at, too, I must say. I'd be more than prepared to give her another chance. ;-)

Anyway, it was a good night on the whole. Well worth a visit.

Posted to by Simon Brunning at 01:17 PM
March 10, 2005
You have to laugh

I'm hung over, and I'm soon to be unable to get to work. A beer and a laugh, that's what I need.

Posted to Beer by Simon Brunning at 04:47 PM
Northern line sections to close for months at a time

Tube closure bombshell. Bugger. That's going to be inconvenient, to say the least.

Update: Well, that's the Colliers Wood residents' view covered, then.

Posted to The Big Room by Simon Brunning at 04:40 PM
Life isn't fair

Bizarre. Wherever I go, I seem to develop the same undeserved reputation. This is a wholly unfair accusation; in many of the photos, I'm drinking a Mojito.

Posted to Beer by Simon Brunning at 02:17 PM
The Wikipedia is just too cool to be true

This is so cool that I'm going to have to do a straight steal from Edward: "The rubber duck can be referred to informally as a rubber duckie or a rubber ducky. Amongst collectors of rubber ducks, the spelling rubber duckie has achieved prominence, but both spellings are considered acceptable."

Neither Britannica nor Encarta have index entries for "rubber duck".

The Wikipedia's Random Page feature is a real time waster.

Posted to Funny by Simon Brunning at 01:05 PM
Read, goddamnit

Mexican police are being forced to read books: Mexican officers brought to book. What a fantastic idea. There are a few books I'd like to force some of my cow orkers to read...

To name but a few.

Posted to Books and magazines by Simon Brunning at 12:02 PM
All alone

My entire team is malingering off sick today. Every single one of them. (OK, with the exception of Tulna, who's off on holiday.)

That means I'm in charge. I've already raised the purchase order for a speced-up 15" PowerBook, and I'm doing my review this afternoon. I think I might come out of it rather well.

I have no idea what it is that they all do together to spread the bug, by the way, but clearly I'm being left out of it.

Update: I've done the review. It turns out that I'm an exemplary employee, with virtually no faults, save for a tendency for over-modesty. A promotion and a very large pay rise are in order.

Posted to Apropos of nothing by Simon Brunning at 11:53 AM
Latin Python

Last night's Python meetup was a blast. I still haven't sobered up. We had nine people at one point, which was pretty good. It ended up with Edward, Chris and I drinking Mojitos until stupid o'clock at Cubana, watching a couple of rather cute girls playing some rather good salsa.

Update: Thanks to Edward for this photo gallery.

I didn't get home until half past two. :-)

If you were there, please leave a comment so I know who you all were...

Posted to Python by Simon Brunning at 10:08 AM
March 09, 2005
Wittgenstein was a beery swine

Right, I'm off for a slimming beer or two at The Stage Door with the London Pythonistas.

I might give the traditional kebab on the way home a miss, though...

Posted to Python by Simon Brunning at 04:52 PM

I picked up Firefly the other weekend, on DVD. What can I say? Andy was right, I was wrong. Firefly is the best TV Sci Fi I've seen in years. Believable characters, good actors, an interesting setting and a promising plot. It's a real shame that they cancelled it - I really would have liked to have seen where it would have gone.

Buffy was still rubbish, though.

Posted to Music and Film by Simon Brunning at 04:51 PM
Time to get serious

Time for a Manhattan Project to combat global warming. I would have linked to the original article if it wasn't behind a paywall.

I don't like it much, but I have to agree with Lord May - in practise, we need to go nuclear. I mean, yes, in theory, if we adjusted our lifestyles enough, and invested enough in renewable power, we could do without it, but I really can't see it happening.

Can you? Really?

Posted to The Big Room by Simon Brunning at 03:38 PM
Incrementing strings

While I'm posting silly little Python scripts, here's one I prepared earlier.

def inc_string(string, allowGrowth=True):
    '''Increment a string.'''
                   Bunch(from_char=48, to_char=57),  # digits
                   Bunch(from_char=65, to_char=90),  # upper case
                   Bunch(from_char=97, to_char=122), # lower case
    string_chars = list(string)
    string_chars[-1] = chr(ord(string_chars[-1]) + 1)
    for index in range(-1, -len(string_chars), -1):
        for char_range in CHAR_RANGES:
            if ord(string_chars[index]) == char_range.to_char + 1:
                string_chars[index] = chr(char_range.from_char)
                string_chars[index-1] = chr(ord(string_chars[index-1]) + 1)
    for char_range in CHAR_RANGES:
        if ord(string_chars[0]) == char_range.to_char + 1:
            if allowGrowth:
                string_chars[0] = chr(char_range.from_char)
                string_chars.insert(0, chr(char_range.from_char))
                raise ValueError, string + " cannot be incremented."
    return ''.join(string_chars)

Requires the martellibot's Bunch class.

The story behind this one is that I was building a database conversion utility, converting both schema and data from one database engine to another. Thing was, the target database only allows 10 characters in its table and column names. (OK, actually, it doesn't - but it's a whole lot easier to access if you stick to 10 characters.) I stripped down the longer entity names by removing whitespace and spacing characters, then non-leading vowels, and at the last resort, I truncated.

This worked on the whole, and the column and table names were not a great deal less readable than an RPG programmer is used to anyway. ;-) But I was getting the occasional duplicate, so I came up with this.

( formatted, with unit tests)

Posted to Python by Simon Brunning at 02:59 PM
Blog your way to the top

Ten Reasons Why Blogging is Good For Your Career.

"Letís assume that youíre reasonably competent, reasonably coherent, and reasonably mature." Oh dear.

Posted to Blogs by Simon Brunning at 01:54 PM
Software Patents in the EU

Software Patents in the EU. A Bad Thing.

Posted to Business by Simon Brunning at 01:53 PM
Picking random items from an iterator

The shuffle the lines of a large file thread on reminded me of Richard Papworth's superb Cookbook recipe, Retrieving a line at random from a file of unknown size. The wonderful thing about this recipe is that the file only needs to be read once, and it doesn't need to be kept in memory, but every line in the file has an equal chance of being selected.

I came up with a quick hack that allows the selection of multiple lines, but it soon occurred to me that this approach is far too pretty to be restricted to files - you can do the same with any iterator:

def random_items(iterator, items_wanted=1):
    selected_items = [None] * items_wanted

    for item_index, item in enumerate(iterator):
        for selected_item_index in xrange(items_wanted):
            if not random.randint(0, item_index):
                selected_items[selected_item_index] = item

    return selected_items

You can run this over a file; random_items(open(file_name)), but you can also run it over any other kind of iterator.

This is in Python of course, but I don't see any reason why you couldn't implement this in any language that has iterators.

Fuller version with kind-of-unit-tests:

BTW, how do you unit test something that gives random results properly?

Update 10th March: Faster initial allocation of selected_items

Posted to Python by Simon Brunning at 01:00 PM
Jam Today

Doughnut jam and keyboards - not a good combination.

Not of course that there's any problem at all with my keyboard. Oh no. But Tulna's off on holiday this week, and I suppose there's always the outside chance that her keyboard (which is co-incidentally identical to mine) may be a little on the sticky side when she gets back...

Posted to Apropos of nothing by Simon Brunning at 12:37 PM
March 08, 2005
London Python meetup tomorrow

The London Python Meetup is tomorrow evening at The Stage Door, near Waterloo, 6:30 'till late. Ish.

I'll be the one with the tin of Spam. See you there...

Posted to Python by Simon Brunning at 12:15 PM
March 07, 2005
Up To Twelve

I saw End Of The Century: The Story Of The Ramones this weekend. It was superb. If you are even slightly into The Ramones, or rock in general, you need to see this. These guys didn't just play punk, they were punk. Tap will never seem the same again...

It was part of a double bill at The Clapham Picture House. The other half was Coffee and Cigarettes, but that went so far over my head that I didn't even feel the wind. There was one obvious theme to start with - people talking but not communicating - but that seemed to tail off towards the second half, and all I was left with was a bunch of unconnected short films with a few shared lines. Some of it was funny, but I'm sure that I missed the point.

Posted to Music and Film by Simon Brunning at 02:05 PM
Spring or Struts?

My company is deciding on the toolset that we'll be using for our next generation of web applications. Java was a shoe-in after my Python suggestion was shot down early in the discussion. :-(

But deciding upon Java is only the first step - you need a whole bunch of stuff to go along with it. One of our recent projects was intended to be a pilot, and I was fairly happy with the toolset that we used for that, so mostly we'll be updating that list.

In the end, though, we ended up not using Hibernate and not using Struts - we wrote our own. This time, I'd like to use frameworks for these layers rather than building our own workable but time consuming and frankly far inferior versions.

Hibernate looks by far the front runner for the persistence layer, but selecting the MVC framework isn't so easy. Struts is certainly the de facto standard here, but I'd like to be using Spring for other things in any case, and I gather that its MVC component is really good, so I lean towards using that too.

Good idea? Bad idea?

There are a few other additions to the original toolset:

  • Log4j
  • We'll be using JSP (and JSTL) for our View layer. Unfashionable, I know, but since JSTL came along and removed the need for virtually all of those nasty scriptlets, I find JSP to be rather nice.
  • EMMA for unit test code coverage reporting
  • iText if we need any PDFs generated
  • Joda Time
  • jMock
  • displaytag

Anyone think that we shouldn't be using any of this stuff? Anything essential that I'm missing?

Posted to Java by Simon Brunning at 10:45 AM
Satire is dead

Sudan is upset that their country's reputation has been damaged by the recent storm in a teacup food scare over "Sudan 1" the food dye.

You can see why they were concerned - prior to the scare, they had a superb reputation. I mean, complicity in genocide-or-is-that-just-crimes-against-humanity is pretty trivial stuff, right?

Posted to The Big Room by Simon Brunning at 09:46 AM
March 02, 2005
G is for Goth

The Cradle Rocks, via boing boing. The AC/DC For Those About To Rock Tee is nothing short of brilliant. I only wish they did stuff big enough for my girls. Ella, in particular, says that she wants to be a punk when she grows up - thanks to School of Rock.

Anyone know where I can get a Ramones tee-shirt for a six year old?

Update: More punk kid's tee shirts - UK based.

Posted to Funny by Simon Brunning at 12:53 PM
For services to anti-competition...

As if the British honours system wasn't in enough disrepute; Microsoft's Gates being knighted. What next - a posthumous lordship for Robert Maxwell? A Nobel Peace Prize for George W. Bush and Tony Blair?

(And yes, I know that Henry Kissenger already has a Nobel Peace Prize. Satire is dead.)

Posted to The Big Room by Simon Brunning at 12:00 PM
Down with The Tower

Channel 4 is running a poll to decide which of the UK's vilest buildings should be demolished. The Tower in Colliers Wood is currently topping the poll.

I walk past The Tower (or The Brown and Root Tower as long-time Colliers Wood residents still call it) at least twice every day. And it's true - it is hideous. But it's been there for as long as I can remember, and I've lived in Colliers wood, on and off, since I was four. I remember using it to find my way home when I was lost. So, I have a funny kind of affection for the thing.

Besides, there's just about zero chance of it actually being knocked down - it would take out the tube line beneath it if you just blew it up - so it's all a bit of a waste of time really.

Posted to The Big Room by Simon Brunning at 11:31 AM
March 01, 2005
The albums you should have listened to before you die

Yet another meme.

"Copy the list on to your blog, put in bold the ones you have listened to (completely from begining to end) and then add three more albums that you think people should have heard."

Sgt. Peppers Lonely Hearts Club Band - The Beatles
London Calling - The Clash
Blood Sugar Sex Magik - Red Hot Chilli Peppers
Think Tank - Blur
This is Hardcore - Pulp
Moon Safari - Air
Elastica - Elastica
Never Mind the Bollocks Here's the Sex Pistols - Sex Pistols
OK Computer - Radiohead
The Kiss of Morning - Graham Coxon
Ziggy Stardust and The Spiders from Mars - David Bowie
The Wall - Pink Floyd
Setting Sons - The Jam
America Beauty - The Grateful Dead
Toxicity - System of a Down
Train a Comin' - Steve Earle
Folksinger - Phranc
Come From the Shadows - Joan Baez
Bat out of Hell - Meatloaf
The River - Bruce Springsteen
The Very Best of Joan Armatrading - Joan Armatrading
Copperhead Road - Steve Earle
Dark Side of the Moon - Pink Floyd
Brothers In Arms - Dire Straits
Outside - David Bowie
Passionoia - Black Box Recorder
Version 2.0 - Garbage
Too Young To Die (Greatest Hits) - St. Etienne

My three:

The Complete Recordings - Robert Johnson
Absolution - Muse
Kind of Blue - Miles Davis

Via badly dubbed boy.

Posted to Apropos of nothing by Simon Brunning at 05:19 PM
Yesterday's London Java Meetup

Coming in to work on a badly overcrowded and very slow running tube with a nasty hangover is no fun, I can tell you.

But last night was a good one.

It looked like it might get a bit nasty at one point. We used a back room that had been booked by a bunch of performance poets. Java nerds versus poets - what a rumble that would have been.

In fact, we just moved to the front of the pub, where I remained undefeated on the pool table.

Oh, and don't forget the Python meet up next week...

Posted to Java by Simon Brunning at 04:54 PM
Where did it go?

The Internet went missing today. It's only just come back - hence no posts today.

I think the sys-admins eventually found it under the sofa.

Update Wednesday 2nd: This was it - Redbus power failure - companies form group to voice concerns.

Posted to The Internet by Simon Brunning at 04:45 PM