David Goudreau's blog



David GoudreauDavid Goudreau
Standup 4/1/2011: April Fool's edition
edit Posted by David Goudreau on Friday April 01, 2011 at 09:26AM

Ask for Help

"Paperclip and fixture builder - we're getting some strange errors that for some reason are fixed when you rerun fixture builder - any ideas?"

No one has run into this specifically, but a few people said to make sure you're mocking out Paperclip.

"Fakeweb, Webmock, VCR, artifice - what's a good Ruby/Rails developer to use?"

It was mentioned that Artifice is good for Selenium tests while Fakeweb and Webmock are good for rSpec tests. VCR's got some fans as well. Sounds like you can't go all that wrong whatever you choose.

Interesting-y

  • GoGaRuCo - This year it will be September 16th & 17th. A call for proposals will be going out sometime in the near future.

  • Unicorn - it turns out that Unicorn doesn't reopen logs after a log rotation unless the path to the log in Unicorn is absolute - so don't use relative paths!

David GoudreauDavid Goudreau
Standup 3/31/2011: Process.spawn pwns all yer codez!
edit Posted by David Goudreau on Thursday March 31, 2011 at 09:26AM

Interestings

Get your Rails mentoring on at RailsBridge this April 8th & 9th @ the Modcloth offices in downtown SF. It's very rewarding.

If you have nested_attributes updating an attribute that is NOT in your attr_accessible attribute list on your ActiveRecord model you won't get an exception - it will just silently fail. It will, however, output a warning line to your Rails log file. Fun for the whole family.

Using popen to open a process actually calls 'sh -c' to open your process, so the process you just ran is actually the child of the 'sh -c' process you just ran. This makes tracking down PIDs simply wonderful. :-) You can use 'exec' instead and your process will be the parent process. But if you're using the new hotness you can instead use Process.spawn in Ruby 1.9.

David GoudreauDavid Goudreau
Standup 3/29/2011: Git it!
edit Posted by David Goudreau on Tuesday March 29, 2011 at 09:16AM

Ask for Help

"Is there a better way to work on a feature, set that feature set aside, do a small change, check that small change in, then resume work on the feature, all using Git?"

git stash was originally used. There were also suggestions to use a feature branch or use one of the Git GUI tools (gitx, tower, smartgit, gitti) that let you partially stage your changes then check in. Or git-friendly workflow scripts or the ol' reliable git cherry-pick.

Help

  • Does anyone know how to set a caching header for urls that end with a cachebusting string (e.g. ?123456789)? Apparently you're not allowed to get the query string when mucking with rewrite rules. A couple of people think that you are able to get your hands on it...somehow.
  • How do you do a screen capture from the Mac command line? We want to do a screen capture of a running emulator. Maybe something like this?

Interesting Things

  • Rails 2.3.8 - for nested attributes, '_destroy' is the new '_delete'. Looks like the Rails team is on top of it. Use

    @foo.update_attributes(:foo_attributes => {'0' => {:id => '1',  '_destroy' => '1'}})
    

    instead of

    @foo.update_attributes(:foo_attributes => {'0' => {:id => '1',  '_delete' => '1'}})
    

Help

  • Determining a users default time zone - someone must have solved this already, right? Well, Javascript only gives you the time offset, which isn't that useful, but Fleegix has some good support we've used on other projects.
  • The after_commit gem - we wanted to create an audit entry every time a particular model failed to create successfully. We tried using the after_rollback hook in both our tests and our development environment but it just didn't work. The before_rollback callback also didn't work, but the non-rollback callbacks in the gem seemed to behave. Anyone have any thoughts outside of overriding ActiveRecord ourselves?

