Events, Family, Personal, Ruby, Software, Thoughts

The Biggest Little State in the Union

After weeks of unpacking, building out shelves, replacing lighting fixtures, unpacking some more, organizing, selling our possessions, getting creative with storing what possessions we didn’t sell, and living off restaurant food, life is finally getting back to normal for me, the wife, and all the critters. Moving day came and went as smoothly as I could hope. Thanks to the blunder of the Warren property, we were overly prepared and living out of boxes for a week prior to the move. In eight hours time we went from being citizens of Braintree, Massachusetts to Barrington, Rhode Island. I was just getting the hang of spelling ‘Massachusetts’ too.

The new property is close to the bay, in a scenic suburb with lots of folks walking, biking, and taking the dogs out. While our street ends at the water’s edge, we did sacrifice quite a bit of space in the move. We have been power sellers on Craigslist, getting some liquidity for things we didn’t have room for in the new place.

Also on Craigslist, I picked up a 2008 Lemond Reno in gently used condition for a great bargin at $225. With a quick tune up, and a bike helmet I decided to bike into work on Friday. I haven’t been on a bike probably since I was in middle school sporting the Huffy around the cul-de-sac. I couldn’t believe how much fun it was to ride! I always found it obnoxious when bike people would talk bikes, but its different once the bike bug hits. All I have wanted to do since Friday is have my body heal enough so I can get back on the bike and ride into work again. We strategically picked this location because of its proximity to the bike path, and this will become my commute to work, as well as a fantastic workout. Its quite a scenic view on my way in, as the bike path follows the bay through Barrington, and down into Warren. Perhaps I can convince the wife to pick up a bike herself and we can venture down to Newport once we get conditioned.

The new job is going very well. I read some materials on Job Characteristic Modeling, and I felt it did a great job at explaining why comparable work at my new employer has been drastically different for me than previous work. I struggled with task variety, identity, significance, and autonomy, which was a recipe for unsatisfaction. Government contracts are hard, and I have a new respect for the people that can do it. Mojo Tech is reminiscent of my time at Clayton State where I was given large problems to work through (some running for weeks at a time) and a full spectrum of disciplines needed to solve them. I guess the moral of the story is experiment with different company styles until you find one that pairs well with the way you work.

In other exciting news, I will be doing a presentation on the Rubymine IDE this Wednesday at the Rhode Island Ruby Users Group. Look forward to meeting the other Ruby developers here in the state of Rhode Island.

Pictures of the house are coming soon, as we prepare the last of the decorations. We are having a house party this Saturday, and any co-workers, past and present are invited. Come meet, mingle, and check out our new pad!

Computers, Ruby, Software, Thoughts

Are You a Lean Developer?

A tourist visiting England’s Eton College asked the gardener how he got the lawns so perfect. “That’s easy,” he replied, “You just brush off the dew every morning, mow them every other day, and roll them once a week.”

“Is that all?” asked the tourist.

“Absolutely,” replied the gardener. “Do that for 500 years and you’ll have a nice lawn, too.”

Dave Thomas offers this story as an example of the powerful effect of Kaizen in his book, The Pragmatic Programmer. As Dave describes it: “Kaizen is a Japanese term that captures the concept of continuously making many small improvements. It was considered to be one of the main reasons for the dramatic gains in productivity and quality in Japanese manufacturing and was widely copied throughout the world.”

Kaizen is one of the building blocks used in Toyota’s implementation of lean production operations. Lean operation is in competition with the traditional operational approach with the former boasting fewer resources, activities, people, and inventory while yielding greater productivity, lower costs, shorter cycle times, and higher quality. It sounds too good to be true! I decided to look at the other building blocks employed by Toyota’s lean operations, and how they could relate to programming:

  • Muda: Waste and inefficiency

This is the core concept of lean, and to achieve real results, you will have to get your hands dirty. Look outside the coding itself. Are you efficiently communicating the needs of the client? Are you using the best software available? Are you doing something inefficiently because you didn’t research the best way to tackle a problem? Are you overproducing?

  • Kanban: A manual system that signals the need for parts or materials

The agile development process takes care of a lot of these issues. In the days of the waterfall cycle project managers clung to the waterfall method as the Bible when implementing a system. Changing a specification mid-way through demonstrated that this approach was more about the developer than the client. Times change, and regimes change. It isn’t necessary to have all the information about everything to begin. Work from a small list, and continuously show the customer what you have to get their feedback. I wish our employer offered a more closed loop about the client feedback on what you had implemented.

  • Heijunka: Workload leveling

