Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

Monthly Archives: February 2010

Sean Beckett

New Yorkers, looking for a new challenge? Come work for a Pivotal client!

Sean Beckett
Sunday, February 28, 2010

At Pivotal Labs, one of the services we provide is bootstrapping startups, including helping them interview and hire. We have a current client looking for skilled engineers to build their development team. This is an excellent opportunity to learn Extreme Programming by working side-by-side with Pivotal’s talented and experienced developers while at the same time getting in on the ground floor of a small and dynamic team.

Pivotal Labs and our clients place a strong emphasis on Agile development and its many aspects: Pair Programming, Test-Driven Development, rapid iterations, and frequent refactoring. General technical requirements include serious web development experience, and a significant subset of Ruby, Rails, CSS, JavaScript, or MySQL.

Here is a job posting from National Lab Day, a current Pivotal client looking for developers in New York.

National Lab Day

We are a non-profit platform funded by the Gates Foundation and the MacArthur Foundation connecting teachers, kids, scientists and techies to engage kids in hands-on learning for science, math, computers and engineering in schools across the country. Our site is at www.nationallabday.org

We are looking for Ruby on Rails programmers to join our team part- or full-time for the next three months as we prepare for a coordinated national event endorsed by President Barack Obama.

Job Description:

  • Develop and maintain a Ruby on Rails app for a high-profile non-profit
  • Work directly with management to improve the product and the message
  • Test Driven Development
  • Aggressive Refactoring

Additional Skills desired:

  • Ability to communicate and coordinate with non-technical management
  • JavaScript, including experience with Javascript testing frameworks
  • SQL

Please email a brief description of your work experience to info@nationallabday.org, optionally including a resume and/or portfolio. Compensation will be commensurate with your experience.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Glenn Jahnke

Adventures in TDDing Scala Actors with Scalatest

Glenn Jahnke
Saturday, February 27, 2010

Recently, Martin Odersky and David Pollak visited Pivotal Labs to show off Scala and its Lift web framework. I have an ongoing interest in concurrent programming and this resparked my interest in Scala and its Actors, a library that leverages the Erlang style concurrency model but with a (relatively) more familiar JVM language. I began spiking on a project with Actors some time ago but hit several issues that made me really want to test-drive the project to both drive out better design, and hopefully eliminate some of these bugs in a more productive manner.

After some effort reading documentation about both ScalaTest and Scala’s Actors, and wrangling with the compiler for a while, here is where I am so far.

The test for a very simple Square class that accepts three messages, then returns the maximum.

package test

import org.scalatest._
import matchers.MustMatchers
import main.Square

class SquareSpec extends Spec with MustMatchers {
  describe("Square") {
    it("returns the max of 3 messages received") {
      val timeout = 500
      val square = new Square
      square ! 1
      square ! 3
      (square !? (timeout, 2)).get must equal(3)
    }
  }
}

Here is the implementation.

package main

import scala.actors.Actor
import scala.actors.Actor._

class Square extends Actor {
  var numMessagesReceived = 0
  var maxMessageReceived = Integer.MIN_VALUE
  this.start
  def act() {
    loop {
      react {
        case msg : Int => replyWhenNecessary(msg)
      }
    }
  }

  def replyWhenNecessary(msg : Int) {
    println(msg)
    maxMessageReceived = if(maxMessageReceived > msg) {maxMessageReceived} else {msg}
    numMessagesReceived += 1
    if(numMessagesReceived == 3) {
      reply(maxMessageReceived)
      exit
    }
  }
}

Things I learned:

Scala

  • Scala’s classes don’t call out the main constructor, you just dump the class variables in parentheses after the class name and constructor code inside the body of the class

Actors

  • You can use the method!?(timeout, message) in place of !(message) to synchronously, and with a timeout, get a return message from the actor. The actor must reply though. The timeout is great for testing, often you’ll have an actor in an infinite loop and your test won’t complete instead of failing nicely.

ScalaTest

  • ScalaTest has several flavors of test, but the one that most Rubyists will appreciate is having your test class extend Spec as it is most similar to RSpec.

General

  • IntelliJ Community Edition with the Scala plugin is pretty awesome.

Hopefully I’ll have more later as I continue my effort to learn how to test concurrent programming.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

NYC Standup Round-up for Feb 22th – Feb 26th

Pivotal Labs
Friday, February 26, 2010

Live from the set of Snowpocalypse 4: The Reckoning, it’s the weekly NYC Standup Round-up!