Interesting Things

  • Vows - real async Javascript testing for Node.js. Jasmine does support some async testing, but it sounds like it's a bit clunky to do.
  • Using RVM on the server - is anybody doing this? Apparently not yet, but we had some strongly differing opinions on the matter as to how useful it would be and if it's the right tool for the job. To be continued...
  • Rails 2.3.8 + mongrel_rails + Rack 1.1.0 - cookies do not work. At all. Apparently with Rack, cookies get fed into mongrel_rails as an array, while Mongrel expects them to be a String. Looks like someone already ran into this. The fix is to throw this in a Rails initializer file:

    class Mongrel::CGIWrapper
      def header_with_rails_fix(options = 'text/html')
        @head['cookie'] = options.delete('cookie').flatten.map { |v| v.sub(/^\n/,'') } if options.class != String and options['cookie']
        header_without_rails_fix(options)
      end
      alias_method_chain(:header, :rails_fix)
    end if Rails.version == '2.3.8' and Gem.available?('mongrel', Gem::Requirement.new('~>1.1.5')) and self.class.const_defined?(:Mongrel)
    

    (As an aside, running mongrel_rails by using script/server works fine, we only found this issue when running our Webrat Selenium tests, which calls mongrel_rails in some different way that causes this bug to be exposed.)

David GoudreauDavid Goudreau
Standup 6/29/10 - EngineYard Redis change
edit Posted by David Goudreau on Tuesday June 29, 2010 at 09:47AM

Help!

  • Ey cloud deploy - has anyone done a deploy to EY cloud and seen the Mongrel instances not get bounced?
  • Does anyone have any tips on testing distributed applications? We're looking for the least ugly/painful way to do it well.

Interesting Things

  • Rvm and sudo - for goodness sake don't do it.
  • Sass not recompiling on deploys - a few of our projects have seen Sass files not recompile/update for some reason that we've yet to track down. So instead of spelunking through Sass code we just force the issue by having a rake task that forces the recompile - see this post for details.
  • Rails xhr redirect - one of our projects is using the xhr_redirect plugin to support ajax redirects - careful if you want to use it in your tests - it self-destructs if your Rails environment == 'test'
  • Android meetup tonight at 6:30 PM - check out the details.
  • New Redis recipe from EY - following up from yesterday, the new EY recipe to set up Redis appears to work fine with a little tweaking.

David GoudreauDavid Goudreau
Standup 6/28/10 - EngineYard Redis change
edit Posted by David Goudreau on Monday June 28, 2010 at 09:45AM

Interesting Things

  • Redis at EngineYard - EY recently fixed a bug in their system chef scripts that was unintentionally installing Redis, so if you're relying on it being there you may find it missing on your next deploy. EY has apparently just added a recipe for running Redis on a utility slice in ey-cloud-recipes. We haven't tried it out yet but at first glance it looks ok. This new recipe doesn't support running Redis on a solo instance, but it doesn't look too hard to change it to do that.

  • Library reorganization - we here at Pivotal have a library of books we let people 'check out'. We've just reorganized it a bit. Let our local librarians know if it's working for ya.

  • Mobile meetup - there's a mobile meetup tonight from 6-8 PM tonight at Horatius in Potrero Hill. They're expecting people from top mobile companies including entrepreneurs, application developers, designers, marketing/business, etc - please RSVP at the Facebook to attend.

David GoudreauDavid Goudreau
Sass development at the speed of Javascript
edit Posted by David Goudreau on Thursday June 10, 2010 at 08:51PM

Surrendering to Sass

I've finally gone all-out for Sass. The last thing that was holding me back was the speed with which I could make Sass file changes in RubyMine and see them in Firefox. I'd gotten so used to the ReCss bookmarklet being mapped to Ctrl-Z-Z using the ShortcutKey2URL Firefox addon that I couldn't go from 0.1 seconds (using Javascript to reload my css files) to see my changes to 1 second (by doing a full-page refresh in the browser) to force Sass to recompile the css files.

Enter Erik Hansen, Javascript guru and all-around nice guy, for a 5 minute pair session where we added a synchronous ajax call to the ReCss bookmarklet to '/' of our application to force Sass to recompile.

javascript:void(function(){var i,a,s;$.ajax({url: '/', async: false});a=document.getElementsByTagName('link');for(i=0;i<a.length;i++){s=a[i];if(s.rel.toLowerCase().indexOf('stylesheet')>=0&&s.href) {var h=s.href.replace(/(&|%5C?)forceReload=\d+/,'');s.href=h+(h.indexOf('?')>=0?'&':'?')+'forceReload='+(new Date().valueOf())}}})();