There is a penalty to varying your output production. I found it fascinating that the Japanese have integrated the concept of Takt Time into their work operation. Takt is the German word for musical meter. This is the cycle time needed in production to match the pace of production to the demand rate. Think of a real-time scheduling system. Is your environment’s “heartbeat” synchronized so that you are getting requirements as you need them? Is your quality assurance team reviewing code you just checked in? Are you getting instant feedback? A rhythm will generate more efficiency than switching contexts, and varying workloads.

  • Kaizen: Continuous improvement of the system

Tackle your TODOs and HACK HACK HACKS, and don’t be afraid to change code just because of the impact on other code. Specs change, and code tends to become increasingly entropic. Fix the problems instead of patching them. Backport your newfound knowledge into older code bases when there is a benefit to doing so. Don’t waste vast amounts of money on consultants!

  • Jidoka: Quality at the source

Quality is a tough issue in software. Some people rely on tests, others on peer review, and most on both. Strike a balance between coding your project and testing your product. Don’t test so much that it is wasteful and inefficient – aim for a 1:1 ration with coding and testing. After having worked with Cucumber, I can’t say that the time trade-off is worth the coverage provided. Stick with fast test suites (like Rspec) and manual confirmation by clicking around.

  • Poka-yoke: Safeguards built into a process to reduce errors

Working in a framework with a community centered on common conventions is probably the best way to tackle safeguarding yourself. The Rails MVC approach is a time tested software design, and usually when something is hard to do, its because you are going out it incorrectly. Another concept that comes to mind is code smell. Code smell isn’t specific to Ruby, but rather is a common convention among most programming languages.

I think that it would be an interesting experiment to convert a Rails shop into a lean operations center just to see what happens. As you can see above, many of the aims of Ruby on Rails, and the agile method pair quite nicely with the lean operational style. What are your thoughts?

Linux, Open-source, Ruby, Software

Rail’s Acts_as_revisable now summarizes changes

If you are a frequent reader, please congratulate me next time you see me on my first ever GiHub commit. I have been a long time user of GitHub, but I haven’t contributed anything back yet. I decided to start with the project acts_as_revisable, because I have some ideas for it that I think are useful.

The commit tonight adds a “revisable_changes” column, which records the attributes “before” and “after” values in the revision record. This data is calculated from the ActiveRecord instance method “changes”. To demonstrate:

# User.create :username => 'ben'
#[nil, "ben"]}>
# User.find(1).update_attributes :username => 'bob'
#["ben", "bob"]}>

This should serve as a good base to build summaries in a human readable format in an application. After tossing around a few different word choices to describe the changes, I decided that the better approach was to just record the data that changed in a structured format and leave it up to the implementation. Such an implementation may look something like this:

  def changes_summary do |attribute, values|
      before, after = values[0], values[1]
      if before.blank? and after
        "Added #{attribute} as #{after}"
      elsif before and after.blank?
        "Removed #{attribute} value of #{before}"
        "Changed #{attribute} from #{before} to #{after}"
    end.join('; ')

Using our user instance above, this method out return: “Changed username from ben to bob”.

Other plans for acts_as_revisable in the future include tracking associations of a model. For example, if a user has many permissions, and the permissions change, the revisable information will include the permissions for that user at that point in time. I haven’t worked out the specifics of this yet, as it could potentially generate a lot of unwanted data. I plan on parsing the data from ActiveRecord’s “reflect_on_all_associations” method to gather the associations. I will then provide a way for a user to configure which associations should, or should not be tracked. Then I will iterate through these objects using ActiveRecord hooks and somehow record the state. Either a shadow table, or by serializing the associations in a column. The trick here will be to marshal the objects back to the live data when a revert is called. More soon…

Open-source, Ruby, Software

Attack of the Clones

This is an elementary Rails tip, but one that I just recently stumbled into. When working in a project where you have a record that you want to make multiple instances of, you can do it the old fashioned way:

User.create(:first_name => 'Laurence;', :last_name => 'Tureaud', :alias => 'Mr. T')

However, this is quite a bit of typing. If you want multiple users, you can add a loop structure like this:

(1..5).each {User.create(:first_name => 'Laurence;', :last_name => 'Tureaud', :alias => 'Mr. T')}

This will create 5 Mr. T’s! Of course, if you have any validations checking for unique values, this might fail. I would recommend using the loop structure to prefix, or postfix a unique digit:

(1..5).each {|x| User.create(:first_name => 'Laurence;', :last_name => "Tureaud#{x}", :alias => 'Mr. T')}

Notice that the “x” will be a different value in each loop. Now for the grand finale, you can save all this typing and use a method on an ActiveRecord object called “clone”. From the official Rails docs:

Returns a clone of the record that hasn‘t been assigned an id yet and is treated as a new record. Note that this is a “shallow” clone: it copies the object‘s attributes only, not its associations. The extent of a “deep” clone is application-specific and is therefore left to the application to implement according to its need.

To use this, grab the record you want to clone first:

user = User.find(1)
# "Tureaud">

