My Review Of Developer-Day in Durham

23 03 2009

This Saturday, I attended Developer-Day in Durham, NC. Overall, the conference was outstanding. Priced at $50, it was definitely worth the 4-hour trip from Washington DC. Below you will find a quick review of each of the talks.

Refactoring Your Wetware by Andy Hunt

Andy Hunt of the Pragmatic Programmers gave us a brief overview of his latest book: Pragmatic Thinking And Learing. He described the way our brains are wired and offered advice to take advantage of what we know about our brain’s architecture.

Andy started by explaining the concepts of Systems Thinking, as described in The Fifth Discipline. Systems Thinking is when you get out of the habit of thinking of things as discrete objects, but as systems instead. Once you start looking at objects as belonging in a system, you began to see how they are interconnected. Having graduated from the UVA Engineering School where Systems Engineering is the most popular department and working with Ahson Wardak, a Systems Engineering PHD candidate, I’ve had some exposure to the discipline and concept.

Andy followed by describing neuroplasticity, the fact that your brain can grow new neurons if you exercise it. He then moved to a discussion on The Dreyfus Model of skills acquisition. In summary, the best way to become an expert is through deliberate practice: 10 years of practice! Imitate the experts, then assimilate, then innovate.

Andy explained that the brain has two sides: the left and right brain, which he would rather call the Linear Mode and Rich Mode, respectively. Think of the Linear Mode as the mode that is prevalent with geeks and the rich mode as the one that is non-verbal, non-rational, synthetic, non-linear, asynchronous like a search engine, analogical, spatial, intuitive, holistic… The Rich Mode of your brain sometimes has trouble putting into words what it is processing but this is where the innovation/ideas comes from. A lot of inventors report that they discovered things in their dreams. Therefore, Andy suggested to try out Free-Form Journaling: wake up every morning and write down 3 pages of stuff (by hand, no typing) before you do anything else. Don’t censor yourself. Write about anything.

Then, Andy explained how our memory is not very good or, I quote, ‘is a piece of shit’ so it is important to write down things. When you think of a new idea, write it down. If you don’t keep track of your ideas, then you stop having great ideas. Once you have an idea, the best way to explore it is with a mind map (on paper, no computers). Once you are done with the mind map, putting that information in a personal wiki can be helpful.

Finally, he challenged the audience to try meditation and warned us against multi-tasking. The benefits of meditation far outlasts the actual practice itself. Multi-tasking is really bad for your brain so avoid context switching.

I enjoyed Andy’s talk and I will definitely pick up his book in the near future.

Evolving Your Git Workflow by Jason Rudolph

In this talk, Jason Rudolph showed us a few special git commands and how we can take advantage of them to improve our workflow.

He started showing us the power of git bisect by walking us through a debug session using the command. He used git bisect to find out when a bug was introduced in his codebase using the following commands:

git bisect start head %%commitid%%
git bisect log
git bisect good
git bisect bad

He then showed how you can automate the whole process with:

git bisect run %%command%%

I thought that was one of the coolest things I’ve ever seen!

After having used git to do some ‘Biology’, he proceeded to show how git can help us with ‘Archaeology’. The latter is the ability to be able to clearly tell what happened in the past by looking at the history of a code base (through a version control system log). It is important for your projects to have a clear, well-defined archaeology, so that new programmers can look back and figure out why things were done in a certain way. Jason shows us how git makes that easier. For example, with git, you can amend commit messages or your can commit changes from one file in two different commits. Pretty slick!

In the third section of his talk, Jason showed that branching in git is easy, cheap (41 bytes), fast, and have low ceremony. Therefore, there is no excuse not to branch and we should Branch All The F***** Time (BATFT).

Optimizing Perceived Performance by David Eisinger

In this talk, David showed us how improving the perceived performance of a web page can greatly improve the user experience. David used a sample application called DBDB (DoucheBag DataBase) to illustrate his idea which got the crowd laughing a lot.

David showed us a few client side techniques that we can use to make our application appear like it is loading faster. He advocates the use of Unobstrusive Javascript with jQuery (with jRails).

Lightning Talks

After lunch, we had the lightning talks. Here is a set of links from the talks:

Getting Girls With Musical Magic and Ruby by Jess Martin and Chad Humphries

Jess and Chad showed us how they are using Ruby to make mashups. Check out Girl Talk for a good demonstration of this style of music.

