Monthly Archives: July 2006

[Perl|Ruby|Python|PHP] Golf

I have recently been playing with carl’s new project,

Basically the idea is to solve given programming challenges in as few characters as possible. The output from entries is compared to a reference output and any that pass the comparison are scored by the number of characters they used. Some challenges require you to parse input aswell.

The implementation is quite neat. Code you upload is run as an unprivileged user inside a chroot inside a jail in FreeBSD, and the whole lot is re-created for every run. Four languages are available, Ruby, PHP, Perl and Python with brainfuck (wikipedia entry) support promised soon.

Anyway, if you have a spare afternoon/evening/week it is pretty good fun.

If that sounded like an advert it wasn’t meant to :)

Set the format of ‘Date’ fields returned by Oracle

For some reason Oracle returns the date from ‘date’ fields in the format ‘dd-short_month_name-yy’ (or something like that) by default. This is crazy, who uses the date in that format? No-one, that’s who. To change the format of dates returned for all queries returned to a database handle do something like this:

$dbh->do("alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'");

(or the equivalent in your language of choice) and the date returned from any date fields will be sensible, much like the way postgres does it. And why does Oracle not allow the use of limit? I guess this comes as a £10,000 upgrade or something.

How to get the SQL that Perl’s DBI is running

It seems to be a question that comes up fairly often, and it is pretty easy:

$dbh->{TraceLevel} = "SQL";

Amusing response seen on a mailing list

24TB in 4U. Oooohhhh… missus…

Depends if you are a storage man or a processor man.

Best ‘site unavailable’ message ever

Seen on Fish4:

Thank you for coming to Fish4 this morning.

Unfortunately the fish4 website is unavailable due to the failure of a very expensive piece of Sun hardware (Sun 6900). A Sun engineer is at the data centre but didn’t think to bring the replacement part with him.

We hope the sun engineer will have repaired the hardware by 12pm, and will update this estimate if necessary as the work progresses.

Here is a screengrab of the error:


I have no idea how I did that

Well, I came top in Top the Table (a world cup prediction league)!

No-one is more surprised than me, I really know very little about football.

99 bottles of Ruby beer on the wall

A while back carl and I had a 99 bottles of beer on the wall one-liner competition in Ruby. I just found this in my home directory and so am claiming it as my entry:

def b(c)"#{c} bottle#{c>1?"s":""} of beer on the wall"end;99.downto(1){|x|$>0?x-1:99)}.


It weighs in at a hefty 206 characters and I know it is possible to get it smaller than this, but it is way too much of a time-sink for me to try.

New job

I got a new job! I started one and a half weeks ago with the Guardian Media Group in the Regional Digital department. The department is responsible for a lot of regional sites, such as Manchester Online.

The offices are on Deansgate in Manchester and are nicer than the offices I used to work in partly because they are more central so there is more to do and more places to eat lunch including Wagamama, which I predict is going to cost me a fortune!

Anyway, I am doing much more web-development stuff now as opposed to the totally back-end stuff I was doing at Netservices so I should enjoy it more. And I have a better computer and more money :)