Interesting

  • Corey points out that the Google Maps embed code wants to be put directly on a page, not loaded on demand with something like jQuery’s $.getScript(). Luckily, there’s a fix: adding an async=2 param to the Google Maps API URL. More info in a post from Olly Hodgson.

  • Rachel and Pat found out the hard way that Bundler 0.9.8 doesn’t run on Ruby 1.8.6. Upgrade your Ruby or stick to Bundler 0.9.7.

  • The same team had a real headache even upgrading from Bundler 0.7.0 to 0.9.8. The gem cache directory moves and the Gemfile format changes, among other things. This sounds like more than a minor-version change to your standup scribe.

  • Don’t put Coca-Cola in the freezer. I know, you want it to get cold faster. You’ll come back for them in like five minutes. It seems like a great idea. But out of sight, out of mind, and the next day, you open the freezer to grab your microwave burrito and you find these waiting to explode all over you:

    Oh ,the Cokemanity.

    I’m just asking you to think this through. Do you want frozen Coke foam splattered across your nice shirt? You can put an end to this madness. Just don’t do it.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

SF Standup Feb 26, 2010: Golden Gate Ruby Conf Dates!

Pivotal Labs
Friday, February 26, 2010

Asking for Help

“Reloading model associations in Rails doesn’t do what you expect it to do.”

If you have a has_one relationship between the parent and the child and you reload the association, rails 2.3.2 will do a ‘select * limit 1;’ from the child table which is not what you want.

“How do I get the debugger in RubyMine to load my fixtures?”

So apparently the debugger built into ruby mine is using a different database connection that doesn’t see the fixtures. Probably because they are built in an uncommitted transaction. The command line debugger doesn’t have this problem.

Interesting Things

  • This years Golden Gate Ruby Conference will happen at a to be disclosed location on Sept 10th and 11th.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Spiking on a Rails 3 upgrade

Pivotal Labs
Wednesday, February 24, 2010

Rails 3 is now beta and the core team is asking people to try it out and report issues back. We decided to do a small spike to get some experience with the upgrade process and see if we could help identify any problems. The application we worked on was our own Pivotal Pulse CI aggregation display (which you can see in action).

Here’s a quick overview of the steps we went through:

  1. Install Ruby 1.8.7 using RVM
  2. Install Rails beta gems
  3. Upgrade the app using the rails_upgrade plugin
  4. Tweak things a lot
  5. Drop incompatible dependencies
  6. Profit!

The first thing we had to do was install RVM. Our development machines are standardized on Ruby 1.8.6 — which we wanted to keep, of course — but Rails 3 requires Ruby 1.8.7. We installed patchlevel 174 after finding that higher patchlevels are not stable with RVM.

$ rvm install 1.8.7-p174

We also found it useful to set 1.8.7 as the default.

$ rvm use 1.8.7-p174 --default

That will also set the ruby that TextMate uses (but not RubyMine). If you don’t want to set 1.8.7 as the default, you can manually set the version of Ruby that TextMate uses by specifying the TM_RUBY shell variable. (Tips on how to manage Ruby VM preference in RubyMine appreciated.)

With Ruby 1.8.7 set up, it’s time to install Rails. You need to install from gems, but because it’s a pre-release gem, there are a few extra steps. Here’s what it took on our side:

$ gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
$ gem install rails --pre
$ gem install railties --pre
$ gem install rack-mount -v 0.4.7

The first line installs the Rails 3 dependencies that are not, themselves, pre-release gems. RubyGems 1.3.5 has a bug that it won’t install non-pre-release gem dependencies of a pre-release gem. This is fixed in 1.3.6, we hear, but that release has other problems. The second line installs the Rails 3 pre-release gem. The third line fixes a “can’t find executable rails” error, and the fourth line installs the right verison of rack-mount — the current version, 0.5.1, seems to break things.

At this point, you should test your installation by generating and running a new app.

$ rails fiddle
$ cd fiddle
$ rails server # => replaces ruby script/server

But what we’re really interested in is an upgrade. Step 1 is the rails_upgrade plugin. The Pulse app was managing gems using geminstaller instead of Rails config.gem feature, so we added our gems to the bundler Gemfile by hand instead of using the upgrader task.

An interesting change in Rails 3 is that config/environment.rb has faded into obscurity. Init code that was located within the initialize block should be moved into config/application.rb. Any other code should be moved into initializer files in the config/initializers/ directory. Be careful with scoping of globals; you may need to add some ::s to the front of your constants to get them to work right.

The app needed a few other minor tweaks to get running:

  • route conversion in the rails_upgrade plugin didn’t retain all the options on the singleton resource definitions.
    map.resource :login, :controller => "sessions" converted automatically to just resource :login
  • rails server failed because there was no tmp/pids directory; once we created it, it started right up.
  • output is now escaped by default in views, so in one place we needed to add raw to get the output markup interpreted.
    <%= historical_status_list(project) %> # => <%= raw historical_status_list(project) %>

