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: June 2011

Pivotal Labs

NY Standup 6/9/2011: Need for speed, revisited.

Pivotal Labs
Thursday, June 9, 2011

Interesting Things

  • Last week, we discovered that Ruby 1.9′s require is unnecessarily slow, and that there’s a patch targeted for 1.9.3. Until then, Dave G. says, you can use the following to patch your Ruby 1.9.2 using RVM:

    curl https://raw.github.com/gist/1008945/7532898172cd9f03b4c0d0db145bc2440dcbb2f6/load.patch > /tmp/load.patch
    rvm get head   # always good to make sure you're up to date with RVM
    rvm reload
    rvm install ruby-1.9.2-p180 --patch /tmp/load.patch -n patched
    rvm use ruby-1.9.2-p180-patched
    

    [from https://gist.github.com/1008945/]

Events

  • Girl Develop It: The first session of the June section of Girl Develop It on Javascript and jQuery has been bumped to next Thursday, June 16th. There’s still room to sign up!
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

NY Standup 6/8/2011: Won’t get fooled again.

Pivotal Labs
Thursday, June 9, 2011

Ask for Help

“How can I validate the presence of a boolean field?”

false.present? is false, so validates :a_boolean_field, presence: true will not cause a validation error when the field’s value is false. What you’re really trying to do, probably, is to validate that it’s not nil.

The best solution we had was to use validates :a_boolean_field, inclusion: { in: [true, false], message: "must be specified" }. The custom message is needed because the default inclusion message looks weird to the user here.

How can we integration-test CarrierWave uploads to S3? Can we stub out S3?

Two suggestions: use VCR to mock the S3 conversation or use Park Place to provide a fake S3 and check the results afterwards.

Interesting Things

  • Given a Rails belongs_to association reflection, how do you get the name of the foreign key column? It’s not what you might think:

    class Person < ActiveRecord::Base
      belongs_to :best_friend, class_name: "Person"
    end
    
    
    Person.reflect_on_association(:best_friend).primary_key_name  # => "best_friend_id"
    

    Why is it called primary_key_name if it’s a foreign key? No idea. But it is.

    Note: The reflection also has an association_foreign_key. This is not what it’s for. In this case, for instance,

    Person.reflect_on_association(:best_friend).association_foreign_key  # => "person_id"
    
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Joe Moore

Android Tidbits 6/8/2011: Warning! Warning!

Joe Moore
Thursday, June 9, 2011

Un-shadowed Method Warnings!

In response to yesterday’s question about Un-shadowed Method Warnings, Pivot Tyler points out that you can turn these on by calling Robolectric.logMissingInvokedShadowMethods(). Thanks!

Bad cached-robolectric-classes.jar

On two workstations every unit test was failing with the following error:

// …many levels of stack trace, finally:
Caused by: com.xtremelabs.robolectric.bytecode.IgnorableClassNotFoundException: msg because of javassist.NotFoundException: android.content.DialogInterface$OnShowListener
at com.xtremelabs.robolectric.bytecode.AndroidTranslator.onLoad(AndroidTranslator.java:80)
at javassist.Loader.findClass(Loader.java:340)

Cause: there was an old tmp/cached-robolectric-classes.jar that was causing these errors and our tests ran successfully after deleting it. That’s two answers from Pivot Tyler!

Don’t DDOS Yourself With Your Own App

The Bump Android team wrote an article about a good idea gone wrong. Moral of the story: not all devices behave the same, and this might cripple your servers rather than the devices.

Robolectric Google Group

Join it, contribute, and learn about unit testing your Android apps.

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

SF Standup 6/9/2011: Git-Flow; RSpec + Sinatra; Rspec ‘empty test suite’

Pivotal Labs
Thursday, June 9, 2011

Ask for Help

“Why do I see ‘empty test suite’ appear in RSpec output when running focus tests in RubyMine?”

This behavior has been seen by others, but no one had an answer. A support ticket exists. vote it up

Interesting Things

  • Git-flow got praise as a simplified, better way of managing Git branches. more info.
  • Sinatra’s default setup causes problems with some RSpec matchers. Sinatra will stop exceptions and turn them in stack traces; this will cause RSpec matchers like ‘should_raise’ to misbehave. A solution is to add the lines below into Sinatra::Base when in test.
Class MyApp < Sinatra::Base
   enable :raise_errors
   disable :show_exceptions
end
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Dan Podsedly

NetworkedHelpDesk.org: New standard for data sharing

Dan Podsedly
Wednesday, June 8, 2011

Pivotal Tracker is a founding member of NetworkedHelpDesk.org, a new initiative to help “create a seamless communication stream among multiple partners and suppliers to deliver an awesome customer experience.”

Led by Zendesk, NetworkedHelpDesk.org is on open application programming interface (API) that will make it easier to connect disparate systems in areas such as project management, customer relationship management, issue tracking, and customer support.

We’re excited to be part of this initiative, and look forward to building richer, bi-directional integrations between Pivotal Tracker and other applications in the product ecosystem that help our customers collaborate across their entire organization.

If you’re interested in joining the initiative, check out the API, and join today!

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

NY Standup 6/7/2011: Making the cut.

Pivotal Labs
Wednesday, June 8, 2011

Interesting Things

  • min_by / max_by: Ian points us towards Enumerable‘s handy #min_by and #max_by. Want to get the string in a collection whose second-to-last character is earliest in the alphabet?

    ["ayx", "zbaaaz"].min_by { |s| s[-2] }  # => "zbaaaz"
    
  • keep_if: On the subject of collections, Kris points out Ruby 1.9′s Array#keep_if (note the missing bang at the end), which mutates the array to remove things for which the block returns false. For example,

    a = ["ayx", "zbaaaz"]
    a.keep_if { |s| s.length < 4 }
    a                                       # => ["ayx"]
    

    Another method, Array#select! behaves very similarly. The only difference is that when it doesn’t change the array, #select! returns nil while #keep_if returns the array. Returning nil matches the behavior of other mutators like String#sub!, while #keep_if breaks the pattern. Thus,

    ["ayx", "zbaaaz"].keep_if { |s| s.length < 4 }    # => ["ayx"]
    ["ayx", "zbaaaz"].select! { |s| s.length < 4 }    # => ["ayx"]
    ["ayx", "zbaaaz"].keep_if { |s| s.length < 10 }   # => ["ayx", "zbaaaz"]
    ["ayx", "zbaaaz"].select! { |s| s.length < 10 }   # => nil
    

    It is, perhaps, of questionable value.

  • $("textarea").clone(): Ian discovered that when jQuery clones form fields, the clones of input elements retain the values of the originals, while textareas and selects become blank.

  • jsFiddle: Sam J. points us towards jsFiddle, a nifty tool for sharing JavaScript snippets. It provides a pane each for JS, CSS, and HTML, and then a pane that shows the results. Then you can share it like a Gist or a Pastie.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Joe Moore

Pivotal Android Tidbits 06/07/2011

Joe Moore
Wednesday, June 8, 2011

We’re trying an experiment: since we currently have several Android projects at Pivotal Labs, and Android development and testing is hard, we are going to post to the blog the tips, tricks, gotchas, and conundrums we find.

Emulator and Orientation

Android will destroy and recreate activities upon screen orientation change. One way to prevent this is to set android:configChanges="orientation" in your AndroidManifest.xml (article here):

<activity android:name=".activities.MyActivity"
          android:configChanges="orientation"/>

This prevents android from calling onPause() => onDestroy() => onCreate() on a device, but not within the emulator; annoyingly, the Activity is still recreated within the emulator.

Un-shadowed Method Warnings?

Once again we spent about 15 minutes debugging a failing unit test only to find that there was no Robolectric implementation/shadow for one of the Android methods under test (ArrayAdapter#insert in our case). I would be nice to have a “warning mode” where Robolectric would log warning for all un-shadowed methods. I wish we knew the guys who wrote Robolectric…

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

SF Standup 6/7/2011: CanCan allows model field authorization by user

Pivotal Labs
Tuesday, June 7, 2011

Ask for Help

“How do you restrict access to particular fields in a model by user (e.g. admin user versus regular user)?”

The CanCan gem can do this.

“How exactly does Active Support find helper files when injecting them into view contexts? The goal is to add helper files into view contexts without using ActionController.”

There was no immediate answer; some pivots are going to look into this.

Interesting Things

  • An Xcode update (4.0) has end-of-life’d hwprefs, which older versions of the parallel_tests gem require. The solution is to upgrade to the newest version of the parallel_tests gem or to place the shell script below somewhere within your search path.
  #!/bin/sh

  case $1 in
  'thread_count') sysctl -n hw.ncpu
  esac

Events

  • Code for America is having an Open House tonight more info..
  • SF Ruby is having a hack night tomorrow at TrueCar more info..
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

NY Standup 6/6/2011: Let’s get dangerous.

Pivotal Labs
Monday, June 6, 2011

Interesting Things

  • Using the result of render as an attribute: If you call render in a view, you’ll get back a SafeBuffer, which acts like a String but is trusted and allowed to contain HTML which will not be escaped when it’s placed on the page. If you use this value in a DOM attribute, however, it will be escaped:

    - template = render 'ajaxy_thing/template'
    %ul#ajaxy_things{template: template}
    

    If it weren’t escaped, the contents of template would probably break out of the ul tag early and mess things up.

    One pair tried to extract code like this into a helper, and then do something like:

    template = render('ajaxy_thing/template')
    content_tag(:ul, id: "ajaxy_things", template: template)
    

    Here, it turns out, template is so trusted that its contents are inserted without escaping, which breaks the ul tag. It becomes something like:

    which is clearly no good. (In fact, it’s so weird that I had to turn that snippet into an image just to get the blog to display it.)

    When you have a String which is untrusted and you don’t want it to be escaped, you call #html_safe on it. This is the opposite, and it’s not clear how best to do it. The pair decided to make a new String out of it, which worked:

    template = String.new(render('ajaxy_thing/template')) # The new String is not html_safe
    
  • TeamCity 6.5 : TeamCity 6.5 is out, but it breaks RVM support. It will return in 6.5.1.

Events

  • Girl Develop It will begin its 4-week June section on Javascript and jQuery on Thursday, June 9th. Girl Develop It is a series of programming classes designed to help women enter the software development world and change the ratio. There are still some spots left!
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Gregg Van Hove

Standup 6/6/2011: SSH IdentitiesOnly bites back

Gregg Van Hove
Monday, June 6, 2011

Ask for help

  • How do you specify a behavior for Backbone.js when there is no hash?

You specify a default behavior for the Backbone model.

Interesting Things

  • If you have IdentitiesOnly turned on in your .ssh/config file, ssh will not connect to any hosts that aren’t listed. This bit a team trying to set up heroku auto-deploys on their CI box, once they added a heroku Host to .ssh/config, everything worked fine.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (781)
  • 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 (21)
  • cucumber (20)
  • design (19)
  • jasmine (19)
  • ios (18)
  • webos (17)
  • objective-c (17)
  • android (16)
  • tracker ecosystem (16)
  • palm (16)
  • "soft" ware (16)
  • fun (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. ←
  2. 1
  3. 2
  4. 3
  5. 4
  6. 5
  7. →
  • 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 >