Getting my fortran head together

It’s very strange to be getting back into a language as different to Perl as it is possible to be. I’m fairly conversant with the weird bits of Perl — map, grep, hash usage, objects — but Fortran has a completely different toolkit

That’s not to say it’s a bad toolkit, just very different, F’rinstance, trying to find all the distinct values in an array. In Perl, you just walk through a hash, parallel to the array, incrementing each key for every value found. In Fortran — well, it’s a different story.

Seemingly innocuous comment spam

In the last 12 hours or so, I’ve been getting a new kind of comment spam on this blog. The text is fairly harmless: “very interesting article”, or “if you are using Linux or unix you can take a look at sourceforge.net”, but the link goes off to one of those pharmacy sites, or to russian car registration people.

Yes, I can run MT-Blacklist manually on them, and they are a bit lower key than the older style ones, but they’re still very annoying.

the tyranny of configure

I’m building Gentoo Linux on my laptop. Every little package that wants to build goes off and calls a configure script, as built by gnu autoconf. Every one checks the presence of features by compiling a little test program.

This gets slow. Quite why a system can’t cache autoconf results, and tell configure that it has this, that and the other. My computers seem to spend half their time somewhere in a configure script (serves me right for using Gentoo), but there has to be a better way than the status quo.

even cooler, simpler stuff

t21.jpg
Yes, it’s just a generic-looking KDE desktop (you’ll probably have to sleect the thumbnail to see the full-size image). But this was from an IBM T21 laptop I bought from Laptop Closeout.com today. I plugged the network cable into my router, stuck the USB key in the back, and booted from an old (3.2) Knoppix CD. You can see it found both the network connection, and the USB key. Oh, and it can play MP3s too.

No configuration was done. I just booted, and this is what I got.

SanDisk Cruzer + Gentoo

Sandisk Cruzer 256MB USB key

I love it when stuff just works. Plug it in, check dmesg to see what it says:

hub.c: new USB device 00:02.2-1.1, assigned address 7
scsi3 : SCSI emulation for USB Mass Storage devices
  Vendor: Generic   Model: STORAGE DEVICE    Rev: 1.02
  Type:   Direct-Access                      ANSI SCSI revision: 02
Attached scsi removable disk sdb at scsi3, channel 0, id 0, lun 0
SCSI device sdb: 512000 512-byte hdwr sectors (262 MB)
sdb: Write Protect is off
 /dev/scsi/host3/bus0/target0/lun0: p1
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 7

So we know from the /dev/scsi/host3/bus0/target0/lun0: p1
line that the filesystem is at
/dev/scsi/host3/bus0/target0/lun0/part1. Create your
mountpoint as root: mkdir -m777 /mnt/cruzer, then edit
/etc/fstab, and add:

/dev/scsi/host3/bus0/target0/lun0/part1 /mnt/cruzer vfat noauto,user 0 0

Any user can mount the device with mount /mnt/cruzer,
and next time Nautilus starts up, the device can be mounted from the
desktop. Easy!

The hardest part was opening the packaging, but you know what I
have to say about SanDisk packaging
 …

the nearly-new immigrants

Two years ago today, Catherine and I were huddled somewhat apprehensively in the immigration lobby of Toronto’s Pearson airport. After a couple of hours of waiting, paperwork and customs clearance (and several “Welcome to Canada!”s), we stepped out into the evening sleet, and headed straight for a Holiday Inn to crash.

We’ve done okay. There have been difficult times, but on the whole, we’re glad we came.

Sustainable Energy Fair

I survived the University of Toronto First Sustainable Energy Fair. The weather was pretty grim, despite the cold and the rain. Maybe some of the solar cooking events didn’t happen, but that didn’t dampen the spirits of all involved.

There was a good crowd, and I talked myself hoarse on the WindShare stand. There were some interesting people there, including the irrepressible Tom Karmo, and UofT‘s own cyborg, Steve Mann. And yes, I am really responsible for getting Winton Dahlström into wind energy; mea maxima culpa.

I have pictures of the sustainable energy fair here.

Touching the camel

