Archive for September, 2008

Quick and Dirty Browser Cookie Testing

Posted on September 30th, 2008 in Programming, Ruby On Rails, Web Development | Comments

On a recent Rails project, I was asked to verify if the visiting user’s browser has cookies enabled, and display a message on top of the screen if they don’t. While I don’t want to get into the reasoning why, or get into a flame war whether the site should still be accessible regardless if the user’s browser has cookies, I still needed to implement it.

Since it’s a Rails project, I thought of checking if the session cookie that Rails sets in the Application controller was set. But Rails sets the session after the view is rendered the first time (I have a more detailed explanation somewhere but don’t have it with me, so maybe next time). This means the first time the user visits the site, it will incorrectly display the warning message. Subsequent views will test correctly, but this obviously won’t work.

So I decided to implement a redirect, thanks to ideas given by this blog post. It worked, but it left me with a parameter in my URL the first time the user visited the site. It didn’t seem clean, and the higher-ups didn’t like it either, so off it went.

Then I was given the idea to check it via JavaScript, and with some slight tinkering I think I got what I wanted:


Basically this uses JavaScript to set the cookie when the page is rendering and immediately checks for its availability using a regular expression. If it’s found, then the user has cookies enabled and we can safely delete the test cookie (provided the user has their system clock set after January 1, 2001). If the cookie isn’t set, that means the user doesn’t have cookies enabled in their browser, so we display the ‘cookies_disabled’ element with our message inside.

This function is called in our application layout, between the <head> tags, meaning it’s called for every single page that renders the default layout. I haven’t observed any type of performance issue this might have, but I might have missed something along the way. And there’s probably a better, more efficient way to handle this as well, so if you have any suggestions, feel free to dtop a comment and let me know.

That’s Why There Are Choices, People

Posted on September 18th, 2008 in Opinion, Programming | Comments

I was having a quick tech discussion the other day on a non-tech message board I visit on a daily basis. I had mentioned how frustrating it is to have to spend hours developing for good ol’ obsolete Internet Explorer 6.0, and why people are so damn lazy to upgrade. There are countless reasons why people don’t upgrade, which I won’t go into now to avoid a long, long rant on why I think these people should be stripped from their computing privileges. But I was talking about the recent developments in web browsers, in particular how Firefox 3.1 is going to be much faster, or how Internet Explorer 8.0 is promising to play better with web standards, I received this delightful comment from one of the few techies (and one of the few females) in that forum:

He can shove Firefox 3 where the sun doesn’t shine, and if he suggests Internet Explorer 8 in person I will be forced to cram his balls up over his head whilst they are still attached to him.

Just lovely. And I hadn’t even suggested that people upgrade!

The particular reasons she gave me as to why she made this statement are irrelevant to the discussion (“Firefox 3 doesn’t support all my add-ons yet and Internet Explorer lost me a long, long time ago.”), but something slightly ticked me off about this brash statement.

Every single person on this planet has an opinion to express, for whatever reason. People involved in computers aren’t excluded. I’d say we absolutely love expressing our opinions about a myriad of things, leading to sometimes heated (and entertaining) discussions: Windows vs. Linux vs. Mac, Ruby vs. Python, vi vs. emacs… No matter what you say, there will always be someone to express the opposite.

I learned a long time ago to avoid these discussions altogether. Why? It’s not because I’m a poor debater and fear I’m going to lose (which is most likely true). It’s because no one in this world will ever be pleased. That’s why there are choices in this world. To put it as simple as possible, someone wasn’t content with something, so they made another thing. And they’re happy with it.

So if I’m happy with Ruby and Rails, and you’re extremely happy with Python and Django, then I respect your opinion, sir. Just don’t come down on me and run down a zillion reasons why Ruby or Rails suck (which are probably variants of “Rails Can’t Scale“). Be happy with what you have, I’ll be happy with what I have, and we can co-exist nicely in this vast software development universe.

Amazon Ships Really Fast – For Those Who Know

Posted on September 17th, 2008 in Books, Opinion | Comments

Yesterday afternoon, I had the urge to get a new Rails book, so I went to Amazon and ordered The Art Of Rails. This post isn’t about the book, but I’ll try to write about it after I read it.