Note that this does not work on a collection of ActiveRecord objects – only an individual object. Now, call the clone method, and this removes the id attribute:

user = User.find(1)
# "Tureaud">
new_user = user.clone
# "Tureaud">

I have now cloned my object. With some method chaining, and some looping, we can easy mass create fake records:

user = User.find(1)
# "Tureaud">
(1..5).each {}

Much less typing! Now, with all that time you saved, go sign up for an Amazon Prime account and buy some cool stuff and get it shipped for free!

Computers, Open-source, Personal, Ruby, Software, Thoughts, Web

Taking the Magic Out of ActiveRecord – Speed up that Query!

Rails, and other programming frameworks that include an Object Relational Mapper (ORM) make is really easy to not worry about your database. That is until your application slows way down and you are left scratching your head trying to figure out why. Recently, I have been tasked with doing some things to optimize our database code in order to speed up the controller views.

The truth about databases is that you can’t beat them at their own game. Doing so would be like making a FPS on the consoles and releasing it the same day as Modern Warfare 2. A database stores data in a manner that can be easily and efficiently queried. ActiveRecord makes it easy to write code without worrying about the database underneath but this can create a issue. If you never know what the database is doing, how can you know if you are doing it efficiently, or not? I am of the firm belief (after witnessing Oracle chomp through 1000 line SQL queries like they weren’t there) that if a database can do something that your code can do as well, it is probably best to defer to the database. Pick the best tool for the job.

“If all you have is a hammer, everything looks like a nail” – Abraham Maslow

Lets look at some examples of where some database magic can improve our lives. Take the following code base:

# == Schema Information
# Table name: assignments
#  id         :integer         not null, primary key
#  post_id    :integer
#  keyword_id :integer
#  created_at :datetime
#  updated_at :datetime

class Assignment < ActiveRecord::Base
  belongs_to :topic
  belongs_to :keyword

# == Schema Information
# Table name: keywords
#  id         :integer         not null, primary key
#  name       :string(255)
#  created_at :datetime
#  updated_at :datetime

class Keyword < ActiveRecord::Base
  has_many :assignments

# == Schema Information
# Table name: posts
#  id         :integer         not null, primary key
#  title      :string(255)
#  created_at :datetime
#  updated_at :datetime

class Post < ActiveRecord::Base
  has_many :assignments

I have created a “Post” object to represent a blog post. On this blog post, I can assign keywords to each post. To do this, I have another model, “Keyword”, which is associated to posts through an “Assignment” model. The schema information shows the Database structure.

Now, recently I have come across some code that aimed to collect all the keywords of a post with some special options. These keywords were to be found, their names listed, and sorted without case-sensitivity. Finally, any duplicate keys would be excluded. A programmers mind might gravitate towards a solution such as:

Post.find(1) {|x| }.sort {|a,b| a.upcase  b.upcase}.uniq

Lets walk through this bit of code before I discuss better alternatives. To start with, we find our Post with an id of “1”, so that we can look at just those keywords. Next we iterate through these keywords (using the symbol to proc shorthand), and then run a sort on the returned array. This array is sorted by uppercasing the strings so that the sort is case-insensitive. Finally, “uniq” is run, to exclude any duplicate keywords. While this is a working solution, it doesn’t take any advantage of the power, and flexibility of what a database can do. A few issues:

  1. This code generates multiple SQL select statements. (N+1)
  2. Sorting can be done through “ORDER” in SQL
  3. Unique records can be generated through DISTINCT

The problem with generating multiple select statements is that this problem is an example of the “N+1” problem. This means that one query (“1”) will be run to determine what the attributes of the assignment is. After this is known, “N” queries are run for each keyword reference. In total, you have “N + 1” queries executed. If you have 5 keywords, the results will be unoptimized, but largely unnoticed. You will have 6 select statements:

  Assignment Load (6.3ms)   SELECT * FROM "assignments" WHERE ("assignments".post_id = 1) 
  Keyword Load (0.8ms)   SELECT * FROM "keywords" WHERE ("keywords"."id" = 1) 
  Keyword Load (0.7ms)   SELECT * FROM "keywords" WHERE ("keywords"."id" = 2) 
  Keyword Load (0.7ms)   SELECT * FROM "keywords" WHERE ("keywords"."id" = 3) 
  Keyword Load (0.7ms)   SELECT * FROM "keywords" WHERE ("keywords"."id" = 4) 
  Keyword Load (0.8ms)   SELECT * FROM "keywords" WHERE ("keywords"."id" = 5)

What happens if you have 500 keywords? 5,000,000 keywords? Your performance bottleneck will quickly shift to the database as multiple queries have to be generated, executed, and returned for each page request.

What is the big deal about sorting in your application instead of the database? In order for Rails (ActiveRecord specifically) to “sort” these items, the items will be be returned from a generated select statement from the database. These items will be returned as elements in an array, and then the array is sorted by calling the “” method on the Array class. Further, this is done in Ruby – a dynamic language, which is several orders of magnitude slower than in the database (which is most likely written in C). Simply, the database is made for this kind of work, and outsourcing it to Ruby is just not efficient.

Finally, why not make records unique with Ruby’s “uniq”? Again, it has to do with meddling in database territory. It has the problems inherent to the sorting problem above, but with an additional problem. Lets say that you return 500 records – and 499 of them are duplicates. Before the “uniq” method is run, Ruby is holding in memory references to the attributes of 500 ActiveRecord instances. When you call “uniq”, it can drop them. Why go through this memory spike and plummet, when the database can be instructed to just return one record? Memory is a valuable resource in a server environment – be frugal with its consumption.

So, lets address these issues, refactoring our code to take these issues into account. Starting with the multiple SQL statements, we can combine these into one statement by joining to multiple tables. I would encourage you to run “script/dbconsole” and get familiar with SQL. Let me demonstrate what we will be building the SQL way, before we implement this the “Rails” way.

FROM   keywords a, 
       assignments b 
WHERE = b.keyword_id 
       AND b.post_id = 1; 

Another variant of this is to join the tables together using a “join” syntax. An inner join is the same type of join that we have replicated in the WHERE clause here. We can right the same SQL as follows:

FROM   keywords a 
       INNER JOIN assignments b 
         ON = b.keyword_id 
WHERE  (( b.post_id = 1 )) 

We can specify this join using ActiveRecord’s “find_by_sql” if we wanted to specify the association by hand. However this case is trivial enough that ActiveRecord can build this for us using “has_many :through”. I can add the following to my models:

# == Schema Information
# Table name: keywords
#  id         :integer         not null, primary key
#  name       :string(255)
#  created_at :datetime
#  updated_at :datetime

class Keyword  :assignments

# == Schema Information
# Table name: posts
#  id         :integer         not null, primary key
#  title      :string(255)
#  created_at :datetime
#  updated_at :datetime

class Post  :assignments

Now, I can gather all the keywords for a post by executing the following:


Next, lets address the sorting issue by specifying an ORDER clause. We can tackle another related problem at the same time we do the sort. Recall that we want to sort in a case-insensitive fashion. If I just call order, then “Pabst” would beat “guinness” simply because of the capitalization (and we all know Guinness beer is better). The easy solution is to call “UPPER” to make the casing the same when the comparison is made. This actually saves even more computation on the Rails side by not having to do string conversions with our array sort. In SQL, we could append the following to our SELECT statement:

FROM   keywords a 
       INNER JOIN assignments b 
         ON = b.keyword_id 
WHERE  (( b.post_id = 1 )) 