Note the

$.ajax({url: '/', async: false})

at the beginning of the line - we're hitting the root of our application with a synchronous ajax call (using jQuery because our application uses it and it is available) to force the application server to return a response which consequently forces Sass to recompile all the sass files we've changed. It's pretty darn fast. One caveat - if your '/' action is slow on your site because it loads a bunch of models and such (it's not yet on our site), you should be able to create a Sass action in your home controller that doesn't do much anything and point the ajax call at that instead - you might wanna enable that only in development mode, too.

And by the way, I've also fallen in love with the FireSass Firefox plugin. It's a must-have for Sass development.

David GoudreauDavid Goudreau
Rochambeau!!! Story estimation as representative democracy
edit Posted by David Goudreau on Thursday March 19, 2009 at 10:33PM

Here at Pivotal Labs we use our iteration planning meetings to not only hash out what we're going to work on in the upcoming iteration but to estimate any unestimated stories that are within striking distance of the upcoming iteration. (We often estimate 1 iteration + 1 week of stories in case we end up delivering more stories than our iteration expects us to).

Over the past couple of projects I've been involved in estimating stories truly as a team - no 'team lead' fiats, no hour-long conversations about every possible implementation under the sun. We've adopted the Rochambeau approach to help get a fairly quick gut-check estimation of a story from all developers at once. Also known as Rock-Paper-Scissors, the way this works is as follows:

  • Discuss an unestimated story for up to 5 minutes
  • Then, 1-2-3 and VOTE!

This approach has served us in a couple of ways:

  • The expectation for the developer is that we're looking for a rough estimate, not a precise measurement. This cuts down on endless technical one-upmanship.
  • The expectation for the customer is that developers have to have 1) general consensus among themselves about the risk/time/complexity of the story and 2) a defendable explanation of their estimation.

On my current project we use a 0,1,2,4,8 point scale for estimates, so each developer has 5 options to vote with. Even with this many possibilities, most stories end up with a clear general consensus and we go with that as the estimation, but in cases where there's a 50-50 split OR an estimation round where people's estimates are more than 1 level away from someone else in the group (for example, Paul votes for 1 point, George & Ringo vote for 2 points, and John votes for 4 points), that's a strong indicator that developer's assumptions are not all in line and that further clarification is required.

An added bonus is that the customers get to watch the developers vote in a concrete fashion and defend their estimates. That helps to bring the process more to life for them and to understand the concerns that we as developers have to regularly wrestle with. They also just love watching developers play RPS, I've come to discover.

For more information, check out this blog post for a discussion of team voting, spicy food, and photos.

David GoudreauDavid Goudreau
Standup 12/03/2008: Instance variables in Selenium
edit Posted by David Goudreau on Wednesday December 03, 2008 at 09:36AM

Help!

  • Instance variables in Selenium? We're setting up a User model instance in a setup method. We want to use that User instance in our test, naturally. But when we get into the test, the User instance has no methods on it. It's a standard Test::Unit Selenium test. Any ideas?
  • hoe/rake/rspec dependencies and CI? The following combination will break CI. The issue is that RSpec 1.1.11 depends on Hoe 1.8.2 and Hoe 1.8.2 requires Rake 0.8.3, which will break our CI environment. RubyGems may also need to get upgraded to get this combination to work. Sounds like a bit of work...
  • Uploaded file encodings? We're getting truncated content when uploading files encoded with ISO-8859-1 Windows. Any ideas why this is happening? Can we check the encoding when the file is uploaded?
  • Clock.now with a time zone in a named scope in the TEST Rails environment does not use the MockClock class (which lets us manipulate time in our tests). Why isn't it being used?
  • Demo environment DNS propagation & Apache configuration. The expected demo URL isn't working. It sounds like Ops just recently set the name in DNS so it's probably still getting propagated around.

Interesting Things

  • Apparently Treetop does not let you assume equality in the usual Ruby ways. Just something to look out for.
  • Last night we hosted a panel in conjunction with our partners Venture Archetypes called Project Startup. It's a regular panel we've been hosting for a while now. It happens roughly every 2 months.

Other articles: