Friday, November 30, 2007

Blogger Enhanced Post Editor

Bet you guys thought I forgot to post today, didn't you? C'mon, admit it. Tsk, tsk, no faith in me at all.

In fact, I'm posting this so late because I've spent all day putting together a Greasemonkey script to fiddle with the Blogger post editor. You can see the result on Userscripts.org.

And to give you an idea what it looks like…

Thursday, November 29, 2007

Encoding "data" URLs

"data" URLs can sometimes be useful for embedding small pieces of data when hosting a file is impossible or undesirable.

Two types of encoding are supported by data URLs — standard URL-escaped encoding and base64 encoding. (The result of the latter is technically URL-escaped as well, but none of the 65 symbols used actually require escaping.) Which encoding produces a shorter URL depends on what percentage of the characters it contains must be escaped in URLs. URL escaping triples the size of escaped characters (a percent sign followed by two hexadecimal digits) but leaves non-escaped characters intact, whereas base64 increases the size of all characters by ~33%.

This means that base64 is more efficient whenever the number of escape-requiring characters exceeds ~17% of the document's size:

3x + (1 - x) > 4/3 2x + 1 > 4/3 6x + 3 > 4 6x > 1 x > 1/6 = 16.6%

Related Links

Wednesday, November 28, 2007

Stupid Firefox tricks: Safari-style stop/reload button

Yup, still on my userChrome.css kick. This time, it's a way to make Firefox look like it has a Safari-style stop/reload button. First, arrange your toolbar so that your Reload button immediately follows the Stop button:

Stop button before the Reload button

Then, add the following code to your userChrome.css… when you restart your browser, the Stop button will only be visible when it is enabled and the Reload button will only be visible when Stop isn't.

/* safari-style stop/reload button */ #stop-button[disabled="true"] { display: none; } #stop-button:not([disabled="true"]) + #reload-button { display: none; }

Tuesday, November 27, 2007

Quote: Irrelevance is no excuse for ambiguity

Imagine you're giving someone driving directions to a house which is on a street which makes a loop. When the driver approaches the street, it doesn't matter which way they turn — either direction will get them to their destination, so you could simply omit it and skip straight to the street number. However, the poor driver is still going to be confused… unless you provide a direction or explicitly tell them that it doesn't matter, they won't know whether it's (A) irrelevant, (B) unintentionally omitted, (C) the result of incorrect instructions, …

Instead, the person providing the instructions should either provide a direction or make it clear that both are acceptable. Irrelevance is no excuse for ambiguity.

Monday, November 26, 2007

Stupid Firefox tricks: colored tabs

When I switched from using PermaTabs to Tab Mix Plus for protected tabs, I missed PermaTabs' coloring them. Fortunately, this can be easily accomplished for Tab Mix Plus via userChrome.css — just add the following rules (and, of course, change the colors to taste).

/* yellow for locked tabs */ tab[locked=true] > * { background-color: #F2F2A9 !important; } /* green for protected tabs */ tab[protected=true] > * { background-color: #A9F2A9 !important; } /* blue for frozen tabs */ tab[locked=true][protected=true] > * { background-color: #A9F2F2 !important; }

Tab colors can also be triggered off a web site's <title> by using the tab's label= attribute. The following uses the CSS3 [attr^=startswith] selector to provide a simple Gmail notifier — if I leave Gmail on my Inbox, the tab turns red when new mail arrives.

/* Gmail new message flagging */ tab[label^="Gmail - Inbox"]:not([label^="Gmail - Inbox -"]) > * { background-color: #F2A9A9 !important; }

Sunday, November 25, 2007

Intro

This blog is an introspective record of odd things I think about and tangents I venture upon while working, mostly while writing code. I'll be trying to make at least one post a day (just to keep in habit).

stupid tricks
When a tool doesn't do exactly what I want it to, I'm prone to spending unreasonable amounts of time trying to "fix" it. If I'm successful, I call the result a "stupid trick". I don't necessarily research the problem exhaustively before beginning, so I don't guarantee these tricks to be unique or even the best approach. All I can really say is that I came up with them myself.
quotes
These are the unfortunate results of my attempts to phrase things cleverly. Some may have value, but most are simply the product of my ability to be easily amused.