This post instead is about the weird shipping service that Amazon provides on its site, at least in my particular case. When ordering something in Amazon, you get the option of how fast you want to get it. Among their options are: Standard Shipping (which is 3 days according to the site), 2-Day Shipping and Next-Day Shipping. I usually choose the standard shipping, since whatever I order isn’t a matter of life or death. I completed my order, expecting the book to arrive on Friday or Saturday, just in time for the weekend.

I just checked the tracking on the book – It’s already waiting for me at home, less than 24 hours after ordering it.

Of course, that’s not happening every single place in the country. It seems the reason I got it so quick is that Amazon has a distributor close to New York City (the tracking indicates it left Bethlehem, Pennsylvania, which is about 90 minutes away), so they received the order and shipped it out UPS Ground, which is just a short drive here. It isn’t the first time this has happened. I usually get books from Amazon one or two business days after I order them.

Obviously, I don’t mind the fast service. That’s why I continue to constantly buy from them rather than any of the other million bookstores I have access to. But take a look at the costs for the different shipping options for the same book:

  • Standard Shipping – $3.99
  • 2-Day Shipping – $11.98
  • Next-Day Shipping – $17.98

So, I spent 14 dollars less than someone who chose Next-Day Shipping, yet got the book as quickly as they did. Pretty sweet deal, but I wonder how many people from this area (and perhaps other areas where shipping is just as quick) keep on choosing those ‘faster’ options unknowingly.

Like I said, this doesn’t apply to every single place in the country, so that’s why there are different options. Also, for someone who really needs an item the next day, selecting the Next-Day Shipping option can serve as a guarantee. But with the millions and millions of orders and a whole lot of stats to go along with those orders, couldn’t Amazon have estimated dates depending on where the items are shipping? This way, the consumer is better informed and can make a better decision. It just seems like the right thing to do.

Oh, and if someone from Amazon is reading this, please don’t purposely slow down my shipments next time.

Envy Casts – The New Hotness?

Posted on September 16th, 2008 in Opinion, Programming, Ruby On Rails | Comments

Last night I was in the mood to just review some of the stuff I already work with on a daily basis. I’ve been reading up on a lot of new stuff that I’m dying to play with, so a quick review of familiar concepts would be a welcome change of pace. Plus, it always seems I’m learning new stuff whenever I go back to an old concept. So I was searching around to see what I could get. I’ve already exhausted most of my Ruby and Rails books, gotten most of what interests me on PeepCode, and seen virtually every single episode of Railscasts, so I wanted to see something different.

That’s when I remembered that the guys from Rails Envy started producing their own screencasts, originally dubbed Envy Casts. As you can see with what I wrote above, and what I’ve written previously, I absolutely love screencasts. And since I’m an avid listener of the Rails Envy Podcast, I thought I would give these guys a try.

So after viewing the screencast on my way to work today, I have to say that Gregg Pollack and Jason Seifer have a good thing in their hands. Their screencasts are totally different from everyone else’s, which is immediately apparent. Instead of just a voiceover of how something is done, they actually have the guys (mostly Gregg) in front of a green screen. While it would virtually be the same if they went the regular screencast route, this adds some sort of personal touch.

Of course, the guys inject their humor as usual (with Jason usually appearing on screen for comedic purposes and nothing else). It even has quick educational breaks, with Gregg posing as a doctor to give us lessons on how our brains work. It has absolutely nothing to do with Ruby, Rails, Active Record, or anything related to software development, but as I mentioned, it provides quick breaks between topics.

So far, they only have one screencast covering Active Record. But I’m definitely looking forward to subsequent screencasts, as long as they’re as good as this first one. Perhaps we have the new hotness of the screencast world in our grasp.

Dropbox – Never leave your files behind again

Posted on September 12th, 2008 in Mac, Services, Software | Comments

I’m pretty damn excited by the long-awaited public launch of Dropbox, an online file storage service. Well, it’s more than that. It’s a service that allows you to store, share and synchronize your files, either on the web, or as a ‘dropbox’ folder on your computer. They offer a nice chunk of space – 2 Gigabytes, which to me is more than enough for the things I would usually store in these services.

It might sound like just another online file storage site, but it really is not. It’s ridiculously easy to use. Once you install their client software and create an account with them, your computer will have a special folder, where you can just drop files in and they will automatically be synced on your account. No need to do any manual syncing or waiting for a timed sync to occur. It’ll happen totally transparent from your regular workflow. Provided you have a fast Internet connection, the synchronization process is virtually instantaneous. Then you can either grab the files from a web interface, or by installing and configuring the client in another computer. It’s that damn easy. Take a look at the tour they have on their site.

I must admit, I was a bit skeptical about this service after I read about it in TechCrunch earlier this year. I thought it wouldn’t be anything special compared to any other site that provides similar services. However, after reading more and more about it, the curiosity got the best of me. I scrounged for an invite and eventually got one. I signed up, but to be honest I never used it much. I only have access to Mac and Linux computers at the moment, and Dropbox was Windows and Mac only, so I was rather limited as to where I could use it.

However, the excitement arrived yesterday, when not only I read that Dropbox launched publicly, but they also released a Linux version of their client software! I immediately downloaded the client at work (laptop using Ubuntu 8.04), created my account. and it worked just as it did on the Mac. I started transferring files and got them when I arrived home. Everything went without a hitch. I’m now finding more and more uses for Dropbox, particularly work-related files that I can access at home.

Kudos to the entire Dropbox team for putting out some quality work.

Fluid and Prism – Site Specific Browsers Are Awesome

Posted on September 11th, 2008 in Linux, Mac, Software | Comments

At my recommendation, my company started using Campfire by the awesome guys at 37signals. In case you don’t know what Campfire is yet, it’s a site where groups of people can chat, upload files, share code and many other collaborative activities. I recommended Campfire because I think this is just what our company needed during this time where we have testers who are in other cities. It’s my first time using Campfire in a business environment, and hopefully it all works out well.

One of the things that initially worried me about Campfire is that being a web-based app, it would be difficult to know when there was any activity on the site. The good thing is that Campfire has an audio alert, a pleasant beep, that alerts me whenever someone wrote something in the chat rooms I’m at, along with changing the title of the page so that I can spot it in my open tabs. However, I’m guessing that I’m not the only web developer who has a myriad of tabs open at any given moment. Site testing, analytics, API specs, build/test results Google – All of them usually occupy a space in my browser. Adding Campfire would mean that it would get lost in a sea of tabulated titles.

After seeing this could be a problem, I immediately thought of Fluid, which I had used previously. Fluid is a browser of sorts. However, instead of being just another browser, Fluid allows you to create an app that’s site-specific, so your web-based apps will act like an independent desktop application, separate from whatever you have in your browser. It’s perfect for those sites which you constantly have open, such as web-based E-Mail like Gmail, social networking sites like Facebook, and, as in my new-found case, chats like Campfire. It will also alert you whenever there’s a change in the site you’re visiting, right on the application icon in the dock. So, as an example, if you’re using Gmail, you’ll see new mail notifications in the dock, instead of needing to open the app window. It’s pretty neat and convenient.

I was happy that I found a solution. One ceveat, though: Fluid is a Mac-only app, and I use Linux at work (at least until the bosses buy souped-up Macbook Pros for their developers… I can dream, can’t I?). So I was bummed out again. Then I remembered that Mozilla was developing an app with a similar concept, called Prism. The functionality is virtually the same: You set up a site to be run as a desktop app, making it totally independent from your regular browser.

Seeing that Prism is in the Mozilla Labs, I didn’t expect much of it. However, it works great on my Linux laptop under Ubuntu 8.04. I was able to create a Campfire app and add it to the desktop with ease. It never crashed on me or gave me any problems during the entire afternoon I was using it. Granted, there wasn’t much activity going on in the chat rooms at the time, but everything worked as if I were working on Firefox.

The main difference between Prism and Fluid is the fact that Mozilla is making Prism available not only for Mac, but for Windows and Linux as well. Of course, Fluid is written with Mac in mind, and it has all sort of goodies for the Mac (like the aforementioned updates in the icon, Growl notifications, its own JavaScript API and more), so you’re much better off with Fluid if you’re on the Mac. For the rest, then Prism seems like a mighty fine solution in the meantime.

With more and more web-based apps taking up the majority of our time in front of a computer, I think these applications will be more widely used in the near future. You can already see some sites adopting it, even including icons for your usage of the desktop, like GitHub and 37signals. There’s even a Flickr group adding more and more site icons every day. If you haven’t checked out either of these apps, you should check them out now.