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
  • Tools
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

Monthly Archives: January 2012

Jacob Maine

Standup 2012/1/31: The bleeding edge

Jacob Maine
Tuesday, January 31, 2012

Interesting Things

  • There’s a new release of Backbone – 0.9.0. It’s billed as a release candidate for 1.0, and seems to be a bit buggy, as RCs can be. However, it’s exciting to see that Backbone is getting close to that milestone.
  • You should default boolean fields to true or false, at the database layer. Otherwise your queries have to deal with three-valued logic.
  • Rails 3.2 has some unexpected behavior. First, the generated form ids have changed … what used to be id=user_new is now id=new_user. Second, if your routes file is missing an entry, you will no longer get errors in controller tests. If you liked that behavior, try out request specs.

Ask for Help

  • “Anyone seen problems with the latest REE and iconv?”

Everything works on the Linux machines, but on Macs, there’s an error about an unrecognized target encoding. Iconv works on the command line, so it’s something about REE.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Max Brunsfeld

A convenient ‘super’ method for Backbone.js

Max Brunsfeld
Monday, January 30, 2012

Inheritance in Backbone

Backbone.js comes with a minimalist OO inheritance framework similar to the one employed by CoffeeScript. Each base class has a static method called extend that is used to create a subclass, like this:

User = Backbone.Model.extend({
  // instance methods
},
{
  // class methods
});

extend returns a constructor whose prototype inherits from Backbone.Model.prototype. References to all of Backbone.Model’s static methods and properties (including extend) are copied to the new constructor.

Calling ‘super’

The constructor also receives a __super__ property, which references its superclass.

User.__super__ === Backbone.Model.prototype

This makes it possible to call super inside of a class or and instance method:

User.prototype.save = function(attrs) {
    this.beforeSave(attrs);
    User.__super__.save.apply(this, arguments);
};

CoffeeScript has a super keyword that compiles to the line above, but when using Backbone with plain javascript, its a little grating to have to type that out.

A small layer of convenience

I wrote this little super method (test-driven using jasmine) which saves me having to repeat the constructor’s name all over the place. You call it like this:

User.prototype.save = function(attrs) {
    this.beforeSave(attrs);
    this._super("save", arguments);
};

The second parameter to _super is the array of arguments to pass to the overridden method. This is to optimize for the common case of passing the arguments object straight through.

There’s no way to avoid having to repeat the method name like that, unless you wrap every method definition with a helper function that either passes the overridden method as a parameter (a la Prototype.js) or reassigns a hidden super property behind the scenes (like JS.Class or John Resig’s approach). These approaches won’t work with Backbone’s ultra-minimalist inheritance system.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Jacob Maine

Standup 1/30/2012: It’s all about sharing

Jacob Maine
Monday, January 30, 2012

Interesting Things

  • should_not render_with_layout can be flaky. For example, asserting that an XHR request doesn’t have a layout could fail if the request renders an email template that does have a layout. These matchers are not very sophisticated, mostly doing string matching, not real template resolution.

Ask for Help

  • “How do I test relative time with FixtureBuilder?”

Since the models are all built beforehand, it’s tricky to write tests that make assertions about relative time. There were a variety of suggestions. You can write all the tests relative to a model: some_time.should == model.created_at - 3.days. You can wrap the entire suite and fixture generation in a Timecop block, but you’ll have to deal with losing that context whenever any test calls Timecop.return.

  • “How do I separate multiple FixtureBuilder files, but allow them to reference objects created in each other?”

Typically you want to separate fixtures into smaller files. But, you also often want to reference objects in other files, for example so you can assign a user from user_fixtures.rb to a post in post_fixtures.rb. One solution is to eval each file in a loop, so they can share instance variables. You can also use User.where(:name => "Tom") but that’s awkward and repetitive.

  • “Any suggestions for a CMS that would allow lots of different visual presentations of the content?”

The questioner is experimenting with branding. Not many suggestions… a shared database perhaps?

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Dirk Kelly

Standup 01/30/2012: Assigning IDs

Dirk Kelly
Monday, January 30, 2012

Interesting

  • Assigning a collection with an = operator will not set the id on the parent object, to do this use <<.

