Friday, September 30, 2005

Geeky Friday: Little known vim "feature"

Earlier this week, a co-worker asked for my help diagnosing a problem on one of our sites. Some pages just weren't working in Internet Explorer, but were working fine in Mozilla Firefox.

Odder still, the HTTP status code returned was 199. Normal returns from a web server have status 200, errors are 500, redirects are in the 300 range, 404 is for missing pages. I've never heard of 199. I searched Google and a couple forums for the various software tools that could be involved and found nothing.

So, I went to the source code. Using "find . -mtime -2 -print" to identify all files which had changed in the past two days, I focused on a file I had been testing with the night before.

The extent of my test was adding something along the lines of:

if (some condition) {
    print some debug information to the log file
}
I considered this to be safe testing code. It didn't modify any variables, make any database calls, or call other procedures (other than the command to write to the log file). I got the debug information I needed and then edited the file again back to the was it was before. Or so I thought.

It's worth mentioning at this point that I was using vim instead of emacs, my usual text editor.

When I looked at the source code today, I looked at the line immediately following where I had inserted and removed the debug code. It was a line to return (programatically) a web page to the user's browser. One of the arguments to the command is the status code. Instead of the usual "200" I saw "199".

I was bewildered. Clearly this was my fault because the mistake was right where I had been editing this file, but there was no reason for me to have changed this return code. How did this happen?

I fixed the code right away, but I had to know what went wrong. My first guess was that vim had some keystroke shortcut to decrement a number -- it seemed reasonable since the new value was exactly one less than the correct value. So, I googled for "vim decrement" and I was right.

I laughed heartily, especially because the key combination for this is Control-x (C-x) which is used as the beginning for many emacs commands. Most notable, "C-x C-s" is used to save the current file. Clearly what had happened was that my well-trained fingers knew it was time to save the file after I had removed the debugging code and hit "C-x C-s". Unfortunately, the cursor was placed on the number "200" when I did this and vim did what it was programmed to do when fed C-x. My brain kicked in and saved the file in a vim-approved way but I didn't notice the error.

As for the discrepancy between Firefox and Internet Explorer, I wouldn't say that IE did the Wrong Thing, it just did things differently. Firefox looked at the content of the information returned, which looked like valid HTML data, ignored this odd status code and displayed the page. IE, on the other hand, decided that if the status code wasn't 200, it would display an error page. Ok, maybe that is Wrong, it's certainly less elegant and less helpful.

Lessons learned (or rehashed):

  1. There's no such thing as safe testing code on production servers.
  2. Always test changes in more than one browser.
  3. Be extra careful when using an alternate editor or simply stick to one editor

Technorati tags:

Tuesday, September 20, 2005

Geeky Friday: Complaints about gaim (and sourceforge)

I've been using gaim as my primary instant messenger program for around five years now. With one program running, I can connect to AIM, MSN, icq, Y!, IRC, and more -- and yes, I have used all of these, although I use Yahoo chat mostly for notifications of new Yahoo mail. Additionally, it logs all conversations so that I can use my desktop search tool (currently X1) to find that code example sent by a co-worker or the phone number I need to call to order something. It doesn't handle voice or video chatting, but that's ok. I use those rarely enough that I'll just launch Skype or Google Talk when I need something like that.

Gaim works well most of the time, but once every 2-3 months, one of the major IM services will tweak something and non-official clients (such as gaim) will not work. If such a tweak is persistent, the gaim team will usually push out a fix within a few days.

Just some thoughts. My complaints all revolve around communication about what's going on. I'm ranting today because I've not been able to log in to AIM for the past couple days -- with an exception late last night. Maybe AIM changed something, maybe the server I connect to is overloaded (and gaim doesn't know how to switch), maybe it's something else. I'd like to know more.

The gaim team could post something on the blog-style front page of their site. But, perhaps I'm in a small minority of gaim users who are experiencing this problem. It would be nice to communicate with other members of this small minority to discuss. There's a gaim forum on the sourceforge project page but it's slow and the user interface is severely dated. I could file a bug report, but similarly, the user interface is lousy and I have a difficult time getting a sourceforge login cookie to stick around from the time I log in to the time I get to the page to file a ticket. (I would try to tell sourceforge about this problem, but that would involve filing a bug report using the same system).

It would be relatively easy for the gaim team to address these sort of problems with freely available services. There are many options for improved forum software any one of which would be easy for the gaim team to install. But forumer offers "100% free hosting" for IPB and phpBB -- I'm not familiar with IPB, but I know that phpBB would be a significant improvement over the sourceforge forum.

For bug tracking, I've been pleased with Atlassian's JIRA. Atlassian has a nice progressive view towards open source projects -- providing their software at no cost and, in some cases, hosting or maintaining the software for the project.

Technorati tags:

Thursday, September 08, 2005

Hilarious Domain Name Mispronouncings

Maybe it's just because I've been working too hard for the past few weeks, but this blog post had me laughing out loud.