Jess wrote some ruby code that wraps Sox to create mashups. He built a really slick frontend for it (CHOP40) which lets you select some tracks and automatically mashes them up for you. I’ve been a big fan of the style (especially diplo‘s stuff) so it was cool to see the techniques behind this art form.

From Paralysis to Static Analysis by Aaron Breda

At every conference I go, I always have a moment where I kinda zone out (thinking about cool stuff I could do with the stuff I just learned about). It usually lasts only for one/two talks before I get my focus back. Unfortunately for Aaron, it happened during his talk this time:-/ ( I’m curious to know if it happens to every one so let me know in the comments. )

From what I picked up though, Aaron and Chad should be awarded some kind of heroes award for the work they are putting into upgrading rcov to Ruby 1.9. Thank you guys!

Scala: A Modern Programming Language by Clinton Nixon

Clinton gave us a great introduction to the Scala programming language. Scala was created in 2001 by Martin Odersky. It runs on the JVM, compiles beforehand or JIT. It is a functional language where everything is an object (like in Ruby) and it supports actor-based concurrency (so it is future-proof with the trend to have more cores on CPUs).

Pros: interoperability, scalability, beauty (of course that is subjective)

Cons: JVM (if you do not like that, though I think this is a pro rather than a con), hard to navigate libraries if you do not know Java, small user base, no killer frameworks/libraries.

Clinton posted his slides at and they are the kinda of slides that you can read and learn from without seeing the presentation so go check them out.

I really enjoyed this talk since I’ve been meaning to learn more about Scala and this served as a great introduction.

Page Caching Resurrected: A Fairy Tale by Ben Scofield

Ben’s talk was great. He showed us a creative use of Rails Metal with page caching. The idea can be summarized as follow:

  • Cache your page with only the content that will be seen by all users.
  • Have your page make a javascript call to get user specific content in the background.
  • To make that javascript call be fast, use Rails metal in the back end to return the needed data fast.

I’ve been using this technique at ShareMeme and messagepub with the exception of the use of Rails Metal. For example, at messagepub, most pages are cached and we fetch the menu bar and navigation links with JavaScript after they are displayed. Therefore it turns out our Rails action with the most hit is the action that fetches the menu bar (since everything else ends up being served by the web server) therefore it would make sense to use Metal for that action to reduce the delay before the user sees the menu.


I can’t decide which was my favorite moment of the conference: whether it was seeing git bisect in action, learning about Scala, listening to a mashup that was created with Ruby, or seeing a cool use of Rails Metal.

This was a great conference with really good talks both in content and delivery. Thanks to Viget, Relevance, and Ben Scofield for putting it together. I look forward to the next one in Washington DC.

If you want to get other opinions on the talks from Developer Day, see how the rest of the audience rated the speakers at

Autotest Notifications in Ubuntu with Mumbles

7 10 2008

Autotest is a nice utility that automatically run your rails tests whenever you make a change to one of your source files. It is part of the ZenTest package from Ryan Davis.

It would be nice if you could be notified of the test results without having to switch to the terminal window running AutoTest. Some Mac users already found a way to do this using Growl. However, that only works if you have a Mac, and I don’t have one, so I figured out a way to do something similar in Ubuntu. Let’s get going.

Step 1: Install Mumbles

Mumbles is a ‘plugin-driven, modern notification system for Gnome’. It is very similar to Growl and even speaks the Growl protocol if you want to receive growl notifications on your Ubuntu/Linux desktop. Installing Mumbles is a breeze thanks to the deb package that you can download here.

Once installed, you can start Mumbles by going to Applications -> Accessories –> Mumbles. You will then see the Mumbles icon Gnome panel applet, as shown in the picture below:

Mumbles Icon in Gnome Panel Applet

Mumbles Icon in Gnome Panel Applet

You can right-click on the Mumbles icon, and edit the preferences. In particular, you can change the theme of your notifications. I like the mumbles-round theme.

Mumble Preferences

Mumble Preferences

If you do not want Mumbles to show up in your Gnome Panel applet, you can start it from a shell using the ‘mumbles -d’ command.

If you want Mumbles to be automatically started when you login, go to System –> Preferences –> Session. On the startup tab, add mumbles with the ‘mumbles’ command.

Step 2: Test Mumbles Installation