Events

  • This weeks brown bag will be on SQL, three of our Australian pivots will be presenting it. You can join our meetup group to find out more information.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Standup 1/26/2012 – Dawn of the WebOS Dead

Pivotal Labs
Thursday, January 26, 2012

Ask for Help

*”ActiveRecord has three methods to determine the number of records: #count, #length, and #size. Which one should we use when?”

As a general rule, always use #size. It checks to see if the recordset has been loaded and if so returns the number of records. Otherwise it hits the database with a count query. The #count method will query the database every time when it’s called on an ActiveRecord scope. The #length method is proxied through to the array of the result set, so every time you call that all the records are pulled from the DB and instantiated.

*”We’re using pow in development and it’s pretty good except sometimes we see 12 second delays in serving assets. Has anyone else encountered this?”

Quite mysterious. Perhaps updating to the Pow 4.0 beta release might help.

Interesting Things

  • Is WebOS dead? This question can be answered at iswebosdeadyet.com. Enyo, the UIKit and data-management layer used in HP’s WebOS, is now available for other webkit browsers. It works with PhoneGap and applications based on Enyo are already in the pipeline for iOS and Android.

  • Webrick when used in development with the Rails Asset Pipeline appears to truncate large CSS files. The general consensus was “Don’t use Webrick” with shoutouts given to unicorn, mongrel, passenger(standalone) and pow.

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

Standup 1/24/2012 – Lobot Needs New Neighborhood

Pivotal Labs
Tuesday, January 24, 2012

Ask for Help

*”Has anyone used Lobot to install CI somewhere other than EC2?”

Crrrrrrickets…….

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Mark Rushakoff

Unwanted whitespace between elements

Mark Rushakoff
Saturday, January 21, 2012

We recently came across a situation in our markup where we wanted whitespace in the markup for readability, but we didn’t want that whitespace represented between the elements.

We found a fix that suggested using font-size: 0 in CSS to eliminate the whitespace. That worked fine in Chrome, but we found that in Firefox, the containing element no longer scrolled with the mouse wheel or arrow keys! Apparently Firefox’s scroll speed is proportional to font-size.

Here’s a jsFiddle demonstrating the issue (open in Firefox to see the problem, of course).

Ultimately the best solution for us was to eliminate the whitespace in the markup. This StackOverflow question lists a couple creative ways to solve the same problem (using comments in place of whitespace, leaving the whitespace inside the tag).

The CSS3 draft (currently) specifies a text-space-collapse property, but we are targeting IE8 among other browsers, and the draft doesn’t seem to be finalized anyhow.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Robbie Clutton

Why we should care about not using anchor tags for page interactions

Robbie Clutton
Thursday, January 19, 2012

I was pairing with Adam today when we had a chance to write a little Javascript. This was an interaction that changed state in the DOM without changing the page location, and we initially used an anchor element. I remembered a spectacular rant by Dan Webb about why anchors shouldn’t be used in this way. I couldn’t quite find the tweets I was looking for, so I asked.

[View the conversation between Dan Webb and myself here on Storify]

Essentially the gist is “if you don’t have a URI, then don’t use the anchor tag”. That means not using markup like

  <a href="#">click</a>

I can hear Matt Andrews telling me to put a javascript void call in the href, and although I understand the point that it won’t do anything if Javascript isn’t enabled on the page whereas using ‘#’ would, and that it states its intentions through calling Javascript directly, I now think we can do a little better. So we shouldn’t do this either:

  <a href="javascript:void(0)">click</a>

I did the first pass of a refactor and started to use a span element before Berger pointed out that that was probably just as non-semantic as the anchor element. I had to concede the point.

For our case, the best option was an input element with type button. That summed up the best interaction for our use case; manipulating the DOM on a user action, without referencing another resource or an anchored point within the current document.

The thing is, it’s a small change and there are so many examples on the web where the href=# pattern is used. It does work, so why bother changing it? Well yes, while it might work, this isn’t the purpose of an anchor tag. There are other elements that will work just as well for you and make semantic sense. If we do that, then we can all make Dan a little happier.

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

Standup 01/19/2012: Dont stretch those cables

Pivotal Labs
Thursday, January 19, 2012

Ask for Help

How to scrub production data

  • try my_obfuscate
  • use handcrafted update-all sql

