Monday, June 22, 2009

Making Safari 4 go "BOOM!" -- javascript style

So I've been busy working on a project for work, and totally missed the fact that Safari 4 was released. That was until I got a bug report that my application crashed Safari 4. It wasn't that hard to work around the crash, but javascript should NEVER cause the browser to crash. Hang? Maybe, and maybe even make it slow as hell, but crash? Never. Well, maybe it could cause it to run out of memory and crash, but I mean just straight up, kick the browser in the shins and make it fall over, crash.

Sure, we all know programs have bugs, and web browsers are programs, so bugs are bound to be there. I guess I'm lucky (or unlucky) to be the one that finds one.

So basically, this bug stems from trying to select() a text input that was orginally inside a hidden div, that was later exposed. Below is a very simple html/css/js example that demonstrates the flaw. I've also included a link to the same example, just in case you want to see it for your self. It uses jquery, but it could probably just as easily have been written with vanilla javascript, but I don't have the time to try and convert it (read, I tried quickly, and it didn't cause the crash, so I left it using jquery).

Without further ado, the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="">
<title>Make safari go boom!</title>
.hidden { display: none; }
<script type="text/javascript" src="
<script type="text/javascript">
$(document).ready( function() {

$('#input').bind('focus', function() {

$('#boom').click( function() {

<div id="container" class="hidden" >
<input type="text" value="Some default text" id="input" />
<input type="submit" value="Go Boom" id="boom" />

And the example to make Safari 4 go boom!

UPDATE: This appears to be fixed now in safari 5.

Tuesday, February 24, 2009

Aftermath: good thing than he needs

While I'm not one for memes either, reading this post from Dossy convinced me to at least see what mine would be. Also, its kind of like a mad lib, and I enjoyed mad libs as a kid.

  1. Go to a random page on Wikipedia:
    The first random Wikipedia article you get is the name of your band.

  2. Go to “Random quotations”:
    The last four or five words of the very last quote of the page is the title of your album.

  3. Go to Flickr and explore the last seven days:
    Third picture, no matter what it is, will be your album cover.

  4. Use Photoshop or similar to put it all together.

  5. Post it and invite your friends to join in.
Mine became:

The random wikipedia page was
The random quotation was this one by Mark Twain,
The flickr image was this one from veryscary,

My only complaint, is that the images are not creative commons, so making the derivative work probably violates the photo owners copyright. Although this probably constitutes fair use, it might not. IANAL, and will be happy to remove this if the owner requests it.

Monday, February 2, 2009

AIM Conversation Map

Quite some time ago, I wrote a simple mashup that used the Google Maps API and the Open AIM API to show real time AIM conversations around the world. Its a bit crude, but somewhat functional, but I never took the time to throw it out there. Here it is, for anyone who is interested.

Before you get too excited, it doesn't show what is being talked about, only conversations happening between two map endpoints (ie, city to city).


Update: 2/3/09 - Redid the above in flash, since the older javascript version was a bit buggy, and would hang firefox.

Saturday, January 17, 2009

Who knew 802.11b would be better than 802.11g

For the last few days, I've been struggling with wifi issues. Pages would load slow and sometimes never complete. Command-R has become my new best friend in Firefox, as sometimes forcing a reload will fix the issue, but only for the moment.

Being somewhat tech savvy, I decided to investigate.

To begin my investigation, I installed Wireshark, and started a packet capture session on my wireless interface on my Mac Book Pro. I then refreshed one of my web pages, and noticed several tcp retransmissions. This basically means a packet was lost, and had to be resent. This results in more data being sent along with taking longer due to the time waited until the loss is detected.

Since my wired boxes didn't show the same behavior, I was pretty sure that wifi was the culprit, and that there was some new interference causing the issue. My first step was to download AirRadar (an access point scanner for the Mac -- you can use things like NetStumbler for the PC) and see what access points are around me (which there were many, anywhere from 5 to 10), but most are very weak signals. Of the strongest signals, most were on channels 6 and 11, so I opted to switch my router to use channel 1 (since 1, 6 and 11 are the only non overlapping channels for 802.11b/g).

Even after changing the channel, I was still having issues. We do have cordless phones in the house so I thought they might be interfering. I tried a test where I was far from the access point while the cordless phone was in use, and monitored the signal strength in AirRadar, but the signal strength and noise levels didn't change more then they normally would. I tried the same test with my microwave oven running, but no change occurred from it either.

At this point, I thought I was out of luck. I then noticed this article on Slashdot, and noticed the submitter commented:
I found out by accident that setting my access point to '802.11b only' mode appeared to give me a vastly more reliable connection that leaving it in 'mixed 802.11b/g.' Is this a fluke? Or does transmitting at 10 Mbps when everyone else is using 54 Mbps (for their 3 Mbps DSL pipes!) give you a true advantage?"
Since it was one of the only things I hadn't tried yet (other then wrapping my house in aluminum foil, which might get me banned from my neighborhood), I promptly tried it.

I re-ran Wireshark, fired up Firefox and loaded a web page. Viola, no tcp retransmissions detected. While I'd love to keep the faster connection, I mainly browse the web and do a few other low bandwidth (relatively) applications over wifi, so having a stable connection is more important then having it fast, at least for now. Worse case, I can easily toggle back to 'g' mode when I need the speed, and stick to 'b' when I don't.

If you're finding yourself having similar issues, and can do without the speed of 802.11g, see if switching to 802.11b only mode in your router will do the trick. It might not work in all cases, but it worked for me.

Wednesday, September 10, 2008

AOL Radio for Mac 2.0 beta - good, annoying song change popups - bad.

I've been using AOL Radio for Mac 1.2.1 for a while, and was somewhat disappointed when I found out it was being discontinued. I decided to take the plunge and get the AOL Radio for Mac 2.0 beta version, even though it was a beta. It didn't pick up my presets from 1.2.1, but since I only had two saved, it wasn't that hard to redo them. The sound was just as good (as streaming music goes), but there was one very annoying feature that bugged me.

At every song change, it showed a little 'popup' of the new song and title. It was cool at first, but soon got very annoying. A quick check and I found out there was no preferences for the app. Zero, zilch, nada. There has to be some way to turn this off.

Dropping to a command shell, I ran 'default domains', and saw ''.

Running 'default read' dumped my presets and a bunch of other info, but nothing that indicated what would change this annoying popup behavior.

Looking in '/Applications/AOL' turned up a plist file that contained:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "
<plist version="1.0">

I changed both the <true/> values to false (although I probably only needed to change the 'show_nowplaying_overlay' one), and then restarted the app. Vioila, no more annoying song change popups.

Wednesday, August 27, 2008

So that is what nameservers are for

So after by BBS snafu, I called up the local ISP the BBS was using to get my own account. The nice sales woman that I spoke to told me they had two different account plans. The first one was what she called a "term" account, which included 50 hours per month for $25. The also had a "slip" account, which was $30 per month.

Not knowing the difference, I asked about them. She explained that the term account was command line based, where you would get access to a text based menu and shell access. The slip account was graphical, and required Windows. Being the geek that I was, and not knowing why I would need a "graphical" internet, and also because the term account was $5 cheaper, I opted for the term account.

After setting up my account, she gave me the information I needed to login over the phone. It was pretty simple really. I had a local access number that I would dialup with my favorite terminal software. Once connected, I would be presented with a username and password prompt, and once that was confirmed, I would be presented with a "Command:" prompt. At this, I would type "term", and it happily landed me with a connection to "larry", which was their shell host. Later I learned they also had machines named "moe" and "curly" (I smell a theme here).

So there I was with a nice text menu that would launch unix programs for me, like 'elm' and 'pine' and 'rn' and 'tin'. All the email and newsgroups I had before, were right there. I also had access to things like 'gopher' and this new thing called the world wide web, through some program called 'lynx'. It was amazing, and even more so, there was 'ftp'. After my experience with the ftp email gateways, I just had to jump in and try it out. So I launched it, and it asked me for a hostname. I told it, "". A few lines of output, and I was staring at an "ftp>" prompt.

Could it happen this quickly? I thought not, so I tried "cd pub" followed by "ls", just like in my very first email from before. Almost instantly, a directory listing scrolled down my screen. Not 24 hours later, but now. Wow! This was exactly what I wanted. With this, I could grab files, and using zmodem, download them directly as binary. No more uuencoding/decoding. I was in heaven.

I played around for a bit, and noticed a menu item called "Exit to shell". I'd pretty much tried all the other commands, so I figured I'd give this a whirl. It dropped me to what looked liked a dos prompt. It also printed a few lines about some common commands to use, and how to get back into the menu if you get stuck or lost. They also had aliased many of the dos commands to their unix equivalents, so DOS geeks like me would feel right at home until we got our unix feet wet.

While experimenting, I learned about a wonderful unix command called "man". The "man" command would give you a "manual" for any command you needed help with, and being the newbie that I was, I needed help with everything. I was reading the man page for every command I knew, and learning about even new commands. Day after day, I would login and spend my time reading more and more man pages. My first month's 50 hours were almost entirely spent reading man pages. I was slowly becoming a unix expert, or so I thought.

Every once in a while, I'd learn something in a man page about the filesystem layout. I learned about /etc, and unix configuration, and would explore the filesystem learning where things lived. I found out that this same box also hosted an ftp site that contained the software used by the "slip" customers.

One day, when I logged in, I was staring at the "Command:" prompt, and about to type "term" when I thought to myself, "I wonder what the slip users type here, or if maybe they use something else?" I thought, just for grins, "What if I type 'slip' here instead of term?" I figured, worse case, I would get something like 'invalid command', and would be asked to try again. I was amazed when instead, I was greeted with something like:

Your IP address is x.x.x.x.
Gateway IP adress is y.y.y.y.

Hmm, could it be this easy? I disconnected, and reconnect as a term user. Using nslookup, I found out the ip address for larry. I used zmodem to download the slip software package, and installed it under windows. When I dialed back in using it, I was connected. They had a "term" program called "telnet", and using the ip address of larry, I was able to get to my shell. Even better, I could open multiple "telnet" windows at the same time.

Then I discovered they had this thing called 'cello' a world wide web browser. I fired it up, and went to a site (can't recall the name, so ill just use as an example), but was somewhat disappointed when all I got back was some error saying it "couldn't resolve the hostname". Figuring something wasn't configure correctly, I looked at the slip software settings, and found there were some empty fields called "nameservers" and also found there was a file called "hosts". I seem to remember reading about them in the man pages, but wasn't exactly sure what they were. And of course, since I was a "term" customer, I couldn't really call tech support asking for "slip" help, now could I?

Determined to get this working, I did an 'nslookup' in my term window on larry, and it came back with an ip address. I cut-n-pasted the host/ip combination into my local hosts file. I did a reload in cello, and viola. A page started loading. This was amazing. There was text and IMAGES. I was awestruck, I would click on the links and browse around the site, and eventually, it would take me to some other host name I didn't have. I would then repeat my process of nslookup, cut-n-paste, and reload and continue browsing.

This was my normal process for a few weeks, until I realized the magic of nameservers. Instead of the host file, I could put  the ip address of the ISP nameservers in and all the lookups happened for me, and was near instantaneous. Personally, I was more then happy to have to do the trick I was doing, but was ecstatic about having it happen automatically. Starting to feel bad about taking advantage of using "slip" as a term user, I emailed their support and told them about it. They said they would look into, and on my next bill, I noticed I was made a "slip" customer at the "term" price, so I couldn't be happier.

Tuesday, August 26, 2008

Latency issues

A few weeks ago, I was talking to a friend about how I got started with computers and it reminded me of a few interesting stories I thought I'd share.

They both take place sometime in 1994, although I can't recall exactly when. The first of the two I'm posting below, and the second one I'll follow up later (soon), but it's a bit too late tonight.

I had an account on a local BBS that provided internet email and Usenet newsgroups via UUCP from a local ISP. Keep in mind, back then I didn't really know what UUCP or an ISP was, but I did vaguely know what email was since we could send "mail" to other members of the BBS, and even to a loose group of other BBS's ( I think it was FidoNet).

I dove head first into reading the newsgroups, and found a wealth of information and discussions that just wasn't possible on a local BBS. Back then, I was really into the demo scene, and dabbled in programming in C and Intel 80x86 assembler, trying to eek out what I could from a slow VGA card. One day, while browsing the newsgroups, I found out some demo was released, and I wanted to "get" it, but alas, it wasn't on the "files" section of the BBS. No worries, one of the newsgroups mentioned I could download it via ftp from something called "sunsite". I had no clue what ftp was, but I knew the only "internet" i had was newsgroups and email, and hoping to find it on alt.binaries wasn't an option, since the BBS didn't carry them.

To my rescue, I had learned about something called "ftp email" gateways. Since I did have access to email, I thought I'd give it a try. I read up on ftp, and learned the magical mysteries of the 'open', 'cd', and 'ls' commands. I created a new email to be sent to the gateway. In the body, I put

cd pub

and hit send. And then I waited, dialing back in couple hours to see if I had a reply. When it finally came (some 24 hours later or there abouts), I had a nice directory listing of, yet again, more directories. A new email was crafted, this time with

cd pub/somesubdir

and it was sent off, taking yet again, another 24 hours or so to get a response. Later I found out that the UUCP link only happened twice a day, and by the time my outbound mail made it across the link, and into the ftp email gateway server, the response would have to wait for the next UUCP session before I would see it, making it a guaranteed 12 hour latency, but since I didn't know when the window was, it was pretty much always the next day for me.

Now lets fast forward a few more days, and a couple more subdirectory traversals, and I finally get to the file I want to download. So I type the magical

cd pub/somesubdir/anotherdir/andanother/demos/

and hit send. The next day, I anxiously awaited for my email. When I logged in, sure enough, there it was. I was all too excited, but the tears of joy after almost a week to back and forth emails quickly became tears of sadness. The file was sent UUEncoded, and I was without a UUDecoder. Had I not been so distraught over all the time I had spent, I probably could have written one myself, but for the time, I simply saved the file, hoping that soon I would figure out how to decode it.

Later that same day, my phone rang. To my surprise, it was the sysop from the BBS. Somehow, my huge download (it was about 1M  back then, after being uuencoded) caused his UUCP usage for that day to skyrocket. Normally, he would only have a few 100K (I seem to recall it being less than 1M), so my one little email caused his traffic to double. Of course, this alarmed him, and after he poked around, it was pretty easy to figure out I was the cause. In any case, he was really nice about it, and we chatted a bit about the internet, and he explained to me about UUCP and who his ISP was, and how I might really want a real account. So later that day, I called up the ISP, and got my first internet account. But that will be another story.