Hello Tumblr; Bye Now, WordPress

Sunday Nov ‘11 20

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.

Leave Your Reply →

Sending Accept-Encoding headers in cURL

Tuesday May ‘11 3

If you’re testing gzip compression on your webserver using cURL, don’t forget to send the appropriate request headers:

curl -H "Accept-Encoding: gzip,deflate" http://www.jetsetter.com

(Another one of those note-to-self’s.)

Leave Your Reply →

Tips and tricks for Mac OS X Terminal

Tuesday May ‘11 3

Very useful. I bet you don’t know most of these.

Leave Your Reply →

Serving versioned files—the awesome way

Tuesday May ‘11 3

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).

Leave Your Reply →

Set a code breakpoint in JavaScript

Tuesday May ‘11 3
// Some code here
 
debugger;
 
// Some code there

That’s it. I had no idea! Works in Chrome too, by the way.

Found it here.

Leave Your Reply →

IE8 CSS Hack

Thursday Sep ‘10 2

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.

Leave Your Reply →

The right way to generate months

Tuesday Jun ‘10 29

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);
}

Leave Your Reply →

Comparing dates in JavaScript

Wednesday Jun ‘10 2

Turns out that we can directly compare two native Date objects in JavaScript using normal comparison operators like =, < or >, since the comparison invokes valueOf() of the object, not toString(). Therefore, there’s no need to call Date.getTime() to compare timestamps.

Kudos to T.J. Crowder for his well-researched post.

Leave Your Reply →

Word Movement in Terminal

Thursday May ‘10 13

I had trouble finding the right incantations on Apple Terminal to make the ⌥← and ⌥→ shortcuts work.

The instructions are right here.

Leave Your Reply →

“Get Rid of the Crappy Stuff”

Tuesday Apr ‘10 27

More nuggets of wisdom from The Jobs to Nike’s President & CEO, Mark Parker on Fast Company:

“Just get rid of the crappy stuff and focus on the good stuff.”
— Steve Jobs

Leave Your Reply →