Poorly Hacked Perl

I have to admit, I’m gaining more than a sneaking admiration for PHP, the web application language that WordPress and Gallery are written in. It does remind me of an even more hacked-together version of Perl, but if it works well, well …

I looked for books, but they seemed to be out of date or very expensive, or both. So I’m sticking with the online PHP Manual.

The ‘head -n’ debacle

Unix/Linux has a handy little tool called head that will print the first few lines of a file. Run without options, it’ll give you the first few lines, but called f’rintsance head -20, will give you the first 20. It’s worked this way since basically ever.

Now whenever I run it, I get the following smug little message:

head: `-N‘ option is obsolete; use `-n N‘ since this will be removed in the future

I don’t consider myself an old Unix programmer, but I know that there are probably 12 year old scripts of mine working in former employers’ offices far, far away that will need fixing if they ever get rid of the sane old `-N‘ option. For any sakes, why, man, why …?

The message is also rather ambiguous. Why would I want to use `-n N‘ if it will be removed in the future? I knew all along that I should stick with `-N‘. The right of the people to keep and bear heads, shall not be infringed, anyone?

brr brr bddr brr weew brr brr

Apologies to our neighbours for my testing the Wheelwriter this morning. This is what I found out about it (after having to compile in parallel printer support to the kernel, grr):

Do we need CRs? : yes
Does it talk ASCII? : yes, subset
Bidirectional? : yes

I chickened out and installed the Courier 10 printwheel just so I could use spaces to line things up. I don’t like Courier at all, but at least it’s easy to manage.

It’s strange that, in this age that we are creating information at an unparalleled rate, we’re also losing it just as fast. While IBM Wheelwriter codes from the late 1980s do not represent the lost wisdom of the ancients, it is something of our knowledge, and once lost, diminishes us all.

Therefore, send not for whom the (carriage return) bell tolls; it tolls for thee …

Just like on the old Amstrad CPC

For no really well defined reason, I used to spend hours designing really tiny bitmap fonts on my old Amstrad CPC. Now it seems that Jason Kottke has done the same thing, but in truetype format:

silkscreen, in fontforge

Silkscreen
reminds me of the HP49g‘s system fonts. You used to be able to get one of those in a scaleable form, so I wonder how similar it looks.

I’m not sure if Jason’s copyright warning would work very well:

This font is free for personal and corporate use and may be redistributed in this unmodified form on your Web site. I would ask that you not modify and then redistribute this font…although you may modify it for your own
personal use.

Back in my pre-press days, I discovered that a font becomes your design if you trivially modify just 5 glyphs. It’s an artefact of the early type producers lobbying to be able to rip each other off … not something that happens much in these DRM-obsessed days.

the word “bummer”

WordReference used to have all the Collins dictionaries available online, for free browsing. I was the main dictionary computing guy at Collins when this deal was made, and it was pretty cool to have a good, non-US English dictionary on the web.

I gues the money has run out, as the Collins data has disappeared, and the English dictionary is derived from WordNet. While I think that WordNet‘s a worthy project, it doesn’t quite compare to the Collins English Dictionary.

Oh well, it was good to know you, WordReference.

Phew, redirects are good!

So I think I’ve got all the old articles appearing at their old urls using .htaccess Redirect rules. This is a modification of a method described in the WordPress MT-Redirect method.

I had a directory of the old numerically-named MT archives, so I used the following script to create a .htaccess file:

for f in 000*html
do
 v=`basename $f .html`
 g=`echo $v | sed 's/^00*//;'`
 echo 'Redirect Permanent' /blog/archives/$f 'http://scruss.com/blog/index.php?p='$g
done

which looks like:

Redirect Permanent /blog/archives/000001.html http://scruss.com/blog/index.php?p=1
Redirect Permanent /blog/archives/000002.html http://scruss.com/blog/index.php?p=2
Redirect Permanent /blog/archives/000003.html http://scruss.com/blog/index.php?p=3
 ...
Redirect Permanent /blog/archives/000322.html http://scruss.com/blog/index.php?p=322

I put this .htaccess file in the root (top level) directory of my domain, and it all works! Everything I set out to do when reindexing my old MT entries has been completed — see, lookit: http://scruss.com/blog/archives/000214.html

Normal Service Resumed, I think

I just got my blog working pretty close to the way I want it to be again. I should be back up and posting.

Big huge apologies to Catherine, with whom I was quite unnecessarily grouchy while this was not working. Sorry, Hen!

two companies that don’t get it

Please, online companies, whatever you do, don’t send users’ usernames and passwords in clear over e-mail. I’ve just ordered from Future Photo and delivery.ca, and both do this. Worse still, delivery.ca (or at least their Pizzaville service) allows you to save credit card information on their site.

As one who is just recovering from more than $8000 of fraudulent transactions on his card, this does not inspire confidence.

Linksys NSLU2 – Network Storage for the people

I’d been looking for a backup solution for a while, and yesterday I found it in the very small shape of the Linksys NSLU2 – Network Storage Link for USB 2.0 Disk Drives. There’s been a lot of talk recently about hacking these tiny embedded Linux boxes, but I just want to store stuff from my Linux machines and Catherine’s eMac.

I bought it, an external USB2.0 3.5″ drive case, and a 160GB Seagate driver yesterday from Canada Computers on College St for under C$350, including tax. It took about half an hour to assemble it, install it, and format the drive from the web interface.

I find it’s easiest to make named users — and tell the unit to make a subdirectory for that user — than fiddle about with other methods of making shares. You’ll also need to enable smbfs (File Systems → Network file Systems → SMBFS support in your kernel config) on your Linux machines.

I have created three shares: scruss (for me), craine (for Catherine) and mp3 (for our shared MP3 collection). I have created relevant directories from /mnt, and chmoded them to the appropriate user. These are the lines I have added to my fstab:

//squirrel/scruss	/mnt/smb_scruss	smbfs	username=scruss,password=******,rw,users	0 0
//squirrel/mp3		/mnt/mp3	smbfs	username=mp3,password=******,rw,users	0 0

I renamed the NSLU2 squirrel to fit in with the Canadian rodent theme I’ve got going with the other machines around here.

With Catherine’s eMac, I’ve found I have to use the OS X 10.1 / .nsmbrc method. Once you have the shares defined in the .nsmbrc file, you can call them up by doing Connect to Server and specifying something like smb://netbiosname/share, like smb://squirrel/craine.

The NSLU2 looks like it will be rock-solid. It has a couple of quirks — it formats the drive in Linux ext3 format, it will shut down at the slightest hint of a power glitch, and it’s rather slow — but I can put up with slowness if the data’s secure.

Mostly working

Okay, WordPress works now. I’m keeping the old MT archives for now, as there doesn’t seem to be a sane way of getting Apache’s mod_rewrite to work properly here. I suspect PEBCAK, probably, with intensely arcane rewrite rule syntax as a mitigating factor.

nice scaling

My Nikon D70 makes images that are too large for the web, so I have to scale them down. Most image scaling routines use simple linear interpolation, which can lose a lot of detail, but some packages use cubic scaling. This keeps most of the detail.

I was looking for a scriptable cubic routine, and I found it in Image::Magick, aka perlmagick. The syntax is simple:

$x = $image->Resize(geometry => '50%',
                    filter => 'Cubic');

I used this routine to resize my 2004 Ontario Renfest pictures.

two cheers for sympatico

Sympatico finally fixed my DSL problems last night. It seems that my account was set to fast mode, when the cheesy old copper we have around here really needs interleaved mode, which trades higher latency for error-correcting operation.

I’m happy now, but why did it take two calls — the second of which I was on hold to the Bell DSL centre for nearly 20 minutes — to sort this simple problem?

photo printers

I want to print some of my D70 pictures, so I asked the GTABloggers what they used:

I’m looking for a non-proprietary upload system, so Ofoto is out. I’d like to try photocentre.ca, but I know no-one who has tried them.