The “Rails” way would be to include this on the association as follows: (Notice that Rails table alias names are probably not as reliable as listing out the name of the table itself. In this case, I have included “”

# app/models/post.rb
has_many :keywords, :through => :assignments, :order => 'UPPER('

Finally, lets address the unique problem. If I have duplicate keywords, I can return only the unique keywords by using the SQL DISTINCT modifier. In SQL, this would look like:

FROM   keywords a 
       INNER JOIN assignments b 
         ON = b.keyword_id 
WHERE  (( b.post_id = 1 )) 

In Rails, we can specify modifications to our SELECT clause, by passing the :select key to ActiveRecord’s “find”, and “all” methods. This has another benefit, depending on the application. For each column in each record, ActiveRecord has to store information in memory. By choosing only the specific columns that we want returned in the SQL clause, we can reduce the memory footprint. This could look something like this:

Post.find(1).keywords.all(:select => 'DISTINCT(')
# 0.16 seconds to complete w/ 200 keywords - thats 3 times faster!

So in summary, we have reduced SQL select statements, computationally expensive sorting and unique method calls from our results, and have managed to do all this without any fancy tricks. A sharp developer may point out that embedding SQL functions is bad form because it isn’t database agnostic. The truth is most databases conform to a base set of ANSI SQL standards and DISTINCT, and UPPER are acceptable almost across the board.

A little database magic can make a crawling Rails action become snappy again. I am a firm believer that Rails, like any framework should not be a reason to be uncaring about your SQL. Database are the heart of most applications, and usually one of the first bottlenecks for performance. Good SQL can be married with good Ruby code, and happiness will ensue. I hope this post was informative for Rails folks that want to get started with SQL optimization.

Apple, Computers, Hardware, Linux, Open-source, Personal, Ruby, Software, Windows

Living in an Apple World

Welcome readers to what is a first here on my blog – a review about Apple’s OS X. As some of you may know, part of my new job is working on a Mac for 8 hours a day, 5 days a week. Someone asked me about my experiences, and I feel up to sharing my findings. I want to be fair in my assessments, so if it sounds like I am starting to get a little slanted, keep me in check with a comment!

First things first – the initial impression. I have a 27″ iMac and I was initially impressed by the appearance of the machine. The iMac screens and case are one piece, so I have plenty of room to kick around beneath my desk with minimal cord entanglement (not that it matters because I sit cross-legged all day). The compact style keyboard has an aluminum casing, which matches the iMac. The mouse is the Mighty Mouse. Both are wired, which I appreciate – especially on the mouse. I hated the compact keyboard since it feels shrunken, and the addition of the “Fn” key in the bottom row meant every time I tried to press “Control” I missed. After swapping this out for a full-sized keyboard I was much happier, and even unlearned some bad habits. The Mighty mouse absolutely sucks. The tiny wheel stops responding all the time from the slightest spec of dirt, and you have to turn it over and rub it back and forth on your jeans, or the mouse pad. Its one saving feature is the ability to vertically, and horizontally scroll which is occasionally helpful. I am a right click fan, and though invisible, the region on the mouse that registers as a right click versus a left is about 10 times smaller. It feels like the edge of the mouse.

The keyboard on a Mac is different in important ways from its PC counterparts. The “Windows” key is replaced with the Command key, which is utilized far more than the Windows key ever was. In fact, most of the operations of the machine are done using Command (copy, paste, new tab, close window, etc) effectively making it closer to the “Control” key in Windows. However, the Control key remains, which actually introduces a whole new key combination to more effectively use shortcuts. The Command key is located next to the space bar, which is much more convenient than the extreme left placement of the Control key. I do copy, paste, etc operations using my thumb, and not my pinky finger – much less strain.

The computer screen can be tilted, which is nice since the whole world seems to be moving towards the annoying high gloss screens. I can tilt it down, and out of the florescent overhead lights. I really feel that gloss is a showroom gimmick just like turning the brightness up to max on the TVs in the store. If I wanted to look at myself, I would sit in front of a mirror. Fortunately, I have a second non-gloss monitor, and I do most of my coding on this screen. Also, it would be nice if the monitor had a height adjustment, as second monitor isn’t quite the height of the iMac screen.

Enough about appearance – lets talk hardware. This is a dual core Intel-based processor, with 2 GB of memory (later upgraded to 4GB). The video card is decent I suppose (however the interface can get quite “laggy” at times). I don’t have any idea what the machine costs, but this is definitely unimpressive hardware. 2GB of RAM is the minimum I would work with, and it being slow laptop RAM doesn’t help at all. At least there isn’t a laptop hard in it too.

As for the Operating System, it seems pretty stripped down. This isn’t necessarily a bad thing – I can quickly find what I am looking for, without going on a damn field trip through obscure dialog windows. The flip-side to this is it doesn’t feel very “customizable”. You use the stock features, or you don’t use a Mac. Perhaps there are a bunch of third party utilities that I don’t know about? Sometimes I am disappointed by the lack of customization options (there are just a handful of settings for the dock). To be honest, I am not sure what I would customize, but I like to poke around, and I often leave the System Preferences disappointed having not found “setting xyz“.

I really enjoy the file system indexing, and they have the best implementation for full-text search I have seen. It doesn’t bog down the computer, and the results are instantly updated. Magic. It effectively is the starting point for all my open actions. I don’t know why it isn’t available for the first 10 minutes after a boot, but I don’t shut down that much so its ok.

I was surprised by the lack of a default system-wide notification system – something that Growl has aimed to fill. I was also disappointed by the lack of package management on the Mac – again third party solutions exist. The system updates are just as annoying as in Windows which was a disappointment. Once the “restart” prompt stole my typing focus and proceeded to shut down the system. A few times the machine has “beach balled” (the Mac “hourglass” icon), and hard locked. Most of time its fairly responsive and stable which I can appreciate.

Other points of interest are the window management. I use Expose almost as regularly as I do the task switcher (Command + Tab), though admittely sometimes I get lost in the special effects and forget what I was doing. There are a bunch of other window groupings, but I don’t really find them that useful. One particularly frustrating observation is that once you minimize a window, you can’t Command + Tab back to it. Isn’t that the point of the task switcher? It even shows up in the task switcher, but when it is selected, absolutely nothing happens.

As for the software available on the Mac it is more comprehensive than Linux, and less comprehensive than Windows. Some of my co-workers commented that in OS X, there is usually one utility to do something, whether you like it or not. I use Google Chrome, JetBrain’s RubyMine, Ruby, Terminal, Lotus Notes, Adium, and Propane almost exclusively. Because of this, I can’t really assess the state of the Mac software ecosystem, but I will say that all these programs run damn well on the Mac. The only software crash I have is Flash. Flash on Linux and Windows is stable, however on the Mac probably one in ten uses causes the browser tab to lockup. I am not sure whether this is a Chrome issue or not, but something is seriously wrong with the state of Flash on my Mac. Now I understand why so many Mac users hate Flash – as a Windows user, I never experienced the constant crashing.

In summary, due to the nature of my work, I use the Mac at work in essentially the same manner I would use Linux. The terminal is where I spend my time, and I am more or less indifferent about the operating system around it, as long as I can install the system libraries I need for Ruby extensions, and it stays responsive. My next computer purchase will be a netbook and I will install Ubuntu on it, as I can’t justify spending the designer prices of Apple products to use a terminal and a web browser.  Toe to toe with Windows, and many Linux distributions, OS X excels in many areas. Its a fantastic operating system, but I am not sure that it is worth its cost. If I could throw it on my PC at home it would be worth $100. Buying a special machine just to run it is just silly.

Computers, Linux, Open-source, Ruby, Software, Thoughts, Web

Ubuntu 10.04 – Very Refined

A lot has changed with Linux since I have last visited Ubuntu. I had an old crufty version of Ubuntu 8.10 sitting on my hard drive that I hadn’t booted into in quite some time. Realizing that April was a release month for Ubuntu, I decided to go get the latest and greatest.

There was a time when the software that I used on Linux was very exclusive to Linux. It took a lot of hunting down of programs to find what the best ones were for what I was doing since the names were all unrecognizable. That no longer seems to be the case. Google Chrome, has an official Linux client that runs quite well. Bookmark syncing to your Google account provides an easy way to import your information. Dropbox has a Linux client that integrates in with the Nautilus file manager.

Rhythmbox integrates in with, Magnatune, and the new music store Ubuntu One. Empathy integrates in with Facebook chat, Google Talk, AIM, IRC, and many others. Gwibber integrates in with Facebook, Twitter, Flickr, Digg, and others. All of these integrate in with Ubuntu’s new Indicator Applet.

The new theme is nice, and the nVidia drivers are stable as always. The new theme does away with the Brown, and moves to a darker theme which I prefer. Compiz is running “discretely” providing effects that enhance with user experience without overwhelming it. The gravy on the cake is the new Ubuntu Software Center which takes all of the “apt-cache, and apt-get” out of the equation. The interface is revamped from the old “Synaptic package manager” and provides some nice touches such as “Featured Applications”, category views, and a seamless search, select and install experience.

If you are doing Rails development on Windows, do yourself a favor and revisit this classic to see how much improvement there has been to the Ubuntu experience.

Apple, Computers, Linux, Open-source, Personal, Ruby, Software, Thoughts, Web, Windows

Have You Had Your Daily Dose of Editors?

The Boss decided to purchase a license to RubyMine for me to use, and the rest of the office to evaluate. I wanted to share my experiences, since there doesn’t seem to be a lot of real-world experience on developing Ruby on Rails in a corporate setting using RubyMine. Also, some of my new (and past) coworkers might be curiously looking over their screens with TextMate to see what else is out there.

First, a bit about the Ruby on Rails culture. It is a very Mac OS X oriented, and the preferred editor of choice is TextMate. I really try and stay away from tools that only run on one operating system, and TextMate falls into that category. Ruby is a very terse, dynamic and simple language. Rails developers will tell you that you don’t need an IDE to do Rails work. While this is true, I find not using anything more than a text editor is like using a screwdriver instead of a power tool. If you are a good developer, and you understand Ruby a good editor will only make you more productive. RubyMine isn’t meant to be relied on like IDEs are for other strongly typed languages including C# and Java. It makes a best effort to provide its features without getting in your way when it fails.

RubyMine offers full support on Windows, Mac and Linux. RubyMine also strives very hard to make the Windows version as strong as the *nix versions. It does this by including an IRB console, and commands to run many rake tasks, and Rails generators. While these tools are a very good solution on Windows, people with the ability to run a native terminal will probably find the offerings lacking in comparison. This review will skip these Windows-audience features, since I don’t feel it represents the majority.


RubyMine does a very good job at trying to autocomplete its code. It will look inside Class definitions, and can find methods, attributes, and associations. If you are using gems that extend classes, such as ActiveRecord, RubyMine will do a fairly robust job at reading these methods from the gem files once they are attached to the project. “Attached” just means that RubyMine is inspecting these gems. It was not able to locate gems provided via Bundler, but this is supposed to be coming. Also, the auto-complete can be slow at times and freeze the editor from further input.

Inline Documentation

When you place the caret over a method, or class, RubyMine will fetch the documentation for that method and show it in the editor. This is doesn’t always locate the documentation however, in cases where the method is defined in a gem that is unattached.

Command+Click Following

You can click class names, and method names to jump straight to the definition. Also useful is clicking on associations, and named scopes. You can also jump to route definitions, and partials.

Cucumber Integration

There is auto-complete provided for your Cucumber tests, however also nice is the Command + mouse over action of displaying the definition of a scenario step. These can be Command + clicked to follow to where the step is defined. Also, if your step does not match a definition, you will be notified in the editor.

Safe Refactoring

Refactoring in this sense is renaming a variable, or a filename. The nice part about RubyMine is the ability to optionally search your project for usages of the current variable, or filename and update those references, or just notify you about them.


Not a big selling point, however many editors don’t offer strong spelling support. It checks your comments, and your variable names, but stays out of the way of your code.

Find By Filename / Class

You can pull up a dialog that will allow you to type a filename and it will return all matches regardless of directory level. Filenames can be regular expressions, and can include paths, and even line numbers. RubyMine will find them, and in the case of the line number, it will open the file and jump to that location. Searching by a class name is very similar.

Copy Buffer

Only having a clipboard with one item in it can be frustrating at times. Using the copy buffer feature, I can copy multiple sections of a file, then paste them individually later.

Code Formatting

RubyMine allows for manual formatting, or formatting on paste. You can also auto-format a complete document with a keystroke, based on your auto-format settings. It even works on HTML/ERB, HAML, Javascript, and CSS.

RubyMine isn’t a perfect tool however, and there are things about it that are less than ideal. Specifically, the footprint of RubyMine can be quite large. This seems to be a sin it shares with many of its Java IDE brothers. After watching it creep (unnecessarily) up to 400+ MB, I decided to do something about it. The solution turned out to be very simple.  On OS X, look for the file “Info.plist” in the /Applications/RubyMine directory. On Linux, change the file in the rubymine/bin/rubymine.vmoptions file. Change the value for Xmx to be 128m. This is the memory cap in which RubyMine will run. Runs like a charm now, and for days too.

Other annoyances include the default editor settings. Changing to soft tabs was more confusing than it should have been. Allowing “virtual space” after then of a line leads to a lot of accidental whitespace. The right gutter line isn’t helpful for Rails development. The font face was terrible. I had to customize the default theme to make it use the Apple default font. And finally, I don’t like the “Project” oriented state. I would rather open from within a directory in the terminal and work from there. I also don’t care for it generating a work folder within my Rails project – its just one more thing I have to pay attention to when using version control.

All in all, this is certainty one of the best editors I have seen yet for Ruby and Rails work, while I am sure I haven’t even scratched the surface of what this editor is capable of doing. It beats Netbeans 6.x, and RadRails. It will be interesting to see how Aptana Studio 3 turns out as the Aptana folks seem to really be putting some love into it. These editors felt like Ruby support was tacked onto what was intended to be a Java editor. The other end of the editor spectrum are hundreds of weak text-editors. I wanted something in-between. RubyMine has a clear focus, and all of its options center around Ruby and Rails work. So, if you are using TextMate as your first, and only Ruby on Rails editor, give yourself some perspective try out RubyMine’s free trial.

Apple, Computers, Events, Family, Open-source, Personal, Ruby, Software, Thoughts, Web

Darkness Warshed Over the Dude

We moved into our new office this week. It is really nice inside – very professional. I got to construct a cabinet from IKEA and I thought my head was going to explode. There were points in the instruction booklet where instead of describing something, there would be an arrow and the noise some action would make like “snap!”. I have never seen modular furniture that was so – modular. We are finally setup at the new place, and the overhead lighting is making everyone hate the stupid high-gloss iMac screens. Someone made the comment that it was “like being stabbed repeatedly in the eyes”, and another “could count the hairs on his face”. Now that we have more space, I will be getting a second monitor which I know will be much less frustrating. Along with our move is the mandatory male interior decorator that is stylishly unshaven, wearing a sweater under a brown corduroy jacket, and designer jeans. He was walking around the room talking about how “powerful” the color scheme felt. At least we got some new chairs out of it.

I finally got to the Registry of Motor Vehicles this week after dropping Kristin off at the airport to go back to Atlanta. Of course her being gone threw me out of my barely comfortable routine. The RMV made me surrender my Georgia license without giving me a Massachusetts license. Go figure. So with Kristin gone, the beer gone, and me without a license for the last week I think I went a little crazy. Now that Kristin is back, I asked her to do a beer run with my sad “help me” eyes. No license yet.

I figured I could go park the car at the train station this week, and ride in as usual. Kristin usually drops me off in front, so it shouldn’t have been that different. I got there around 9am the first day I tried it and the damn lot was full. I thought I was going to be clever and drive a block and park in another parking lot and walk back to the station. Apparently everyone tries that because the signs all said “T station parking illegal. Vehicle will be towed at owner’s expense”. The last thing I needed was a pending accident investigation, no license, and a towed car. I ended up just driving in the whole way which I have come to increasingly dislike. The rest of the week worked out better. I just got there earlier and the lot had spaces. The office is right across the street from the train station, so without the bus, it takes about 45 minutes to get to work from the house.

Work has been a mixed bag. Some days I really feel independent enough to feel like I am churning out good, usable code. Other days it is a lot of waiting, or some silly thing that I get hung up on for hours. We moved our project through my first “iteration”. Development on this project is done through “User stories”. A user story (either real, or fictitious) outlines what is a problem, and what needs to be changed to resolve it. A developer can read the user story, make the revisions to the code, and then write a “feature” that demonstrates that it is resolved. The cool thing about features is that it is all natural language thanks to Cucumber. For example,

  Scenario: Search by title
    Given that I am a common user
    And I have a topic with a "title" of "test topic"
    And I am on the Topic Search page
    And I search for "test"
    Then I should see "Results"
    And I should see the topic "test topic"

You can see that it is very easy to follow, and it allows our limited-technical people to read User Stories features without worrying about understanding Ruby tests.  Also, making a change, then seeing your entire test suite pass is a very reassuring feeling. Testing is so important here, that we actually write the feature first, and then change the code to make it pass.

It has been quite a bit to adjust to. I haven’t really had the opportunity to do Ruby development full time, and I am unfamiliar with Git, and OS X. I have already gone through the O’Reilly book on Git with my time on the train, and I am a few chapters into the Ruby 1.8 Pickaxe book. Textmate has been decent, and I could get used to it, however it definitely lacks some of the things Rubymine has. I do like the speed and lightness of Textmate. Case in point is when switching a branch in Git, it applies a bunch of deltas to files in your path, and Textmate just detects that files have changed and reloads them in your tabs. I anticipate that Rubymine would shit bricks and try to re-index your project. Rubymine has some impressive features for speeding up Cucumber development, and showing code coverage though, so I may use it yet again. My co-workers have all been very supportive of me using the tools that I am most comfortable with.

I am getting adjusted to life is adjusting here, but I miss everyone very much. My weekends are just a lot of downtime, with Kristin at work, and me trying to occupy my time. I’ll try and get out of my funk today with a car wash, and a haircut. Hope everyone is having fun down in the Atl!

Apple, Computers, Events, Hardware, Open-source, Personal, Ruby, Software, Thoughts, Web, Windows

3 Days Down, 40 Years to Go

Yesterday at 5:00pm marked the end of my first week at Beacon Interactive Systems. My coworkers are all really nice, and there is a surprising geographic mix between them. Some folks have lived in Massachusetts their whole lives, while others come from Maryland, and Michigan. The cultural differences between “down South” and here are pretty minimal, unless you just feel like having a good laugh. There have been two big adjustments however: Snow is really not a big deal up here – people hardly notice it outside. The second is restaurants don’t have sweet tea. You would have to drink sweet tea to understand why this is a big deal.

In general:

  • The job is much less stressful. Even during crunch times, you hear Southpark and Big Lebowski quotes (“I’m not your pal, guy!”).
  • The environment is a lot less structured. You come in whenever, you leave whenever. If you want to go outside and toss around the football, go for it. Good team-builder by the way.
  • The skill sets of my coworkers are all very impressive. Its the rifle vs shotgun approach.
  • The job area is nice – its next to Harvard. Getting there is rough – I have to cut across the city. My 20 minute commute takes about an hour.
  • Developing on a Mac is an easier transition than I thought. I won’t say that I’m in love with it yet, but its workable. The biggest pain has been this silly bundled keyboard and mouse. No one else uses them. Also, package management on Mac sucks compared to Linux. I think I would actually prefer to use Linux. Time will tell on this one.
  • The coffee isn’t as good.

An interesting collision of viewpoints occurred my second day at the job, while I was shadowing a coworker on a joint project. He was showing me their (complex) system of bug detection, and correction. They write up a use case, file a ticket, branch the code, create a changset, rebase it, merge it into QA, verify it, then push it back upstream. Not coming from anything near that complex (“Hey Ben – login to the production server and change it!”) I was amazed that they spent so much time on this process. I asked if they ever just ignore a bug that would be too minimal to matter. My coworker asked me to clarify what I meant. I replied with “You know, its good enough for government.” He paused and looked at me funny, then reiterated that they address all bugs that are discovered. A bug is a bug. It will take me a while to harden my resolve to be like theirs, and aim for perfection. Perfection wasn’t possible before because we had the typical scenario of overworked, underpaid, and on a deadline.

We are moving into our new building in a few weeks. When we move, there will be a train station across the street from the new building, and I will probably make the transition to riding into work. Its about the same amount of time, but I would have the ability to sleep, read, surf the Internet, etc all without causing an accident.

Wish me luck for next week – its been a difficult adjustment.