December 2003 Archives

Back to Workaday Life

| No Comments

Dave Pollard has a piece about saving time for bloggers. It's a reminder that I'm back in a place where time is in short supply and needs to be rationed.

During my vacation I slept nine hours or more most nights. I would idle the evening away in the living room, hanging out with family under the guise of watching television or playing cards, going to bed between midnight and one o'clock and sleep until 10:30 or so the following morning. Apart from a visa appointment at the embassy at 8:30 early on during my trip I had no pressing commitments. After the 23rd most museums and other places S. would want to see were closed anyway.

Coming back, it's hard to adapt the Taylorist mindset required to rouse myself from sleep out the door to catch a bus in less than an hour. For the moment, I'm still going to bed long before ten at night, so it's relatively easy to wake up at 6:30 and take an hour and a half. It doesn't feel as if I am slacking — I'm just not being ruthless about doing only what needs to be done in the shortest way possible.

It's enough to make you want to curse whoever invented agriculture and the associated evils of civilization and long for the existance of noble hunter-gatherers, who could do anything they wanted after they had got enough food to subsist. It's a myth, I know, but so attractive.

Fixing a Country Code Muddle

Came back from my holidays to find a report that a drop-down list of countries on our web site did not include Germany. A quick check showed that it also did not include Ireland. Oops.

On investigation, it had to do with a conflict between two tables. One table was using ISO 3166 country codes; the other was using FIPS 10-4. Most of the codes are the same, but many are not. For example, Germany is GM in FIPS-speak and DE in ISO-speak. Even worse, AU is Austria in FIPS-speak but Australia in ISO-speak. The nice folks at daml.org have made available an XML file with the conversions.

The Joys of a Digital Camera

S's parents gave us a digital camera for Christmas with the understanding that we would provide them with plenty of shots from our trip to Ireland. We just got back so I have spent most of the afternoon getting the pictures from the camera to my ISP's web server.

The camera is a Canon PowerShot A70. Neither of us is more than a point-and-shoot photographer, but it took good pictures even under fairly challenging conditions (high contrast, low light, that kind of thing). My Linux box is the only computer in the house with USB ports, so I paid a visit to Peter Toft's Linux / A70 Howto page.

My system is a little different to his: I am using SUSE 8.0 and he was using Mandrake. I found that digikam crashed when trying to load pictures from the camera. So did gphoto2, apparently at places where pictures had been erased from the camera.

I was eventually able to get gphoto2 to work. I downloaded, compiled and installed a more recent version of libgphoto2 (version 2.1.3 to be exact). With that change, gphoto2 loaded all the pictures from the camera. It still does not recognize the camera, so Peter Toft's workaround is still required:

gphoto2 --usbid 0x4a9:0x3073=0x4a9:0x3056 --camera "Canon PowerShot S40" -P

I used ImageMagick as described in an earlier entry to massage the photos a bit. (There is one additional step: the photos from the A70 are 3.2 megapixels, so the pictures need to be halved in size before they can be viewed on screen all at once.) The results can be seen at my ISP (for those who are interested).

Replacing Large Chunks of Text with Perl

| 2 Comments

Imagine a programmer finds chunks of (almost) identical code duplicated across multiple files. Such a programmer should be itching to extract those chunks. It doesn't really matter what programming language we're talking about: every non-trivial language has a way of refering to external code.

It's easy to do a simple find/replace operation where the text to be replaced does not run over any line boundaries. Any half-decent text editor can do it, as can tools like sed or awk, with minimal tweaking.

When it comes to chunks of text that span multiple lines or paragraphs, it gets a little harder, but not that much. A language such as Perl has more than enough power to handle the job.