We had a few dependencies that flat-out didn’t work; the most important of these were rspec and rspec-rails. The Pulse tests are all rspec, and while we were able to get them to run by installing Mutwin Kraus’ modified version of rspec-rails as a plugin, they didn’t come anywhere close to passing. This may be due to our use of foxy fixtures – calls such as projects(:project_name) failed, as did references to fixture names in the foreign key fields in fixture yaml files.

Also not working:

  • wapcaplet
  • custom-err-msg

Once we finished all the tweaks, we ran rails server, and the application loaded and behaved normally (just not on the first attempt, heh). Pulse is a small enough project that we can say with at least some confidence that the app still works, even though the tests are red. It does feel a little dirty to check that code in though — even to a branch.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

SF Standup Feb 24, 2010: Chasing Down Obscure Error Messages

Pivotal Labs
Wednesday, February 24, 2010

Interesting Things Today

  • Message “undefined method ‘join’” on gem installation during deployment to Engine Yard turned out to be the result of an upgrade of RubyGems from 1.3.5 to 1.3.6. The new version no longer requires stringio which broke bundler 0.8.1. The solution was to install the gem bundler08 -v0.8.4 on the server and then rerun ‘gem bundle.’

  • A mysql ‘Error 139′ was traced to a mysql 5.0 innodb table that had enough varchar(255) and text columns such that the total bytes in the row exceeded 8k bytes. This is allegedly fixed in 6.0 (maybe 5.1).

  • Finally a team noticed the new ‘touch’ option in rails 2.3.4 on has_many and belongs_to attribute that allows you to update the updated_at attribute of child and parent objects. They’d implemented their own observer pattern to do the same thing but this was much easier.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

SF Standup Feb 23, 2010: Bleeding edges break things

Pivotal Labs
Tuesday, February 23, 2010

Interesting Things

  • One project attempted upgrading the newrelic rpm to version 2.10.3 and 2.10.4 but it broke delayed_job. The fix was to down grade newrelic to version 2.9.9.

  • Ruby versions above 1.8.7 patch level 174 are not stable with RVM. Incidentally this is the version of ruby that ships with snow leopard.

One Question:

  • What’s the best practice for configuring services that notify users between development, staging and production? You really don’t want to send out a million email notifications by mistake when you are testing the staging version of a service. If you put the switch in the database, it could lead to the production database being moved to staging or development and sending out erroneous notifications. Putting the switch in an environment variable means that it’s difficult to test the staging server with some sample data.

Some Answers:

  • Some projects encrypt credentials for the different environments with different keys, thus the production credentials will absolutely not be available to the staging servers. (This can be hassle because you get exceptions when you try to use the real credentials in a staging environment with the different key.) Doing this means that you can inject test data into the staging environment encrypted with the staging keys and use that without risk of mistakenly sending notifications to real users.

  • Consider wrapping the API in question with a fake that only talks to the real world in the production environment.

  • Perhaps you could set up a rake task that manages the state of a live versus test notification.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

NYC Standup Round-up for Feb 16th – Feb 19th

Pivotal Labs
Friday, February 19, 2010

Helps

  • Using bundler seems to break some Rails plugins which try to extend Rails objects, such as Loofah, and no one is sure why. Probably something in the load order is different. A “workaround” is to find other ways of including functionality in your models, such as including modules in an ApplicationModel base class, which you should probably do anyway. Still, does anyone know what’s going wrong?

  • On a few of our Snow Leopard machines, we’ve seen git slow to a crawl. Rebooting seems to fix it temporarily. We haven’t seen it on our Leopard machines. Anyone else seen this or have a fix?

