Patrick Moore Plays the Xylophone

Two things surprised me in this BBC article about Sir Patrick Moore’s recent brush with Duck-induced death. The first is that Moore has never before missed a show of The Sky at Night which has been running since 1957. Note that BBC News is now celebrating 50 years on television so it seems that The Sky at Night is almost as old as television itself in the UK. That’s somewhat longer than Gamesmaster lasted, and he hasn’t missed one until now.

The second thing that surprised me was this:

He is a self-taught musician, famed for playing the xylophone and composing.

(Emphasis mine)

So this isn’t entirely inaccurate.

Cryptic Arcana

With great power comes great unreadability, at least in the case of Apache’s mod_rewrite. I recently remarked on my reorganisation of SoylentRed’s archives but the same old archives are still there. What gives? I made some significant changes on my local test server to replace the old style URLs like http://www.soylentred.net/archives/?month=jul-2004 with the more useful http://www.soylentred.net/archives/2004/07/ (remember: at the time of writing that URL won’t work). In fact the new system has five types of archive page. There’s the complete archive, http://www.soylentred.net/archives/, which displays the titles for every post ever; the yearly archive, http://www.soylentred.net/archives/2004/, which displays the titles for every post in the given year; the monthly archive, http://www.soylentred.net/archives/2004/07/, which displays complete entries for the whole month; the daily archives, http://www.soylentred.net/archives/2004/07/06/, which displays all entries for that day; and the individual archives, http://www.soylentred.net/archives/entries/187, which is the new style for permalinks.

Uh, yeah, permalinks. Won’t they be messed up? That’s the beauty. It’s also the reason I’ve called this post ‘cryptic arcana’. I’m talking about mod_rewrite, the Apache module that rewrites requests on the fly according to a series of regular expressions. You see there are no directories on the server called /2004/ or /entries/. That wouldn’t scale. Instead I have a set of rules:

# Rewrite archive URLs:
RewriteRule ^archive/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ archive/?year=$1&month=$2&day=$3
RewriteRule ^archive/([0-9]{4})/([0-9]{1,2})/?$ archive/?year=$1&month=$2
RewriteRule ^archive/([0-9]{4})/?$ archive/?year=$1
RewriteRule ^archive/entries/([0-9]+)/?$ archive/entry.php?id=$1

For example the first rule looks for any request of the form archive/ followed by four digits, a slash, one or two digits, a slash, one or two digits and possibly an optional trailing slash. It then rewrites it in the form archive/?year=, then the four-digit block, then &month= then the first one- or two-digit block, then &day=, then the second one- or two-digit block. The advantage of this second form of the URL—which incidentally would work if you typed it directly rather than using the pretty form—is that it directs every archive request to a single script so there’s no need for seperate directories for every year, month and day since the site launched.

Okay, now to get back to the permalink issue. The old archive links point to archive/?month=MMMYYYY, where MMM is the three-letter abbreviation of the month name and YYYY is the four-digit year. You may notice that this is exactly the same script as the new URLs ultimately point to. Then its a simple matter of PHP mojo sorting the ‘month=MMMYYYY’-style requests from the ‘year=YYYY&month=MM&day=DD’-style requests. The old permalinks point to archive/?id=N where N is the numerical ID of the entry. Again this is the same script that deals with all the other requests. In this case it simply looks for the ‘id=’ query string and, if it’s found, redirects to the new URL archive/entries/N. This URL, when the browser asks for it, will then be subject to the same mod_rewrite rules above. In this case the fourth rule takes effect and passes the ID to a script called entry.php.

And the reason none of this is actually deployed yet? Well that’s because I left out a line that’s necessary on the Linux server that SoylentRed runs on but isn’t necessary on my own Windows machine. The line is Options +FollowSymlinks and I have no clue what it has to do with mod_rewrite. Now that I know it’s probably just a matter of uploading. But if there’s anything I’ve learned from the last year and a half of SoylentRed it’s never to upload anything until I’m prepared to fix whatever goes wrong this time.

MakeLink

I’ve modified my installation of Dean Allen’s Refer to keep out anyone who isn’t, well, either me or very good at imitating me. So you’ll just have to take my word for it when I say that since MakeLink was listed on update.mozilla.org I’ve been getting new hits every ten minutes. This has been fairly constant since around 11 o’clock yesterday.

Since it’s now pretty obvious that MakeLink is the main gateway for new visitors to the site I’ve gone all out—by my standards—and spend a minute sprucing up the project page for it. It’s a very small extension, and a little bit specialised, but—even though I wrote it with no intention of using it—I find myself using it all the time. Given the new extension system for Firefox—specifically the capacity to uninstall extensions rather than just disabling them so you can install them with no risk—you might want to give MakeLink a go.

Toasty

From bash.org:

Rabidplaybunny87: Okay, so my neighbors officially hate me
GarbageStan23: why?
Rabidplaybunny87: Well, me, david and andrew were having a bonfire in the backyard, and we were making s’mores and all… and suddenly we here sirens, and see a firetruck turn into the street in front of us.
Rabidplaybunny87: So we all went running to see what was up, and our neigbor’s house was on fire!
GarbageStan23: oh shit!
Rabidplaybunny87: Yeah, and when we got there, the wife was crying into her husbands arms, and we were just kinda standing there, and then she saw us, and then like for 10 seconds, gave us the dirtiest look ever
Rabidplaybunny87: Turns out, we were still holding our sticks with marshmallows on it, watching the fire….
Rabidplaybunny87: talk about bad timing…