One liner to add a public key to a remote authorized_keys

Wednesday Apr ‘10 14

From the very, very useful Top Ten One-Liners from CommandLineFu Explained:

 ssh remote-machine 'cat >> .ssh/authorized_keys' < .ssh/id_rsa.pub

Leave Your Reply →

Syntax Highlighting for QuickLook

Tuesday Mar ‘10 30

More comprehensive syntax highlighting for Snow Leopard’s QuickLook: qlcolorcode

Leave Your Reply →

Triggering quirks mode in IE

Thursday Mar ‘10 11

When XHTML was all the rage years ago, it was common knowledge that an XML prolog declared before the doctype will trigger quirks mode in IE6. That has been fixed in IE7.

However, I found out that actually anything at all, except for white spaces and the XML prolog, will trigger quirks mode in IE6, 7 and 8 for doctypes that should otherwise trigger standards mode.

So if someone decides to add <!-- $Id$ --> to the first line in the HTML file, it will trigger quirks mode in IE. Now you know too.

Leave Your Reply →

Is this why IE6 doesn’t support PNG24?

Monday Mar ‘10 8

So Mosaic‘s source code has just been released on GitHub, and a sharp eye at Reddit has already spotted this gem (keep in mind that IE is originally derived from Mosaic).

Assuming that IE was actually derived from this code base, may I present the reason we had to work around PNG24 for almost a decade:

/* its #if'ed out for now cause I don't have anything to
   test it with */

1 Comment →

HTML5: <!DOCTYPE html>

Sunday Mar ‘10 7

All the cool kids have started using the new HTML5 doctype:

<!DOCTYPE html>

It triggers standards mode even in shitty browsers, so we can dump its verbose predecessor and start blazing a path of HTML5 glory.

Leave Your Reply →

HTML5: <meta charset="UTF-8">

Friday Mar ‘10 5

The old way:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

The HTML5 way, which works on all browsers:

<meta charset="UTF-8">

Even though the charset can and should already be set in the HTTP response header, the meta tag is still relevant when the document is offline.

Leave Your Reply →

Naming conventions should follow the language

Wednesday Mar ‘10 3

For example, id, class and attribute names should be in lowercase-with-dashes in HTML/CSS; JavaScript names should be in camelCase (better defined here); and anything in URLs (including file names) should be in lowercase not only because of conventions, but for cross-platform compatibility as well.

Please, avoid crazy shit like ab_someName and keep things consistent!

Leave Your Reply →

F.lux: better lighting for your screen

Friday Feb ‘10 26

F.lux adjusts the color temperature of your screen to match your lighting and time of the day.

Leave Your Reply →

Optimize only when you have a reason to.

Wednesday Feb ‘10 24

Measuring Javascript Parse and Load

While studies like this are fascinating to observe and to learn from, be very careful — unless you’re doing something like distributing JS libraries, these optimizations probably do not apply to you.

Keep in mind that the parse-and-load test runs 1000 iterations; in the first table, the actual average parse time is really only 0.125ms at worst and 0.003ms at best. Compare that to the average HTTP request — you might see sub-30ms responses just for a HTTP 304 on a good day, but 1000ms+ responses are not unheard of on unprimed caches (even more with DNS lookups). To put this into perspective, a snappy HTTP request at 30ms is more than 200 times slower than the slowest parse time of 0.125ms.

In other words, the net improvement you might gain from such parse-and-load optimizations is insignificant compared to the improvement from removing just one HTTP request.

So before you go adding more lines of code to accomplish yet another new trick, profile your code to see where the actual bottlenecks are. Otherwise, this smells like a lot like premature optimization.

Update: I’ve wrongly interpreted the results table and Carlos has corrected me. This means that the cost of script parsing and loading is significant, and optimizing this should help reduce CPU load which is hard to benchmark in real world conditions but could certainly be perceptible to users.

3 Comments →

Always check your permissions!

Wednesday Feb ‘10 17

Note to self — Apache (stock on Leopard, which runs as _www) cannot read the preset directories in my home directory (like Desktop, Documents, Downloads, Library etc) because these directories only allow owner access by default (drwx------).

So that is why PHP won’t include files on my desktop. D’oh.

Leave Your Reply →