Interesting

  • On one of our projects, we have a rake task called deployed:versions which sshes into each of our deployment boxes finds the git version which is deployed, and presents the results in a nice table. It’s been a handy tool, and you may want to write one for yourself, especially if your project deploys to lots of boxes and environments like ours.

  • If you’re using Snow Leopard and Firefox 3.6, you may have some issues with sqlite3 (of all things). Sauce Labs have fixed this in their Sauce RC, which is a replacement for Selenium RC. You don’t have to use Sauce RC to get the fix; just download it and replace the JAR files in Selenium RC with theirs.

  • Speaking of Selenium did you know it has great drag and drop support? Here’s a Cucumber step for dragging items in a jQuery UI Sortable list:

    When /^I drag “([^"])” above “([^"])”$/ do |dragged_item, dropped_item|
    li = lambda { |text| %{//ul[contains(@class,"ui-sortable")]/li[contains(string(),"#{text}")]} }
    selenium.drag_and_drop_to_object(li[dragged_item], li[dropped_item])
    end

  • On one project, have a lot of commits called “WIP” (”Work in progress”). It’s not a very useful message. Some people have taken to squashing their branches into a single commit before they put them on master. When there are lots of commits on a branch, this is also not very useful, as the details of what happened get lost. Instead, we’re striving to give commits good names and not squash them. When we do need to make a WIP commit, such as when we push work in progress at the end of the day, we amend to it later and give it a meaningful name.

    When it’s time to rebase onto master, you can do this:

    code(master)$ git rebase -i origin/master

    That -i means “interactive”. Your editor can open, and you can tell git to squash meaningless commits into other commits they belong with. You’ll get a chance to give the frankensteined beast a new commit message. You can also reorder, skip, or edit commits this way; see git help rebase for details.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Davis W. Frank

webOS Workshop Tech Talk posted

Davis W. Frank
Thursday, February 18, 2010

As promised, the video from the webOS Workshop we held on January 23rd is posted on our talks page.

It’s full of tips & tricks for developing webOS applications, including a live “pairing” session with the audience.

Slides (such as they are) are posted here.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Selenium in the cloud, saucelabs.com and the SaucelabsAdapter

Pivotal Labs
Thursday, February 18, 2010

Pivotal has recently started experimenting with a service that runs Selenium tests ‘in the cloud’ at saucelabs.com. Sauce Labs was founded by Jason Huggins, the creator of Selenium.

The first question that comes to my mind when such services get mentioned is “do I have to give them a copy of our source code and database so they can run this test for us?”. In the case of Sauce Labs the answer is no. They use a novel architecture that involves a round trip from your test process (e.g. cucumber or something else using selenium-client) to saucelabs.com, where they run a SeleniumRC server and a browser, then back to your machine where your webserver and database are. Something like this:

Sauce Labs Architecture, Simple

Of course in the real world we all live behind firewalls, so actually the architecture is slightly more complicated. You setup a reverse SSH tunnel to a machine at Sauce Labs that the Sauce On Demand service then uses to tunnel to your webserver.

Sauce Labs Architecture, Detail

Of course inserting this roundtrip across the Internet is not without cost. The penalty of running Selenium tests this way is that they run quite slowly, typically about 3 times slower in my experience. This means that this is not something that individual developers are going to do from their workstations.

However, when you consider the issue of cross-browser testing, this starts to look a lot more attractive. During our continuous integration (CI) testing, we like to test against several different browsers. In the past this has meant complex setups involving virtual machines running Windows and other OSes. With Sauce’, switching OS and browser is simply a matter of tweaking a parameter. For CI builds, speed is not of the utmost importance, so we are willing to trade the cost of maintaining complex and fragile build setups, for a speed penalty.

To ease the integration of this service into Rails projects, we have written a gem, saucelabs-adapter, that will do the necessary tunnel setup/teardown and selenium configuration, automatically as part of a Rails test. Currently it supports Test::Unit using Polonium or Webrat, and JsUnit tests. We haven’t used it with an RSpec project yet, but I suspect that will be an easy integration.

Today we are open-sourcing the saucelabs-adapter gem:

  • The code
  • Pivotal Tracker project
  • Canary CI build that runs once per hour to see if adapter is working and Sauce Labs service is up.
  • Canary source code.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (780)
  • rails (113)
  • testing (88)
  • ruby (83)
  • ruby on rails (70)
  • jobs (62)
  • javascript (55)
  • techtalk (44)
  • rspec (38)
  • ironblogger (32)
  • productivity (30)
  • activerecord (29)
  • gogaruco (29)
  • git (28)
  • nyc (27)
  • rubymine (26)
  • bloggerdome (23)
  • mobile (22)
  • process (21)
  • pivotal tracker (20)
  • cucumber (20)
  • jasmine (19)
  • design (18)
  • ios (18)
  • webos (17)
  • objective-c (17)
  • android (16)
  • palm (16)
  • "soft" ware (16)
  • fun (15)
  • tracker ecosystem (15)
  • ci (15)
  • cedar (15)
  • rails3 (14)
  • performance (14)
  • bdd (14)
  • gem (13)
  • css (13)
  • tdd (13)
  • selenium (12)
  • goruco (12)
  • bundler (12)
  • meetup (11)
  • railsconf (11)
  • nyc-standup (11)
  • capybara (10)
  • mac (10)
  • mojo (10)
  • chef (10)
  • api (10)
Subscribe to Community Feed
  1. 1
  2. 2
  3. 3
  4. 4
  5. →
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >