thoughts from brian samson

Word count in your Browser

My wife is taking an online class that has a requirement that she make some number of forum posts on their blackboard. This is not uncommon for online classes to encourage participation. The ridiculous part is that she is required, at the end of her post, she needs to include the number of words she wrote so that the instructor knows the post is long enough. So she ends up launching Word and writing her post over there so she can use the word counter over there to make sure she gets all her words. So I thought I’d be nice and write a little bookmarklet that does this for her:

Word Count

Drag this link up to your bookmarks bar and click on it and it will tell you the number of words you’ve typed into all of the text areas on the page. It reports the count back using the internal name of the field, but that will usually be enough to figure out which field you’re typing in. It also counts the number of words you have selected in the web page, just because its easy to do. I hope this helps somebody else out there meet arbitrary post length guidelines.

Internationalization is Hard

Either that or programmers are lazy. I’ve been working on an App at work that requires internationaliztion, and until you get used to doing it, its very easy to let strings just leak through. I just installed Google Chrome, and right there on the first prefs page is a whole slew of I18n bugs: Chrome-es

They missed a translation and another couple don’t fit in the space and just run off the page into oblivion. These bugs are annoying to fix, but at least they are easy to find: Just change the locale on your computer while you develop. Only one person on the team really needs to do this.

I have my computer’s language set to spanish, so I notice these problems right away while testing, which is certainly something you should do for at least a round of QA before you ship, but preferably while you develop. You can make it fun if you write a pirate locale or something, but you should absolutely be running your app in a language other than english before you can even come close to calling it finished.

Yahoo learns nothing, enforces “security questions”

I play fantasy football on yahoo. For the last few weeks they’ve been hassling me to enter “security questions” so I could reset my password if I forgot it. I already have an alternate e-mail address registered with them in case I forget the same password I’ve been using for 5 years, so I’ve been clicking “Later.” Until today, when I went to adjust my team and saw this:

Yahoo security questions

This is infuriating to me, especially considering how badly yahoo got burned in the media after that UTenn student “hacked” Sarah Palin’s e-mail address. I really wish that people would stop doing this, or at least make it not mandatory. Even Time Magazine had an article about how stupid these questions are.

So please, internet, I’m begging you to stop doing this.

Don’t send “Unsubscribe Confirmations”

I recently got some spam from American Airlines, and like usual I went down and clicked the unsubscribe link. A few minutes later I get this:

from American Airlines <AmericanAirlines@na.info.aa.com>
to my@email.address
date Thu, Jul 23, 2009 at 9:26 AM
subject Unsubscribe Confirmation
mailed-by na.info.aa.com

This message is to confirm our receipt of your request to receive no further messages from American Airlines.

Thank you.

Message-Id: <hrc2l0f5nsz6vx4cn6v76Splnv@na.info.aa.com>

This is exactly the opposite of what I wanted to happen. Whoever came up with the idea to send an email to confirm that you will receive no more emails should die of ghonnorea and rot in hell.

Sharing internal Javascript libraries between Rails projects using SVN and Rake

I’ve been developing rails apps for over a year with Six Fried Rice, and we’ve been using ExtJS as our Javascript framework. As is quite common in industry, we’ve developed internal libraries for Ruby, Rails, vanilla Javascript, and ExtJS. When I used to write Java, we would have our shared libraries in separate source control projects, package them up as JARs and just distribute binaries, which we would check in to each project that used them. This worked fairly well because of 2 important reasons:

  1. Our libraries were mature
  2. They could be developed independently of a certain project

Number 1 is nice because the libraries don’t need to be updated often, so you usually only needed to spend time getting them set up at the start of a new project. Number 2 was true because our libraries usually revolved around authentication/single sign on and they were maintained by an entirely different group in IT. This is more typical of large enterprise development.

So when I wanted to do something similar for our rails/js libraries, I initially turned to gems and plugins. Either of these solutions would work fine for our modifications to Ruby, and we do currently maintain 2 internal rails plugins that handle our ruby convenience methods and also some changes we’ve made to rails (that haven’t made it into core rails yet….). We keep those plugins in separate subversion projects, and everything work great.

Now enter Javascript. We write lots of javascript. Many times as much as we write ruby. The Javascript also tends to be dirtier than ruby, and we run into a lot of problems that are much harder to reproduce so I usually prefer to test changes to the libraries in the context of the applications that use them. This JS code is also very immature and changes frequently, often daily. The traditional method of developing a library on the side and updating it occasionally breaks down for this case, so the situation for the JS libraries is the opposite of the traditional way I described above:

  1. Immature code that changes frequently
  2. Development depends on applications that use the library

It turns out that there is a nice property that is supported by subversion called externals. This allows you to set a directory in one repository to link right to another repository. You can make changes to the library right there, commit it back, and then go run update on a different project and it will go grab the changes. This is perfect, except for one thing. Say I branch off of trunk to write a big new feature that ends up adding a lot of code to the Javascript UI library. This branch may take a few weeks to finish and the whole time I’m committing new code to the javascript, which gets propagated to trunk everytime I update, which could certainly introduce bugs that we might not want in other branches.

This leads me (finally) to the point of this post. I solved this by writing a rake task to “freeze” and “unfreeze” the library. When it is frozen, the library just stays at a version we know to be stable. When you want the latest code, or if you need to make changes, you unfreeze it and test. We’ve been using this solution for a few weeks now and its works really well, so I decided to post the rakefile that handles installation and freezing of a javascript library, called ‘jslib’ by default.

