One-line of Python: string -> hex

Just a little something that may come in handy in the future (for my reference, rather than yours), a Python one-liner for converting an ASCII string to hexadecimal pairs.

to_hex = lambda s: ' '.join(['%02X' % ord(ch) for ch in s])

As you were…

Thank you, all. #wgs

I realise that I have been harping on about Leukaemia Foundation’s World’s Greatest Shave a lot over the past four weeks. It’s all done and dusted now and so I justed wanted to wrap up with a thank you to everyone who supported me, particularly in the past 24 hours.

When I woke up yesterday morning, I was anxious about the day ahead. Having never had my legs waxed, I was concerned about the pain that lay ahead, particularly given the very hairy nature of my legs. At 12:30, I went to Claire Françoise’s salon and after a brief wait was led to a little room with a couch and a bucket of hot wax. K came in too, to take some photographs for you people, which I will upload later today.

I have to say, folks, that my anxiety was for nothing. Claire was very fast and in no time at all, I was looking down on a pair of freshly-waxed, pale white, freckle-covered legs. I was reminded of an early scene in Spike Milligan’s book ‘Puckoon’, where The Milligan is giving out to The Author on writing such legs.

Back at the office, I was told that it was now time to go downstairs for my head shave. This was never a part of the plan, but there we go. There was a WGS event happening on the ground floor of my office block, so it seemed appropriate to do it there and then where some of my sponsors could witness the event first-hand. You will have to make-do with the photographs!

This morning, after an hour locked away in the bathroom (during a thunderstorm for effect) with a large tub of Veet and a Mach III, I emerged with smooth arms, chest and head. Again, there will be photos online later today.

You’ve kindly donated $2,120 to the Leukaemia Foundation. I’m extremely grateful for your generosity. And now, I have to concentrate on hair growth ahead of my brother’s wedding in Swindon, England on 12 June. Thank you very much.

One more sleep to go!

Leukaemia Foundation World's Greatest Shave

The Leukaemia Foundation World’s Greatest Shave is happening this weekend!

To bring you up-to-date:

  1. I thought I’d raise a few bucks by shaving my head.
  2. People wanted more to give more, so I offered to shave my legs as well as my head for $500.
  3. You called for my legs to be waxed, so I asked for $1,000.
  4. I’m now sponsored to the tune of $1,782!
  5. Claire Françoise Salon in Melbourne’s CBD are going to wax my legs tomorrow (Friday) lunchtime!
  6. If I raise $2,000 by Friday, I shall shave my arms and my chest, too.

Claire Françoise Salon

Your donation will make a difference, in the short term it could mean the loss of more of my hair, in the long term it will help those suffering with leukaemias as they undergo treatment. As an Australian tax payer, you get to claim your tax back at the end of the year! You’ll be sent a PDF receipt when you donate (let me know if you think you’ve donated but not received a receipt).

Photographs will be shared via my Flickr Stream after the event.

Most importantly, here is the link you need to sponsor me. Every dollar counts. If you cannot spare a dollar right now, then perhaps leave some words of encouragement on my profile page. I really appreciate the support.

Many, many thanks for your generosity, financial or otherwise.

World's Greatest Shave Update

Leukaemia Foundation World's Greatest Shave

Last week, after I hit the $1,000 target that would mean that I have to wax my legs, I mentioned that I am dreading it. I’ve been hearing many tales of home-waxing and also have had the scene from The 40 Year Old Virgin recounted to me more times than I would like.

Yesterday evening I had a very nice email from Claire Françoise, telling me that her studio would love to be a part of the World’s Greatest Shave and that they would be more than happy to inflict ‘pain’ on me for the sake of a good cause.

Claire Françoise Salon

Since the Claire Françoise Salon is only a few blocks away from my office, I can pop by in my lunch break next Friday for the dreaded waxing.

This has calmed my nerves a little, knowing that professionals are on the case. I promise to take some photos of the event and to blog of my first waxing experience. I’m sure it shall be an experience.

According to the total on my profile page, my arms and chest are still safe but there are still ten days to go, so you still have time to sponsor me.

Now I must think about how to execute the head shave… I’m open to suggestions!

Thank you all, once more, for your amazing support. I really am very appreciative.

Police Warning

I’ve just received the following SMS:

Msg from Vic Police:Extreme weather in Vic expected Mon night and Tues.High wind & fire risk.Listen to local ABC Radio for emergency updates.Do not reply to this

According to The Age, another two million similar messages will be sent.

Speaking of The Police, I recommend this Mashup of Watching the Detectives + Walking on the Moon.

Stay safe.

TDD and the Python Shebang

Before I joined my current employer about two years ago I had heard of both Python and TDD but used neither. Now Python is the first language I reach for whenever I want to write a utility and I naturally start by writing a failing unit test. It’s a fun way in which to program, but more than that… Today I was telling a friend (and former colleague) why I prefer test-driven development as a way of writing code. Here are some of the reasons I enumerated:

  • TDD helps me think.
  • TDD helps me design.
  • TDD helps me create clean interfaces.
  • TDD helps me focus on developing just what needs to be developed.
  • TDD helps me clean up my code.
  • TDD tells me that my code does exactly what it is supposed to.
  • TDD lets me test my code as often as I like at the press of a single key.

That last point is more an artefact of unit-testing, but is still valid.

If you’re a programmer and you want to learn about TDD, you could do worse than reading Ron Jeffries’ bowling game examples, first the C# object-oriented example and then procedural version.

My first post of 2009 was on doing TDD in Python using Vim. Unfortunately, not all of the Python code owned by ${PETES_EMPLOYER} was written using the same editor or coding standards. I love the fact that Python uses indentation to determine code blocks and has no need for ugly braces everywhere but it doesn’t do anything to enforce discipline in this area. Occasionally, when working with Other People’s Code, I’ve encountered problems where a mixture of indentation styles have been employed and Python hasn’t behaved. Recently I discovered that Python can throw an error when this happens by supplying the switch ‘-tt’ to the interpreter. This is why all Python code that I write now begins with the following shebang line…

#!/usr/bin/env python -tt -Wall

I hope that is of some use to somebody.

Target $2,000!

Dear all,

You are quick, and generous. You are kind but brutal. I thought that calls for me to have my legs waxed were harsh, but you’ve quickly rallied together and raised the extra $500 I suggested would be enough for this to happen. And now it must. I have to say that I am dreading this.

Now there are calls for a "BSC". I’m sorry to have to disappoint but despite my hirsuteness, for reasons unbeknownst to me, I don’t have a hairy back. And since neither the ‘sack’ nor the ‘crack’ will be photographed in the name of good taste, this would be a pointless (yet painful, I imagine) exercise.

Since you have reached the $1,000 target I feel duty bound to offer more so that you might do the same. This time I am doubling the target to in return for my shaven arms and chest.

I feel I should mention that this is not an event that I am undertaking lightly. I really, really don’t like shaving my face in the morning. To shave more than that is a huge ask, so please drop by my profile page, give generously and help me help the Leukaemia Foundation in World’s Greatest Shave.

As ever, I’m deeply thankful for your support, be it financial or emotional!

Much love;

–paj

P.S: If there are any Olympic cyclists, swimmers or cross-dressers out there, I have a burning question: Do you use the same shaving products for your face as your body hair or do you use a products aimed at women?

$500 Target reached, $1000 for the wax!

I don’t like sending out emails to large lists of people, but sometimes needs must and yesterday I sent out two mass emails to people in order to gain more sponsorship monies for the Leukaemia Foundation.

Those emails are clearly paying off. Rather generously, you have taken my total past the $500 target and two three things must now happen. One, when the time comes I must shave my legs as well as my bonce. Two, I have to raise my fundraising target. Three, I have to provide you with some incentive to keep giving. Five, you must continue to sponsor me!

It is with great trepidation that I announce that if you help me raise $1000, I shall answer your repeated calls to not only shave my legs, but wax them too. What have I let myself in for?

So please now pop by my profile page and show your support by leaving words of encouragement, advice on how to wax(!) and most importantly a donation. Every single dollar counts. Once you have done this, please pass on the message to one friend or family member.

Deep thanks to all of you.

How to shave?

I forget if I mentioned that I’m taking part in the Leukaemia Foundation World’s Greatest Shave on 14 March 2009, but I am, so there and I’m looking at ways to raise more money.

Yesterday my delightful wife asked me if I was going to just shave at home or if I’m going to have an event to mark the occasion. To be honest, I’m yet to decide.

Please take a moment to pop over to my profile page and leave a message as to how you think I should execute the shave. Perhaps you’d pay good money to use the clippers?

While you’re over at my profile page, I encourage you to drop some coins in the collection tin.

Many thanks to all that have already donated and to those still to donate.

Wax on. Wax off!

I have been delighted, so far, with the generosity of those of you who have donated to the Leukaemia Foundation World’s Greatest Shave, that I mentioned recently, am mentioning now, and shall continue to mention until I’ve extracted every penny that you can afford to give!

My friend B left the following comment on my profile page:

There are many people out there who would pay good money for you to shave your legs. But I’d hope you’d wax too….?

If those many people are reading this, perhaps they would pay that good money of which B speaks and sponsor me?

As for waxing… how much is that worth to you?

Heartfelt thanks to those who have sponsored me and to those of you who will sponsor me!

On a different note, I have been asked to note that things aren’t rosy over at Facebook. Frankly, I can’t stand the site, as I demonstrated by deleting my Facebook account last month.

Page 5 of 13