Mumble ships with a ‘mumbles-send’ utility. To test it out, type the following in your shell: mumbles-send --help As you can see, mumbles-send takes in a title and an optional message. Let’s try it out now: mumbles-send 'Testing Title' 'This is a test of mumble-send' You should see the notification in the top right of the screen:

Step 3: Installing AutoTest

Autotest is part of the ZenTest Ruby gem. To install it, run: sudo gem install ZenTest That’s about it. Now go to the RAILS_ROOT directory of your application, and run: autotest Autotest should start running your tests.

Step 4: Adding Autotest hooks to Mumbles

To have Autotest results show up as Mumbles notifications, create a file called .autotest and save it in your $HOME directory. Copy the following content into that file:

module Autotest::Mumbles
  def self.mumbles title, msg
    system "mumbles-send \"#{title}\" \"#{msg}\""

  Autotest.add_hook :red do |at|
    errors = { |k, v| "#{k}:\n #{v.join("\n ")}"}.join("\n\n")
    mumbles "TESTS FAILED", errors
  Autotest.add_hook :green do |at|
    #res = at.results[/\d+ tests.*$/]
    res = at.results.scan(/Finished.*failures/m).to_s.gsub(/\e\[32m/,'')
    mumbles "TESTS PASSED", res

Step 5: Verify everything is running smoothly

At this point, you should be done. Go back to your RAILS_ROOT directory and start autotest. It should now report whether the tests PASSED or FAILED via Mumbles, as shown below:

I hope this helped! Enjoy your Mumbles Autotest notifications

Bmore on Rails – Sept. 10 2008

10 09 2008

Last night, I attended Baltimore on Rails for the first time and I was very pleased with the presentations and conversation.

The first talk was from Bryan Liles. He actually had two distinct topics. His first one was a just a quick survey of Ruby REST clients. He quickly went through a list of them, while pointing out some of their pros and cons:

Bryan’s second talk was entitled “10 things you should do to your code”. You can find the content of his presentation on his blog.

After Bryan’s talk, Frank Tao presented HyperActiveResource, a set of enhancements to ActiveResource that his team wrote. They have added a bunch of features to ActiveResource without monkey-patching it. For example, you can use :include like you would with ActiveRecord. To me, it just feels like a lot of the features they added should already be in ActiveResource. I hope that they can get some of these enhancements in there.

RailsConf Europe 2008 – Day 1

7 09 2008

Ahson and I arrived in Germany on Monday to attend RailsConf Europe thanks to FiveRuns. On Monday night, we attended Bratwurst on Rails. It was a great event and the bratwursts were delicious.

Tuesday was the first day of the conference and I attended two tutorials and a panel with the Rails Core members. The first tutorial was given by Pradeep and Michael from Intridea, a rails consulting firm based in Washington DC. The title of the tutorial was The Renegade’s Guide to Hacking Rails Internals. The second tutorial I attended was given by two ThoughtWorkers: Neal Ford and Patrick Farley. The topics were MetaProgramming and Ruby internals. The summary of the two tutorials and the panel is below.

The Renegade’s Guide to Hacking Rails Internals

Pradeep started the tutorial by listing the reasons why you would want to hack Rails internals:

  • you’ll learn a lot
  • know your tools
  • you may have to
  • you can do very cool stuff: asynchronous goodness
  • keeps your app DRY
  • keeps multiple apps DRY
  • effective ownage: own your codebase

With that said, he made sure to emphasize that hacking the internals of Rails can be dangerous, so be careful and only do it if you really need to. And when you do it, cover your ass with tests.

The first piece of Rails code that we started to look at was the Rails initialization process. A good point of entry to start understanding what is going on there is script/server. Pradeep walked us through the steps involved in the initialization of rails. In particular, we looked at boot.rb, initializer.rb, and environment.rb. To get a good idea of all Rails does during initialization, you can look at the ‘process’ function in initializer.rb.

The next thing we looked at was the Rails class loader defined in ActiveSupport::Dependencies. One thing to notice there is the way rails load classes in a production environment vs. a development environment. In dev mode, rails uses ‘load’, while in prod, it uses ‘require’. This logic can be found on the function ‘require_or_load’ in dependencies.rb (of ActiveSupport).

Below is a quick example of class loading in Rails:

has_many :users
:users => User (not loaded yet)
(searches through Dependencies.load_paths)
(finds the first file that matches => app/models/user.rb)

After that, Pradeep did a lot of live coding. He showed us how he wrote a Rails plugin that hacks the Rails internals. The plugin he wrote is similar to app-slices in Merb. It lets you dump a whole Rails-like directory structure of code into the app/slices directory and it picks everything up from there as if it was part of your Rails root folder. However, if you create a controller in app/controllers with the same name as a controller in your slice (e.g. app/slices/blog/app/controllers), the actions from the app/controller will override the actions from the slice controller.

There are other plugins for rails that do similar things:

Pradeep live-coded the whole plugin in front of the audience. It was a great presentation and a great way to learn about the Rails internals. He promised to release the code and the slides so watch the Intridea blog if you are interested.

Michael Bleigh took over for the second part of the tutorial. He showed how he wrote the subdomain_fu plugin, which ‘provides a modern implementation of subdomain handling in Rails’.

subdomain_fu doesn’t require as much hacking of the internals but it was a good example to show how you sometimes have to dig into the internals to understand what you are doing when writing a plugin. The plugin is small so I would recommend that you take a look at the code on github and try to understand it. It consits of a few helper methods in subdomain-fu.rb and a simple alias_method_chain in url_rewriter.rb. The trickier part to write was the route extension, but with the help of Jamis Buck he was able to get it working.

Meta-programming Ruby for Fun & Profit

Neal’s meta-programming talk was interesting and his slides had some interesting code samples. You can download them from here. Some of the slides I had already seen at RubyNation during his Ceremony vs Essence talk.

Here are a few things that I noted from Neal’s talk:

  • Jim Weirich’s BlankSlate just metaprogramically removes all methods from an object. It was adpopted in Ruby 1.9 where Object extends from BasicObject (which is basically BlankSlate).
  • sapir-whorf hypothesis: language affects the capabilities of thoughts
  • Even though Ruby is more powerful than Java, it has a smaller surface area. Matz created a super powerful language that is very simple at its core.
  • Features from weaker languages can be synthesized in more powerful languages.
  • Ruby is all about messages sent to objects.
  • dust gem: makes it easier to write easier/safer test

Patrick Farley’s portion of the tutorial was more about Ruby Internals. A lot of the talk was similar to his talk at Mountain West Ruby Conf. I highly recommend watching this video as you’ll learn a lot from it. In particular, the following will start making sense if it doesn’t already:

struct RObject {
struct RBasic basic;
struct st_table *iv_tbl; # stands for Instance Variable table. a C Hash.

struct RBasic {
unsigned long flags; # is this object tinted, frozen, is it a singleton class… just bit flippin
VALUE klass; # in this case VALUE is pointer to a location in memory where a class lives

struct RClass {
struct RBasic basic;
struct st_table *iv_table;
struct st_table *m_tbl; # Method table where all the behavior is stored
VALUE super; # stores super class

During the discussion of the Ruby Object model, we discovered one of the differences between the dup and clone function, as highlighted by this code. Once you watch the video, it will all make sense. Otherwise, buy these screencasts and watch them. It’s important to understand Ruby’s object model.

Panel Discussion with DHH and Rails Core Members

This was a Q&A with 3 members of the Rails core team: DHH, Jeremy Kember, and Michal Koziarsky. They started by announcing that there was a new committer and that 2.0.4 will be released (which they did the next day).

There were a lot of questions and I didn’t take extensive notes but there are two things that I remember particularly:

  • They said how git has been wonderful in allowing them to cherry-pick good patches and ideas. They were skeptical before the move of how it was going to affect their development cycles but it seems like it was for the best.
  • When asked about the competition in Ruby web frameworks, DHH said: ‘Variety is great when there is variance’. But he did acknowledge that when they see good things in these other frameworks, they can apply them to Rails (Rack comes to mind)
  • That’s all I have. Stay tuned for my coverage of Day 2 coming soon

    Five Rails Tips

    6 05 2008

    I’m a big fan of Ryan Bates’ Railscasts. He is holding a contest and I thought I would participate and share 5 Rails tips with the community.

    Without further ado, here are my five tips.

    Tip 1: Rake task to remove tildes (~) added by text editors

    My favorite text editors (emacs or gedit) create files that end with a tilde character (~) as backup copies when I modify a file. Thus, after working on my rails project for a while, I have a bunch of files ending with ~ that are hanging around. At times, it can be annoying to have my directories filled with these files so I use a rake tasks to get rid of them all.

    Put the following in a file called ’tilde.rake’ and save this file in your rails project under the lib/tasks/ directory.

    desc 'Deletes all files that end with tilde (~)'
    task 'tilde' do
    files = []
    Dir.glob('**/*~').each do |file|
    files << file
    puts "Deleted the following files: #{files.join(', ')}"

    To run the task, simply run the following rake tasks from your shell:

    rake tilde

    Update: See Dominic’s comment. Rake already includes a task to clean-up files. Just need to include ‘rake/clean’. Thanks Dominic.

    Tip 2: Small Erb Tip

    Did you ever need to display <% or %> in an erb template but didn’t know how to do it? I’ve been there!

    It’s quite easy actually, all you have to do is use <%% and %%> instead and the erb templating engine will replace them with the appropriate <% and %>.

    Tip 3: Detect Cross-Script Scripting (XSS) Attacks ‘Holes’

    If you do not know about XSS attacks, panic and go read this chapter of the Rails manual to learn about them.

    Rails provide the h() helper method for HTML meta-character conversion in views. It’s important to use it whenever you are inserting dynamic data in your erb templates.

    Sometimes, I want to double check that I’ve been using the h() helper methods everywhere so I want a list of everywhere I’ve used <%= in my views. I use the following command to scan through all the <%= where I’m missing the helper method:

    grep -R '<%=' app/views/* | grep -v '<%=h' | grep -v '.svn' | more

    Rather than typing that command everytime, I simply created an alias for it by saving the following in my .bash_aliases file:

    alias xss_erb_scan="grep -R '<%=' app/views/* | grep -v '<%=h' | grep -v '.svn' | more"

    Tip 4: gEdit on Rails

    My laptop runs Ubuntu so I use gedit for doing Rails development. gedit is highly configurable and you can turn it into a bad-ass Rails-IDE with a few tweaks.

    First follow the steps on this tutorial. This will make your gedit environment pretty much ready for rails development.

    Then, you can add the ability for gedit to execute Ruby code that you have in your currently open document by just using a keyboard shortcut. To do this, first install the ‘External Tools’ plugin. Go to ‘Edit’, then ‘Preferences’, and select the ‘Plugins’ tab. Find and select the ‘External Tool’ plugin and click on ‘Configure this plugin’. The following window should popup.

    Click on the ‘New’ button and create an ‘Execute Ruby’ tool by filling in the information as shown below:

    That’s it. You can close the window and test by writing some ruby code in a new document and pressing F5. The code will execute and the output will be shown at the bottom of the editor.

    Tip 5: Explore Other Ruby Web Frameworks

    My last tip is to explore other ruby web frameworks. There are a lot of other web frameworks written in Ruby and you can learn a lot by just exploring them. Even if you do not plan to use them for a production site, try using them for a small project, look inside their codebase and try to understand the code. Since Rails is a more mature and more complex framework, it can be scary to look inside the Rails code but the same can’t be said for some of the newer, lighter frameworks out there. Furthermore, exploring these other frameworks can give you new ideas when working on Rails projects. So just like the pragmatic programmers advocate learning one new language a year, I recommend learning a few web frameworks in that language during that year to expand your knowledge of the language and avoid tunnel vision. So go start exploring Merb, Ramaze, Camping, Sinatra, etc… Check here for a full list of Ruby web frameworks.

    I hope you will find some of these tips useful. I look forward to read the tips submitted by the other railscast readers.

    ASP.NET Rails clone?

    19 11 2007

    The folks at Microsoft are working on a MVC Framework for ASP.NET. It looks like they borrowed a lot of ideas from Rails.

    It looks interesting and I can’t wait until it gets released to start playing with it. According to Scott Guthrie’s blog post, it should be released soon.

    ASP.NET MVC Framework

    Rails :include Gotcha

    1 07 2007

    If you are using the :include option of the find function in Active Record, there is a big gotcha: you have to disambiguate all column names used in other parameters to ‘find’ (prefix each with the name of the table that contains it).

    For example, the following will give you an error:

    Post.find(:all, :include => [:user, :comments], :order => "created_at DESC")

    The error that you get is the following: Column ‘created_at’ in order clause is ambiguous
    The fix is really easy:

    Post.find(:all, :include => [:user, :comments], :order => "post.created_at DESC")

    Note that I changes created_at to post.created_at.
    I would have saved myself some debugging time had I known that so I just wanted to share.


    Get every new post delivered to your Inbox.