Archive for March, 2008

The Window Object in IE is Actually an Array of Frames

I happened to come across this javascript quirk in a very obscure way today. I was maintaining some code that when presented with a string such as this.foo.bar, would evaluate it, if a complex variable such as that exists in the supplied context, or just return the string if it does not. It does this lookup by evaluating each piece with an array lookup. In this example, the first step would be to perform, window['this'].

This code works pretty well in Safari and Firefox, but in IE6, I got this strange error that just didn’t make any sense. For some reason, the symbol lookup code was changing the string ’5′ to the window object. What I really couldn’t understand was why removing the Appcelerator Calendar widget fixed the problem.

The supplied context to my variable lookup guy was window. Of course, window[5] doesn’t mean anything. But Wait! IE6 returns something that looks an awful lot like the window object. On a whim, I tried, window[1000] which returned undefined, which is what I was expecting in the first place. Then I looked a little harder at the DOM that resulted from the widget and noticed <iframe> tags. I had 5 of these widgets, which would explain why windows 0-5 weren’t undefined. If the value I was trying to test this code on wasn’t 2, I would have never seen this.

In the end, my fix was, if the value to lookup looks like a number, assume the person wants a number. As is normally the cause with debugging, 5 hours of work results in a 3 line change.

  • Share/Bookmark

Olives

Last week I ended up having to fend for myself during dinner. Being male, and have a strong dislike of cleaning up by myself, I opted to head to Publix for a sub. For those of you that don’t live year a Publix, your’e probably going to think it’s rather strange that someone would go to a grocery store specifically to get a sandwich. Those that do, know that Publix beats any other chain sandwich store by a mile.

This particular trip provides the perfect anecdote explaining why. This particular episode stands out because the sandwich lady put on a small handful of olives on the sub. Then she realized it was a small handful and, without prompting, put another small handful of olives on the sub, leaving me with a sub with lots of olives. This is good. I love olives.

Contrast that to the last time I entered a Subway. Instead of the usual, mostly friendly, high school kids, it was an older lady making the subs. If I had to guess, she’s probably the proprietor of this franchise. Not only that, she was being a little stingy with the ingredients. Like counting the number of leaves of lettuce stingy and the guys in front of me weren’t having any of it.

C: “Can I have more lettuce?” “I need more tomatoes.” “Can you put a little more onions?”
All the while the owner is getting a little more upset. Every extra vegetable cuts her margins, you see. Then came the kicker:
“You need to put more olives” (there were about 6 little slices on this footlong sub)

OL: “I’m going to have to charge you extra for that.”
C: “What?! It’s a vegetable, it’s not like I’m asking for more meat.”
OL: “It’s the most expensive item on the sub.”

I fully understand that she, as a franchise, is a little ticked off by how crappy her investment in a Subway turned out to be. But to take it out on a customer is just absurd. After all, the margin on those olives is going to completely vanish if you don’t sell enough sandwiches to put them on. Sorry Jared, but I’m going to stick with the place that actually makes a sub that I want to eat. There are a lot of businesses that would trade the cost of a second handful of olives for a satisfied, and recurring customer.

  • Share/Bookmark

Ruby SVN Bindings on OSX

Most of the information about this is outdated and not very useful. Collaboa’s site suggests that you need to build the bindings from source. If you attempt this and use Macports for dependencies, you’ll get un-resolvable errors regarding time.h.

Installing subversion-rubybindings from Macports itself doesn’t work either. This approached failed since it was unable to find the dependency db44.

Thankfully, there is a solution if you want to do this. First install Ruby and whatever from Macports. Then grab the OSX one-click installer. Once that’s installed, you need to make Ruby aware of the bindings. Do this by copying the bindings files into your Ruby:

$ sudo cp -r /opt/subversion/lib/svn-ruby/universal-darwin8.0/svn /opt/local/lib/ruby/site_ruby/1.8/i686-darwin9.1.0
$ sudo cp -r /opt/subversion/lib/svn-ruby/svn /opt/local/lib/ruby/site_ruby/1.8

Do not use symbolic links. I tried this at first and it didn’t work.

You can then test to make sure it works with:

irb
>> require 'svn/core'
=> true
>>
  • Share/Bookmark

NIN Ghosts. The verdict: moody.

Last night I blogged about why I bought the Nine Inch Nail’s new album Ghosts. Which means it’s time for my first album review. I finished listening to it and the word that was at the top of my mind when it finished was “moody.” This makes a lot of sense, Trent Renzor states that one of his goals was to create a soundtrack for day-dreams. However, it appears that his day dreams aren’t as happy as mine. Ghosts

I really like stuff like this. Moody, abstract, and varying between depressing, rage, and hard driving. It appropriately fits the condition of the modern computer programmer. The slower tracks reminded me of Mogwai’s sound track to Zidane, un portrait du 21e siècle. The faster tracks are classic, dissonant, and industrial NIN. It’s a good mix.

As an added bonus, when you purchase the songs, you also get a 40 page pdf booklet of the scenes that inspired the music, as well as some desktop wallpapers and web graphics derived from images in the booklet. The packaging of the set does a great job of translating the value-add of a traditional CD to the web distribution model.

My final verdict is moody and good, but probably a little short of great. It’s fantastic as coding music since it doesn’t get in the way. I’m probably going to listen to it again today.

  • Share/Bookmark

I actually bought a CD.

I used to buy a decent amount of music. But then the RIAA cracked down on internet radio, Clear Channel bought up all the radio stations, and I stopped being exposed to new music. In the past few years, any time I heard anything new, I already had the full cd, which means I had no reason to go buy anything. Plus, cd’s started to cost around $15. Barely worth it for an hour of entertainment, definitely not if there’s only a few good songs.

However, Nine Inch Nails released their new album and made the first quarter available for free. They even put it up on bit-torrent. I listened to the first set, decided I liked it. Normally it would go no further than that. But this time I decided to buy it. The clincher was the text they attached to the bittorrent upload:

Ghosts I is the first part of the 36 track collection Ghosts I-IV. Undoubtedly you’ll be able to find the complete collection on the same torrent network you found this file, but if you’re interested in the release, we encourage you to check it out at ghosts.nin.com, where the complete Ghosts I-IV is available directly from us in a variety of DRM-free digital formats, including FLAC lossless, for only $5. You can also order it on CD, or as a deluxe package with multitrack audio files, high definition audio on Blu-ray disc, and a large hard-bound book.

We genuinely appreciate your support, and hope you enjoy the new music. Thanks for listening.

I like the fact that they aren’t labeling their fans criminals and threaten to sue them. I like that they respect that their fans want to listen to their music. That’s all the encouragement they need for me to send money their way.

  • Share/Bookmark
Return top

About

This is my blog about programming. For random stuff, checkout my Twitter or Tumblr