Friday, 7 December 2007

Let's go scripting

The latest article by Larry Wall is out, and it has the highest density of memorable quotes I ever observed in the wild. Go read it now!

Tuesday, 27 November 2007

The elevator dream

Light ascending I made one of those strange dreams tonight. My job was to write software for elevators. I had just read a (fictional) article by MJD on how bad is most software for elevators, and written by incompetent programmers. Full of those thoughts, feeling somewhat insecure about my ability to write good elevator software, I begin my work day by, you know, taking an elevator, to go to my office. At this exact moment, a bunch of Japanese girls show up and take the elevator with me. Somehow they know what I do for a living, so they start asking questions: "Hey, I'm vegan. Can't you design elevators for vegans? -- I'm Christian, and there are no good Bible-friendly elevators. -- ..." and so on ad libitum. When I said, "Bloody Hell", (for once, I dreamt in English), "Bloody Hell, why can't you just all take the same bloody elevator", I woke up.

Next time, I'll take the stairs.

Saturday, 24 November 2007

Dolphy's last words

Here are the last recorded words of Eric Dolphy, one of the most talented alto saxophonists of the jazz avant-garde of the early sixties (and one of the true continuators of Charlie Parker):

When you hear music, after it's over, it's gone, in the air; you can never capture it again.
Never capture it again? Those idealists, they would kill the music industry in the name of art! Hopefully, the music industry has now understood that music much too serious a matter to entrust to musicians.
(The quotation above can be heard at the end of Miss Ann, on his album Last Date, recorded in 1964. Not Dolphy's best recording, but a masterpiece anyway.)

Monday, 19 November 2007

Back from FPW2007

Iron windows I'm back from the French Perl Workshop 2007, in Lyon. That was a great conference. I took some pictures and made two presentations and one lightning talk.

The slides of the first presentation, Un Panorama de Perl 5.10, are available on-line. The second one didn't had any slides, since I just walked through the code of my module encoding::source, explaining what it does.

Finally, the lightning talk was the live upload on stage of perl 5.10.0 Release Candidate One. Download and test!

Monday, 12 November 2007

Flaubert's elephants

The Carthaginians did use elephants in their army, but those beasts were difficult to handle. Here's what Livy says about their drivers:

More elephants were killed by their drivers than by the enemy. They had a carpenter's chisel and a mallet, and when the maddened beasts rushed among their own side the driver placed the chisel between the ears just where the head is joined to the neck and drove it home with all his might. This was the quickest method that had been discovered of putting these huge animals to death when there was no hope of controlling them, and Hasdrubal was the first to introduce it. -- Livy, XXVII, 49

Also, in Salammbô, we read:
He [Hamilcar] organised a phalanx of seventy-two elephants with those which had returned from Utica, and others which were private property, and rendered them formidable. He armed their drivers with mallet and chisel to enable them to split their skulls in the fight if they ran away. -- Flaubert, Salammbô, VIII

Hasdrubal is the son of Hamilcar, and the brother of Hannibal. Flaubert's novel takes place during the Mercenary War (circa 240, Hasdrubal was probably not yet born), and the Livy quotation refers to the Second Punic War, more precisely to the Battle of the Metaurus (207) -- that is, afterwards.

In other words, Flaubert is guilty of anachronism. But he was certainly aware of that, and favored the literary effect over the historical accuracy.

Saturday, 3 November 2007

Hannibal and the vinegar

How Hannibal Barca and his army crossed the Alps to go in Italy to fight against Rome:

At last, when men and beasts alike were worn out by their fruitless exertions, a camp was formed on the summit, after the place had been cleared with immense difficulty owing to the quantity of snow that had to be removed. The next thing was to level the rock through which alone a road was practicable. The soldiers were told off to cut through it. They built up against it an enormous pile of tall trees which they had felled and lopped, and when the wind was strong enough to blow up the fire they set light to the pile. When the rock was red hot they poured vinegar upon it to disintegrate it. After thus treating it by fire they opened a way through it with their tools, and eased the steep slope by winding tracks of moderate gradient, so that not only the baggage animals but even the elephants could be led down.
-- Titus Livius, XXI, 37

Yes, vinegar. I'm full of admiration for this legendary hack.

Tuesday, 30 October 2007

Ubuntu, Dell laptop and hard disk power management

There has been some talk those days on laptop hard disk lifespan. See, for example, what Pascal says about it.

So, after some investigation, I saw that on my laptop (Dell Latitude D420) the BIOS doesn't handle an APM value of 255. By default the startup scripts execute hdparm -B 255 /dev/sda (or other devices) and that actually sets the APM value to 128 (as given by hdparm -I /dev/sda | grep Advanced). (I'm using Ubuntu 7.10 -- the script I'm talking about is /etc/acpi/power.sh.)

On the other hand, using -B 254 seems to disable APM. So here's a way to do it, by default, on every boot:

  • Add those lines to /etc/hdparm.conf:
    /dev/sda {
    apm = 254
    }

  • Make /etc/init.d/hdparm run at startup:
    ln -s /etc/init.d/hdparm /etc/rcS.d/S07hdparm

And now the load cycle count reported by SMART remains stable. Which means that hopefully my hard disk will live longer.

Addendum: if you don't use SMART, you should. Install the smartmontools package, enable SMART on your disks with smartctl -s on, and read the smartctl(8) manpage. Optionally, enable the smartd monitoring daemon (via /etc/default/smartmontools).

Wednesday, 24 October 2007

urxvt + perl

I'm playing with urxvt (a.k.a. rxvt-unicode), a fully Unicode-aware terminal forked off the popular rxvt.

One of the good things with it is that it's fully scriptable in Perl. Here's my first attempt, a small plugin that adds an item in the popup menu (given by the standard Perl plugin selection-popup) to draw in bold font whatever matches the selection. It's not extremely useful, but that's a start.

our $selection_hilight_qr;

sub on_start {
my ($self) = @_;
$self->{term}{selection_popup_hook} ||= [];
push @{ $self->{term}{selection_popup_hook} },
sub { hilight => sub { $selection_hilight_qr = qr/\Q$_/ } },
sub { 'remove hilight' => sub { undef $selection_hilight_qr } };
();
}

sub on_line_update {
if (defined $selection_hilight_qr) {
my ($self, $row) = @_;
my $line = $self->line($row);
my $text = $line->t;
while ($text =~ /$selection_hilight_qr/g) {
my $rend = $line->r;
for (@{$rend}[$-[0] .. $+[0] - 1]) {
$_ |= urxvt::RS_Bold;
}
$line->r($rend);
}
}
();
}


As you can see, this code is pretty small (although not very readable maybe -- I dislike using @+ and @-, but my urxvt isn't compiled against a Perl 5.10 :).

Well, I'm now looking for ideas. What would be cool for a terminal to do for you (and that urxvt doesn't already provide?)

Monday, 8 October 2007

New camera

I just got a new camera, a brand new Canon PowerShot A720 IS. Very nice compact camera. Great optical zoom (6x). Possibility of manual settings. Nice UI (so far). There's no detailed user manual, though -- I still need to learn how to program my modes, etc.

I spent my sunday playing with it. I've uploaded a couple of shots to flickr -- more, of course, are to follow.