Pull Requests on Private Teams

Pull Requests are used often in the open source world, but less so on private teams. They are a great way to provide an automatic, team-wide code review mechanism. If your private team doesn’t use pull requests, I’d encourage you to investiage it. Why would you move your team over to pull requests? it provides a mechanism for code and source control review it gives more visibility and accountability to the whole team you can (optionally) restrict access so only trusted members bless the merge What is the Pull Request process like? There are lots of resources about how to submit pull requests out there, but the basics go like this. ...

April 24, 2012 · 2 min · Mark Simoneau

Git Bisect For Great Justice

About a week ago, we had an elusive error that appeared when we deployed our latest app to staging. Suddenly, any submission resulted in a “Stack trace too deep” error that gave no meaningful way to determine where the issue was coming from. We were stuck for a couple of days, but then I was reminded of git bisect. git bisect is a great way to trace down problems to a specific commit for purposes of isolation or blame (though I’d suggest against the latter). Like you’d expect from a programmer, it even searches efficiently, using a binary search, hence bisect. ...

April 12, 2012 · 2 min · Mark Simoneau

CanCan and Devise with nil current_user on POST

I had a Rails 2.3.X app that I migrated to Rails 3. When I did, I upgraded CanCan and Devise. Suddenly, my delete links weren’t working. I remembered that unobtrusive JS was the default so I hopped into the application.html.erb template and added the relevant javascript tags. ... <head> ... <%= javascript_include_tag 'prototype', 'rails', 'application' %> ... </head> ... Great! Now my delete links weren’t just links to the show action, but when I did click them I noticed that a CanCan error appeared. After some debug statements, it became clear that current_user wasn’t set, but only on the POST/DELETE methods. Hmmm. What could be causing this? ...

April 11, 2012 · 1 min · Mark Simoneau

Best Way to Bundle

Thanks to the RubyRogues Episode on Bundler, I learned the best way to use bundler. You want to always use the “pessemistic” version numbers for a handful of reasons. gem 'rails', '~> 3.0.3' gem 'rspec', '~> 2.7.0' This allows the most efficient resolution of gem dependencies (in this case, any version of rails from 3.0.3 up to and not including 3.1, and any version of rspec from 2.7.0 up to and not including 2.8) and the added benefit of allowing you to easily patch everything safely using only bundle update. ...

March 14, 2012 · 1 min · Mark Simoneau

Always Fight for Simpler

If there is one thing I have said over and over again in one form or another, but never seem to learn completely, it’s “Always Fight for Simpler.” Everything could be simpler. Sure, we think it can’t, but it can. Don’t assume you need a feature in an app, a gadget in your life, or a certain amount of money… fight first for simpler. Ask yourself, for any given situation, what the simplest possible solution to the problem is. Maybe it’s not good enough… but maybe it is. Fight for the simplest solution and go from there. ...

March 8, 2012 · 1 min · Mark Simoneau

Complexity and Elusive Perfection

About three or four times a year, I find myself wishing my application wasn’t so complicated. I wish I was some stud developer who always made the right architectural decisions and didn’t back myself into a corner. I read about OO ideas regarding change management and coding for change even when you don’t know what that change is and mostly, I find myself baffled. Hindsight is 20/20. I can see easily how the decision that seemed good at the time to make a Model.seed! method that allowed you to specify all the department data in the database AND change it in the app was a bad idea. I can see that allowing users to change values of reports from within the reports, like a spreadsheet without using the adjustment-as-a-line-item pattern is now a bad idea… but we’re 3 years on and it’s just not something we’re going to be able to convince the users to change or the management to invest the money in fixing. ...

February 29, 2012 · 2 min · Mark Simoneau

Octopress

I am trying out Octopress as a new blogging engine. I have seen several people use it and I appreciate the lack of PHP :)

February 28, 2012 · 1 min · Mark Simoneau

My Ideal GTD App

I have been a long time user of Things by Cultured Code, but they have been very slow implementing a couple of features that would really enhance the way I use GTD, namely time based reminders, location based reminders, and cloud-based syncing. So I went out looking. Producteev looked pretty good, but it is woefully underpolished. Firetask also looked promising, as did Wunderlist, but both left something to be desired. Toodledo had nearly everything except a native app. Omnifocus looks like it has all the features, but is so complicated and ugly that I don’t like it. ...

January 26, 2012 · 3 min · Mark Simoneau

Don't Use DateTime in Rails 3

Rails 3 has good TimeZone support built in, but you have to use the right Date and Time classes to get full support. If you have this set in your application.rb config.active_record.default_timezone = :local, then you really need to use Time so that it properly identifies itself as being in the local timezone and not in UTC when passing to the database insert. ree-1.8.7-2011.03 :001 > DateTime.parse('2011-11-27 12:00:00 +0000') => Sun, 27 Nov 2011 12:00:00 +0000 ree-1.8.7-2011.03 :002 > DateTime.parse('2011-11-27 12:00:00') => Sun, 27 Nov 2011 12:00:00 +0000 ree-1.8.7-2011.03 :003 > Time.parse('2011-11-27 12:00:00 +0000') => Sun Nov 27 06:00:00 -0600 2011 ree-1.8.7-2011.03 :004 > Time.parse('2011-11-27 12:00:00') => Sun Nov 27 12:00:00 -0600 2011 So basically, Time.parse always returns the value in the local timezone, DateTime.parse always returns the value in UTC. To get complete compatibility, always use Time.parse. Trust me, I learned the hard way :)

November 29, 2011 · 1 min · Mark Simoneau

Code Kata #1 - Supermarket Pricing

Taken from Code Kata’s by Dave Thomas The basic premise of this Kata is asking how you would model super market pricing. What is the price of an item? What is the cost? How do you handle price-per-pound? Buy 2 get one free? What’s the value of stock? It’s interesting, and I thought I’d take the time to blog through my thought process. I’d like to iterate over the design and see where it takes me. First task is to represent a product. ...

October 14, 2011 · 4 min · Mark Simoneau