Wishful Coding

Didn't you ever wish your
computer understood you?

Food versus code

Food: 279kJ/66kcal; E263, E181, E459;
Code: [a-zA-Z0-9]*; hey
Now, which one is easier to decipher? Do you think we need simple food, simple code, or both? For the record, the first food part is from coffee, the ingredients are Calcium acetate, Tannin and Beta-cyclodextrine. The first code part is a regex matching any number of alpha-numeric characters, the second part is 'hey' in html entities.

Shorten Wordpress urls in Adium

I use Adium as my Twitter client, it includes a nice url shortener supporting multiple services, so what is my problem? Nothing, I just had some fun making use of the wp.me service. Every Wordpress blog contains a header containing the short url, so it was only 3 lines of Applescript and one line of Bash to get the short url of any wp blog and post it to Adium. If anyone with knowlegde of regex/grep comes around, he might get it to work with any shorturl/shortlink header.

Shorten Wordpress urls in Adium

The current line looks like this:
curl --head <url> -s | grep -o http://wp\.me/[a-zA-Z0-9\-]*
Update: sed seems to be able to do what I want.
curl --head http://pepijn.cqhosting.nl/ -s | \
sed -n 's/Link: <\(.*\)>; rel=shortlink/\1/p'
Use:
%_shorten{<url>}
Download the script: shorten.AdiumScripts

Cross-domain caching

Looking at the list of HTTP headers at Wikipedia, you'll notice a few headers like If-Modified-Since, that serve to send content over only if it has changed since the last request. While working with JavaScrip frameworks like jQuery, the thought occurred to me, that maybe half of all the websites I open are using the exact same JS framework, isn't that a waste of bandwidth? The best real-life solution would be to get your JS from Google, so you at least share a cached version with others that do the same: http://code.google.com/apis/ajaxlibs/ My imaginary solution however, would allow the same file, served from different hosts to be cached only once. Look again at the list of headers... We're looking for something to identify files as equal... What about Content-MD5? It exists, right there! But as far as I can tell it's used for content-verification only. So I want to propose a new HTTP header: If-MD5-Differs What do you think about it? Cool? Useless? Security issues?