external_js_library.rake

Now I can do cool stuff like

rake jslib:freeze

which makes sure that the library stays at whatever version it is at right now forever, or until I issue:

rake jslib:unfreeze

which sets it back to HEAD and updates. I don’t think this is a replacement for gems/rails plugins, but it does a very good job of handling our shared javascript library. Thoughts?

Capistrano: Calling tasks from other tasks

I wrote a new capistrano task for deploying a rails app the other day that would totally reset the old deployed database and give me a fresh new one with fixtures pre-loaded. This is useful for deploying different branches to the same location on a server. However the lack of proper capistrano documentation let to some wasted time figuring out how to invoke previously defined tasks from a new task. Most of them are just simple methods you can call, but to call the task deploy:migrations is a little more complex because it’s really a task called migrations in the deploy namespace.

So for my new “super deploy” task, deploy.rb looks something like this:

task :drop_db
  run "cd #{deploy_to}; rake db:drop"
end

task :create_db
  run "cd #{deploy_to}; rake db:drop"
end

task :super_deploy
  drop_db
  namespace :deploy
      migrations
  end
  create_db
end

Pretty simple but I got hung up it for a few minutes. So there you go.

16 Million Terabytes

Just so you know I don’t play favorite and just post screenshot of windows being stupid, here’s one I ran into on my Macbook Pro this afternoon. That’s a lot of virtual memory right there.

16 Million Terabytes

Then why is there a cancel button???

THEN WHY IS THERE A CANCEL BUTTON??!?!

Thanks for being so specific.

I’m trying out the windows 7 beta. After all these years of usability testing, you’d think Microsoft would have learned not to write horrible “confirmation messages” like this. In fact I would argue they shouldn’t put a confirmation message at all. Maybe just show me the file. Maybe ding. Certainly not this.

The files have been exported in the format you selected

Also on the first screen of the export contacts wizard, the default button is cancel. So I typed a file name and hit enter and the whole thing closes.

I just want to play video games

So I wanted to play Fallout 3, which my friend Jeff told me is totally bad ass. Unfortunately it is, like pretty much every other PC game out there, only for windows. I could have monkeyed around with WINE for a while, but since I had a copy of the Windows 7 beta sitting around already and Jeff gave me a spare hard drive, I figured what the hell. So here goes:

At 7:45 I reconfigure the BIOS so that windows thinks my newly installed HD is the only one. It somehow discovers the other drives, but at least it thinks it’s drive is #0, so I think I’ll be ok. After picking my language, it starts installing. It sits at the first step, “Copying files” for about 4 seconds and then moves on to “Expanding files” where it sits at 0% for 5 minutes and then slowly creeps up to 100 over the next 35 minutes. It reminds me that my computer will “restart several times” during the install. No problem.

After the files are done expanding, it says it reboots, but I don’t see a POST or hear a beep, i just get a black screen. The hard drive is furiously spinning, so I wait it out another 15 minutes, during which time num lock flashes on and off sporadiacally. Now it’s like 8:45 and I’m starting a black screen, so I kill the power and reboot. The “Safe Mode” menu briefly (and I mean briefly) shows up and then it picks safe mode. Windows boots up, it says it’s continuing installation, and then a dialog pops up that says it can’t continue installation in safe mode. Restart. Windows comes up, eventually tells me that the install did not complete successfully and it needs to reboot and start over. Restart. It comes up and tells me the same thing, so now I realize it want’s me to reboot off the dvd again. Restart.

Now it’s almost 9:00. I restart the installer, this time I find the advanced menus and format the hard drive it’s installing to. 2 seconds of “copying files”, only 10 minutes of expanding, and then another reboot. This time windows comes up and continues the install. I’ve only lost 90 minutes of time, maybe I can still play fallout tonight :)

9:12 - While windows is “completing install” it decides it wants to up the resolution from what looks like 800×600 to the full 1920×1600. It ups it alright, but only the top left quarter of the screen has anything and the rest is black except for a “Windows 7 Build 7000″ in the bottom right corner. It sits like that for another minute or so and reboots again.

9:15 - Setup is preparing my computer for its first use! After entering my product key, it guesses that the time is 4:17 AM, which is strange because its really 9:17pm. I tell it that it’s a home computer and it sets up a “Homegroup” with the easy to remember password of “pw6IU3gV1u,” and no way to change it.

9:21 - Windows spends 4 minutes “preparing my desktop.” What took so long you ask? 2 icons (one of which is the recycle bin) and a fish background. Also a message about how it needs to install 4 updates. Not too bad I guess, only 23 megs. And I can start the fallout install now.

9:28 - It finished downloading updates about 5 minutes ago and wanted to reboot. I clicked “later” and started installing fallout. Then all of a sudden right in the middle of the install windows says “Logging out” then “Installing updates” then “Shutting down” and reboots. This is garbage.

9:31 - Back up, IE opens up and tell me without a hint of irony that my “last browsing session closed unexpectedly.” Yeah. Thanks for the heads up.

9:45 - Fallout is installed. Sweet. 2 hours isn’t that bad, I guess. If thats the price to pay to play the one good video game that comes out every few years, I can deal with it.

« Previous Entries