Thursday, 24 April 2008

Company car time!

Yes, I know that company cars do not make sense financially but......

I've hankered after one for over 20 years and, now that I've finally become eligible and, having loads of grief with my just out of warranty caravan tug and, with one of the family holidays coming up soon...

It seems like now might be the time to make the switch. Of course it wont arrive in time for the holiday, so hopefully I can get the problems sorted in time.

Thursday, 17 April 2008

Python homework

As part of a 'Python study group' at work, we were given the following challenge:


Exercise 1:

Write a program that processes a list of numbers from 1 to 100. For each number, if the number is a multiple of 3, print “FIZZ”; if the number is a multiple of 5, print “BANG”; otherwise, print the number.

You are *NOT* allowed to use any *IF/ELSE* statements in your code. You can use the list-accessing ternary operator hack, but whilst I’ll accept your homework if you do, you’ll miss out on the prize (alcoholic), which goes to the most concise code (not including whitespace).

Have fun!


Here's my final solution:


for i in range(1, 101):
f = (i % 3 == 0) and "FIZZ" or ""
b = (i % 5 == 0) and f + "BANG" or f + ""
n = (len(b) > 0) and b or i
print n

Wednesday, 12 March 2008

flickr -> photobox transfer

SWMBO asked me if I could help transfer some of our flickr photos to photobox so that she can create and print an album. A quick Google seemed to find a few links for doing it the other way around, so it seemed like time to get knitting some perl!

Flickr has an API and photobox lets you use ftp to upload, so I thought I'd use the perl API to download the 4 sets that my wife had arranged on flickr. Anyway, here's the code with keys etc obscured. Sorry it's pretty rough and my perl is not too hot, but at least it works.


use Flickr::API;
use Data::Dumper;

my $api = new Flickr::API({'key' => 'your_flickr_api_key',
'secret' => 'your flickr_secret'});


my $frob = $api->execute_method('flickr.auth.getFrob', {
'api_key' => 'your_flickr_api_key',
});
my $f = $frob->{tree}->{children}[1]->{children}[0]->{content};

my $url = $api->request_auth_url("read", $f);
my $cmd = "C:/Progra~1/Mozill~1/firefox.exe \"$url\"";
system($cmd);
sleep(3);

my $token = $api->execute_method('flickr.auth.getToken', {
'api_key' => 'your_flickr_api_key',
'frob' => $f,
});

my $t = $token->{tree}->{children}[1]->{children}[1]->{children}[0]->{content};

my $response = $api->execute_method('flickr.photosets.getPhotos', {
'photoset_id' => '72157601397952579',
'auth_token' => $t,
});

my $ids = $response->{tree}->{children}[1]->{children};

for my $id (@$ids) {
if ($id->{attributes}) {
my $photo_id = $id->{attributes}->{id};
print "$photo_id\n";
my $sizes = $api->execute_method('flickr.photos.getSizes', {
'api_key' => 'your_flickr_api_key',
'photo_id' => $photo_id,
'auth_token' => $t,
});

my $s = $sizes->{tree}->{children}[1]->{children};
for my $size (@$s) {
if ($size->{attributes}) {
if ($size->{attributes}->{label} eq "Original") {
my $url = $size->{attributes}->{source};
print "$url\n";
my $c = "wget $url";
system($c);
}
}
}
}
}

Sunday, 9 March 2008

Central heating problems - from bad to worse

I've been working on a bathroom re-fit for the last few weekends. Last weekend, I removed a radiator and replaced it with a heated towel rail. This involved draining the system down. Sad to report that it's never been the same since.

The boiler started making a right old racket, thumping, banging and occasionally venting into the expansion tank. A phone call to a trusty plumber friend, and I'm pretty convinced that there is now some air in the system. Looking back I think this might have been caused by trying not too lose all the water in the system by turning off as many radiators as I could at both ends before draining down.

So this Saturday, I started to investigate.

The boiler is situated in a sort of utility room that links the house with the garage, and in the garage loft above there is a sort of pressure relief valve that I had trouble with last year when it started leaking. I wondered if this was adjusted down too tightly and was not allowing any air to escape, so up I went for a fiddle. DISASTER. The rubber o-ring is perished and, before I know it, the system is pissing out and dripping down into the wall mounted boiler below. A quick panic has me draining down the system again, and rushing off to B&Q to get a new o-ring. Once refitted, all seemed OK, until a couple of hours later I notice that the boiler is not firing at all, the whole system is off and the fuse has blown. To cut a further chapter short, the water from the leak has dripped down into the top of the pump that is sited under the boiler and cause the pump electronics to blow...... pump now f**ked. Another trip to Wickes this time for a new pump. Manged to fit that, but now one of the pump valves has a tiny leak from the screw that turns to isolate the pump. A common problem apparently.

Next weekend I'll be draining the system again to fit new pump valves.

The only good point about this is that the system does seems a lot quieter now.

I'm sure it's on borrowed time as the boiler is over 20 years old. Although I've replaced a boiler in the past, I wont be doing it again, so maybe this summer we ought to get it looked at?

Ubuntu upgrade to 7.10 problems!

I don't use my dual boot Ubuntu that often except that it's wireless network seems far more performant and reliable than that on XP running on the same machine using the same USB wireless adaptor. Irony follows....

I boot into Ubuntu, and like nearly always, it prompts me to do some software upgrades, this time asking me to upgrade the whole OS. Like a fool I accept. About an hour later, it's all done, but no network! Woe is me.

Resort to trusty google, and this pops up! Lug the desktop down to the router to get a network connection, and it all worked fine.

Not good marks for Ubuntu though.

Monday, 3 March 2008

Michael Clayton

Last night I watched "Micheal Clayton", one of 2007s most well received and awarded movies. A couple of things about this made me think.

Firstly, I downloaded the film using BitTorrent, naughty me! However, is there a difference between doing this and watching the film once, and just borrowing the
DVD from a friend, and doing the same. Are both illegal?

Secondly, more directly related to the film, what was all the fuss about? OK, it was a reasonable film, but how does Tilda Swinton get awarded an Oscar
for best supporting actress? It seemed to me she was only on the screen for about 5 minutes in total.

Thursday, 7 February 2008

Fix It Again Tomorrow

Well, after several months of prevaricating, I've finally taken the plunge and ordered a brand new car, well second car anyway, mainly used as a local run-about. It's the first brand new car I ever had, but only a really small and cheap Fiat Panda.

In spite of generally good reviews and great economy and low running costs, I'm slightly nervous of getting a Fiat given their past poor reputation. Only time will tell.

The only colour it comes in at no extra cost is a rather pale yellow. If it was a nice bright yellow, I'd be pleased, but anyway my wife insisted she wants a black one. The extra £360 makes a slight nonsense of getting a rock bottom price, but who am I to argue.

Only 6-8 weeks to wait!