Hello Tumblr; Bye Now, WordPress

I’ve migrated to Tumblr to experience all the fuss about it. Something about brainlessly posting to neat buckets of pictures, links, quotes, text etc. appeals to me more than WordPress’ long-form text format.

I don’t want to maintain two parallel blogs, so one of them has gotta go. This WordPress instance will be kept alive until I figure out a good way to 301 redirect WordPress posts to Tumblr.

Please update your bookmarks/URLs — all further postings will be made there from now on.

Serving versioned files—the awesome way

If you serve content with far-future expiry headers (if you don’t, you probably should), you need a way to make sure that clients get the latest files. You need to version those files somehow.

This post on Stack Overflow nails the perfect approach.

Versioning using the build number (as it’s almost always implemented) causes clients to re-download the files unnecessarily, even though most files probably haven’t been changed in that build. Using the file hash is brilliant—it is the perfect identifier of file content, which is what we really care about.

One thing I might change is to put the file hash as part of the file name, not as a query string. Apparently, some proxy caches don’t like query strings (I haven’t actually seen manifestations of the issue myself).

IE8 CSS Hack

I just discovered a CSS hack that applies to IE6, 7 and 8. It is basically just \9 right after the property declaration, but before the closing semicolon.

For example:

div {
    -ms-filter: "progid:DXImageTransform…";
    margin-right: -2px\9;

Plucked from a more comprehensive list of hacks at paulirish.com

This is starting to get a little out of control with IE6, 7, 8 and 9 on the horizon… time to look into better ideas.

The right way to generate months

I recently wrote this (partial) piece of PHP code to generate a list of months in a year:

for ($i=1; $i<=12; $i++) {
    $monthStamp = mktime(0, 0, 0, $i);
    echo date('F', $monthStamp);

Today, I suddenly have two “February”s in the list. Not Good. I missed the part in mktime()’s docs that say missing arguments will default to the current time, so the code was generating a timestamp for Feb 29 2010 (which mktime() interprets as Mar 1 2010).

So note to self—the fix is explicitly specifying the day of month (just “1” in this case):

for ($i=1; $i<=12; $i++) {
    $monthStamp = mktime(0, 0, 0, $i, 1);
    echo date('F', $monthStamp);