Posts RSS Comments RSS 132 Posts and 25 Comments till now

Archive for April, 2008

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:

  1. if ($_SERVER[‘HTTP_HOST’] == ‘example.mydesktop’) {
  2.     // LOCAL DEV SETTINGS
  3. } else if ($_SERVER[‘HTTP_HOST’] == ‘example.com’) {
  4.     // PRODUCTION SITE SETTINGS
  5. }

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.

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.

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…