Interesting Things

  • Do not stretch monitor cables, they make the ports break
  • MySql: Different os have different rules on table case sensitivity(My_Table <-> my_table), be strict or you get into trouble
  • validates_acceptance_of can crash your asest:precompile on heroku (because it uses the db when loaded, but db is not yet ready), least hacky solution: validates_acceptance_of xxx unless ENV['RAILS_ASSETS_PRECOMPILE']
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Ken Mayer

Social Chorus is looking for a Ruby on Rails Engineer

Ken Mayer
Wednesday, January 18, 2012

At Pivotal Labs, one of the services we provide our clients is helping them interview and hire. 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.

Halogen Media Group merged with YouCast Corp. to collaborate in forming a powerhouse of technology, Social Chorus (http://socialchorus.com), that measures social reach through paid and earned media through influencer distribution.

Here’s the job posting:

Overview

Are you looking for a chance to do agile development? Do you want to immerse yourself in extreme programming using test driven development? Then Social Chorus is for you.

On to our development practices. We are on Rails 3.1.1 with deployment on Heroku and test driving EVERYTHING with Rspec, Jasmine, and Selenium. We are running Jenkins on our Amazon EC2 cloud for our continuous integration tests and firing it off on every push to Github. Every Monday we have an internal planning meeting that includes the dev team along with our project manager to go over upcoming features, stories that need discussion, and story estimation. Why stories? To manage the project and all the components that drive its development we use Pivotal Tracker, the collaborative, lightweight agile project management tool, brought to you by the experts in agile software development. Mornings start with stand-ups to go over the previous day’s work, work for the current day, or any blockers anybody might have. Pair programming and green tests make the day fly by with the gratification of clean code without broken windows. Our analytics module runs in the cloud, hitting nginx, aggregating all data into our sharded MongoDB database. Like to map/reduce over extremely large data sets? Sweet.

Perks. Our development is fueled by a fully stocked kitchen and beer bashes at least once a month. Team dinners, ski/snowboard trips, lunchtime crosswords, Giants games, are some of the enjoyable company sponsored events. Halloween and Christmas parties also keep us busy as the holidays get closer. On top of that, we have competitive salaries and a semi-annual bonus plan.

Currently we are boot-strapping with Pivotal Labs at their office at 875 Howard St. Upon the end of our engagement with them, which tentatively concludes at the end February, we are moving back to our home base located in SOMA, China Basin, right next to AT&T Park to join the rest of the team. Come join our team and show off your Ruby on Rails chops!

Responsibilities

  • Test Drive everything
  • Push out awesome code
  • Pair well with each other
  • Constantly stay up to date with technology

Experience

  • Ruby on Rails
  • RSpec
  • CSS
  • JavaScript
  • Database Architecture
  • Heroku is a plus

Skills

  • Ruby on Rails
  • RSpec
  • CSS
  • JavaScript
  • Database Architecture
  • MongoDB is a plus
  • NGINX is a plus
  • Amazon EC2 is a plus

Education

BS Computer Science or equivalent

Compensation

Depends on experience

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (783)
  • rails (117)
  • testing (90)
  • ruby (86)
  • ruby on rails (71)
  • jobs (62)
  • javascript (59)
  • techtalk (44)
  • ironblogger (42)
  • rspec (39)
  • bloggerdome (34)
  • productivity (34)
  • activerecord (30)
  • rubymine (30)
  • git (29)
  • gogaruco (29)
  • nyc (27)
  • design (24)
  • mobile (23)
  • pivotal tracker (22)
  • process (21)
  • cucumber (21)
  • jasmine (19)
  • ios (18)
  • tracker ecosystem (17)
  • webos (17)
  • objective-c (17)
  • fun (16)
  • android (16)
  • palm (16)
  • ci (16)
  • "soft" ware (16)
  • bdd (15)
  • tdd (15)
  • cedar (15)
  • rails3 (14)
  • performance (14)
  • css (14)
  • gem (13)
  • mouse-free development (12)
  • selenium (12)
  • goruco (12)
  • bundler (12)
  • api (12)
  • keyboard (11)
  • meetup (11)
  • railsconf (11)
  • nyc-standup (11)
  • capybara (10)
  • mac (10)
Subscribe to Community Feed
  1. 1
  2. 2
  3. 3
  4. →
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Tools
  • 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 >