Archive for May, 2008

FireFox bug with onreadystatechange

Saturday, May 24th, 2008

Just ran into this bug in FireFox: https://bugzilla.mozilla.org/show_bug.cgi?id=412112. Basically, if you do a synchronous call on an XMLHttpRequest object, the onreadystatechange function is not called. So the following code doesn’t work.

var request = new XMLHttpRequest();
request.onreadystatechange = function () {
if (request.readyState == 4)
  if (request.status == 200) alert('request successful')
};
request.open("GET", "/index.html", false); /* the false here makes it synchronous *
request.send(null);

Instead you must assume that the synchronous send has completed and instead check the status and process the response immediately. <edit> This means you do not need to define an onReadyStateChange function at all </edit> So:

var request = new XMLHttpRequest();
request.open("GET", "/index.html", false); /* the false here makes it synchronous */
request.send(null);
if (request.status == 200) { /* the request has been returned */
  alert("request successful")
}

This can actually be easier to code, but to me it was unexpected. I would expect that the
onreadystatechange be called when the response comes back either way. And if the synchronisity of the call is variable, it could get more interesting.

Recording The Daily Show on Tivo

Tuesday, May 13th, 2008

I just upgraded my Tivo to a Tivo HD (very cool) and lost the old tip on how to avoid recording 5 copies of The Daily Show every day. Apparently Comedy Central doesn’t provide enough metadata for the Tivo to figure out when an episode is new and when it is a rerun. This little trick was in a Tivo Newsletter:

WishList(r) Search Suggestion: De-dupe Your Now Playing List

Even more remarkable than the truth behind “My TiVo gets me” is the inspiring fact that many of you truly get the real genius of TiVo, and why a cable DVR couldn’t even begin to compare.

If you like The Daily Show with Jon Stewart, you know what happens when the show takes a week or two hiatus: Your DVR records lots of repeats because they stop listing the guests for each night. Why? When the networks don’t provide unique guide data, TiVo can’t determine if the show is new or a repeat, so it records them all to play it safe. Waste space and/or manual recordings no more! Martin T., from the Web’s most beloved TiVo community forum, exercised the new-and-improved TiVo WishList(r) feature to get us our daily Jon Stewart, without the three extra servings. Here’s how:

1. Go to Find Programs, and create a new WishList(r) search.
2. Enter the show title as your first Keyword: Daily Show with Jon Stewart.
3. Select “Done entering Keyword.”
4. Next, select Keyword again, this time entering the generic program description (the following is the generic descriptor for Daily Show): A humorous slant on top news stories.
5. Now give it a Thumbs down. (By default, your first Keyword gets a Thumbs up.)
6. Set the WishList to “Auto-record” with “First-run only.”
7. Delete the old Season Pass recording for Daily Show.

So what just happened? You’ve instructed your TiVo DVR to record all new episodes and ignore episodes with generic guide data. No more reruns. No more multiple recordings. And if two of your tuners are busy at airtime, TiVo will choose to record a later show. Ahhhh…

“In addition to working very well for The Daily Show and The Colbert Report,” explains Martin. “I use the above method for an ongoing ‘Amazing Race’ WishList search that will automatically record each new season, but ignore generic reruns, as well as ‘Saturday Night Live’ and ‘Conan O’Brien’ WishList searches that ignore generic, late-night reruns.”