Flash for mac is bad for your HTTP_HOST

I’ve been testing the super awesome swfupload code for some projects at work. I have nice progress bars working and you can queue up multiple files. It’s sweet. I tested out my code in Opera, Firefox, Safari 3, IE 7, etc on Windows and Linux. Working great.

Of course, an hour before an important meeting is when we discover it doesn’t work on any mac browser. The flash debug output shows our site initialization code is just throwing a fit. No DB access settings can be found. Doesn’t make any sense why an HTTP request from flash on a mac would break our app.

Here’s the basics of how our our setup switches dev/production settings:

if ($_SERVER['HTTP_HOST'] == 'example.mydesktop') {
} else if ($_SERVER['HTTP_HOST'] == 'example.com') {

It makes considerations for www. etc. The problem in this case is that flash is adding :80 to the HTTP Host header. Instead of

GET /path/to/file HTTP/1.1
Host: example.com

Flash for mac likes to add

GET /path/to/file HTTP/1.1
Host: example.com:80

This will cause ‘example.com:80’ to show up in the php $_SERVER[‘HTTP_HOST’] variable. You can see how this would break simple host detection.

Written by Comments Off on Flash for mac is bad for your HTTP_HOST Posted in General Tagged with ,

Scrabble word search

While playing scrabulous online recently, I found myself needing a site to search for words that start or end which what I have in my scrabble letters. I didn’t find anything good so I decided I would write my own. Not sure how to exactly describe the feature, I decided to call it scrabble lookup. You search for any part of a word, and it gives you lists of all the words that start with that phrase or end with that phrase. The lists show the length of the word and points earned, assuming no multipliers. It takes into consideration the maximum number of letters in scrabble which means that some words you would need the blank letters to spell.

And yes, there are words that end in q.

Written by Comments Off on Scrabble word search Posted in General Tagged with

Greasemonkey script for twitter

A few weeks ago I was thinking about how hilarious it would be to view twitter pages with OMG: prepended to all the messages. I’ve had a post-it note attached to my monitor ever since that has 3 words: twitter greasemonkey omg.

I present my first greasemonkey script: twitter omg.

To be honest, I’ve never actually installed greasemonkey before. Writing the script was quite fun. I’ll be looking for opportunities to make a script that is actually useful…

I love code snippet challenges

I stumbled upon a blog with a random code snippet challenge. Here was the problem at hand:

Given a String (x) containing only characters a-z, write a function (f) that returns a base 10 integer, which converts the String as if it were a base 26 numeral. Function f is bijective.

I wanted to give it a stab in javascript not because it sounded particularly difficult but to play with different javascript code styles. Here’s my 4 versions:

function f(i) {

    if (!i) { return 0; }

    var parts, n, pow, val;
    parts = i.split('');

    val = 0;
    pow = 1;
    for (n = 0; n < parts.length; ++n) {
        val += pow * (parts[n].charCodeAt(0) - 96);
        pow = pow * 26;

    return val;

The first one turns the string into an array and reverses it before doing the math loop. My next try eliminates the array and iterates backwards over the string.

function f(i) {

    if (!i) { return 0; }

    var n, mult = 1, val = 0, offset = 96, base = 26;

    for (n = i.length - 1; n > -1; n--) {
        val += mult * (i.charCodeAt(n) - offset);
        mult = mult * base;

    return val;


Here I’m playing with chaining array functions. While I don’t create an array, this is very similar to the first try.

function f(i) {

    if (!i) { return 0; }

    var mult = 1, val = 0, offset = 96, base = 26;

    i.split('').reverse().forEach(function(el) {
        val += mult * (el.charCodeAt(0) - offset);
        mult = mult * base;

    return val;


Finally, recursion instead of an iterative loop.

function f(i, mult) {

    if (!i) { return 0; }
    if (!mult) { mult = 1; }

    var offset = 96, base = 26;
    return mult * (i.charCodeAt(i.length - 1) - offset)
             + f(i.substr(0, i.length - 1), mult * base);


Checkout the test output of my functions. Works in Firefox 1.5+ or other browsers that implement more modern javascript functions. Shouldn’t work in IE.

Written by Comments Off on I love code snippet challenges Posted in General Tagged with

Quick www. survey

I’ve been trying to pay attention to sites that either add a www or remove www from their domain. For example http://www.reddit.com/ turns into http://reddit.com/ or http://cnn.com/ turns into http://www.cnn.com/.

I’ve been defaulting any new domains I setup to remove the www. Remember, www. is deprecated.

Here’s a quick survey of some popular sites:

adobe.com adds www
amazon.com adds www
bbc.co.uk adds www
bloglines.com adds www
blogspot.com adds www
cnn.com adds www
engadget.com adds www
facebook.com adds www
forbes.com adds www
google.com adds www
last.fm adds www
microsoft.com adds www
mozilla.com adds www
msnbc.msn.com adds www
myspace.com adds www
politico.com adds www
salon.com adds www
techcrunch.com adds www
w3.org adds www
washingtonpost.com adds www
whitehouse.gov adds www
wired.com adds www
creativecommons.org removes www
digg.com removes www
gizmodo.com removes www
news.yahoo.com removes www
reddit.com removes www
slashdot.org removes www
tinyurl.com removes www
twitter.com removes www
wordpress.org removes www
blogger.com no change
boingboing.net no change
boston.com no change
delicious.com no change
flickr.com no change
geocities.com no change
gmail.com no change
imdb.com no change
nytimes.com no change
prweb.com no change
technorati.com no change
youtube.com no change

Written by Comments Off on Quick www. survey Posted in General Tagged with

IE 8 Beta

IE 8 Features

IE 8 beta is out. Looks like they’re making great strides to improve their support for standards. I love that you can install the beta with out the need to uninstall it when it breaks sites. I’m hoping they keep the Emulate IE7 button for the final release. Or somehow tuck it away in a menu so the option is still there. An amazing feature for web developers would be an additional Emulate IE6 feature. Testing sites in Internet Explorer would be a breeze if that was the case. I haven’t played with the developer tools much, but I like how much easier they’re making JS debugging for IE. Here’s a post from the IE Blog about the new developer tools

Written by Comments Off on IE 8 Beta Posted in General Tagged with

In and out all day

Like any mature individual my age, I find ‘that’s what she said’ references to be the funniest joke possible.

I recently helped my friend Devlin setup a new blog. I’m trying to get all my friends into blogging or having their own site. I feel it’s good to get the conversion out of the closed world of facebook/myspace.

She picked a rad domain name for her blog: http://waityouremrodonnellsdaughter.com/. Devlin told me a story a few weeks ago involving someone defacing creating a work of art on her whiteboard. ‘Not amused’ is what she said in response. Devlin just wrote a followup after she caught the culprit in another act of defacement.

Written by Comments Off on In and out all day Posted in General Tagged with

Green Collar Jobs

Tonight’s democratic debate has been my least favorite of them all. They’re actually getting into some details now, but the back and forth on health care in the beginning was awful. I do love how hard the moderators are having to work to get the candidates to switch topics.

You may be cool…but you’ll never be 4 popped-collars cool
Favorite random image of the last week.