Paul asked about getting back
to maintaining some Perl code after an absence of a few years. Since I
do a lot of Perl, here are some of the time-savers that I can’t live
without:

  • search.cpan.org allows you
    to search all the publicly-available modules on CPAN. There are few problems in Perl that
    haven’t been at least partially solved by a CPAN module. At the very
    least, make sure any web scripts use CGI.pm appropriately. I still see
    hand-rolled code that parses CGI arguments, never as well as CGI.pm would
    do.
  • PerlMonks is where you go
    to ask about your Perl problems, and find solutions. It’s worth
    learning a bit about the search options so you don’t ask a very old
    question again. This is me on
    PerlMonks, incidentally.
  • The Perl FAQ,
    included in the documentation as /perlfaq[1-9]?/. The Perl Cookbook is
    basically just the Perl FAQ on paper. Nice to hold, but you can’t
    search it the same way you can with perldoc -q <keyword>.

I would always advise Perl programmers to be
lazy
. Not slothful, but spend a little time seeing if someone
has solved your problem before. Thus you can turn many routine
programming jobs into a small matter of configuration.

I would also advise learning some of the idiomatic Perl tricks,
like ‘... or die ...‘, inline
if/unless, careful use of
undef, and list operators like map and
grep. It’s not just because you’re likely to meet them in
everyday code, but they’re very convenient. Once you start to miss
them in other languages, you’ll know that you are One Of
Us
.

sometimes you just have to …

… calculate the number of seconds in the current year using JavaScript:

function seconds_in_this_year() {
      // get length of this year by subtracting "Jan 1st, /This Year/"
      // from  "Jan 1st, /Next Year/"
      var now = new Date();
      var current_year = now.getFullYear();
      var jan_first = new Date(current_year, 0, 1, 0, 0, 0, 0);
      var jan_next = new Date(current_year + 1, 0, 1, 0, 0, 0, 0);
      return (jan_next.getTime() - jan_first.getTime()) / 1000;
}

late cat

I think I’m about the last person on the planet to get a Digital Convergence CueCat — remember those freebie barcode scanners that were going to change the world, until the parent company crashed and burned?

Active Surplus has a whole case of late-model USB ones (model #68-1966 for those who care). Maybe $14.95 is a little steep, but it does cover all your barcode scanning needs.

Toronto, the MFP enquiry, and Linux

At a Green Economics meeting last night, we heard from councillors Paula Fletcher and Glenn De Baeremaeker about the Toronto Computer Leasing Inquiry. It seems that the city is stuck with approximately 14000 Windows-NT class machines that it can no longer use, as Microsoft will not support its operating system.

I need to find out more on the specs of these machines, but I think it would be fair to say that they would be functional for most office applications with Linux. This has only been hinted at by other writers, but at least it could provide working, virus-proof computers to city staff at very little extra expense.

This could be something that the Toronto Linux User Group could look at.

Rendez-vous with the Triplets

triplets of belleville
Ah, how I love The Triplets of Belleville. I was brought up on a steady stream of Jacques Tati and Django Reinhardt, so it’s natural that I get along with this film very well. Especially since I scored a region-free copy in the UK. I can live with it being called Belleville Rendez-vous on the box.

It was robbed of an oscar. Finding Nemo was an amusing little merchandising platform, but ToB is genius. But what chance did a joint French-Canadian production have in a US-based competition?

Yet another Scottish rooftop turbine

Anent the WindSave turbine, yet another similar product has appeared: the Renewable Devices Swift. It’s Scottish too, and again there are few details. The Scotsman has the story.

Someone commented here that one could build such a device cheaply from parts from any DIY store. This isn’t quite the case. Properly formed blade sets are not trivial to make, and while you could build your own generator, weatherproofing it and making it CE-compliant would be hard.

appalling office samizdat generator

Remember when office walls were festooned with grubby, wonkily photocopied slogans, bad attempts at Snoopy cartoons, and all manner of xerox-worn paperwork? Something like this:
donthavetobemad.jpg

With everything being digital, and e-mailed the world over without degradation, I became nostalgic for the old analogue days. So I decided to emulate the squint, black-edged, mottled, heavily-thresholded imagery with the NetPBM toolkit and a shell script. You can download it here: pnmcopier – emulate a badly-photocopied document to stdout. It should work on most Unix machines. It does require that your shells sets $RANDOM, which might make it a bit bash-specific.

It works best with a fairly high resolution image. Be advised it’s a processor hog; it has to rotate, smooth and merge very large images. To compound the effect, pipe the output into pnmcopier, perhaps several times. I don’t quite have the parameters right, but it gives the desired level of grubbiness. Sorry I couldn’t reproduce coffee stains, staple marks, old tape ghosts or random doodles.

Do what you will with it, but harm none.