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

Hash#fetch with confidence

Abhijit Hiremagalur
Sunday, May 5, 2013

Hash#fetch is stricter about key presence than Hash#[]

 {}[:foo]
 => nil

 {}.fetch(:foo)
 KeyError: key not found: :foo

If you forget to set an ENV variable, would you rather your application fail late or immediately?

 ENV['TWITTER_OAUTH_TOKEN']
 => nil

 ENV.fetch('TWITTER_OAUTH_TOKEN')
 KeyError: key not found

It’s especially interesting when a key with a truthy default is explicitly set to a falsy value.

options = {on: false}

@on = options[:on] || true 
=> true # yikes, ever fallen into this trap?

@on = options.fetch(:on, true) 
=> false
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 08/05/2010: ‘bundle check’ and Websockets

Abhijit Hiremagalur
Friday, August 6, 2010

Ask for Help

  • How to specify compile flags when installing the mysql gem with Bundler 1.0.0RC1?

Don’t. Instead use version 2.8.1 of the mysql gem and ensure mysql_config is on your PATH.

Interesting Things

  • The team whose CI build was running Bundler too many times addressed this by wrapping bundle install in a conditional using bundle check.

 

This saved about three minutes of build time (from what used to be 11ish runs of bundle install instead of bundle check.)

  • Websocksets are easy, use them if you need to ‘push’ to your webapp and your server can handle many persistent connections.

This was in reaction to some recent conversation between Pivots about Pusher, which will keep persistent connections on your behalf.

This said, here’s a quote from websockets.org:

WebSockets represent an alternative to Comet and Ajax. However, each technology has its own unique capabilities. Learn how these technologies vary so you can make the right choice.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 08/04/2010: Accounting on Rails anybody?

Abhijit Hiremagalur
Wednesday, August 4, 2010

Ask for Help

  • Double-entry/ledger based accounting in Rails (i.e. Quickbooks in Rails for free)

Ideally would be tied in with user/role system where each accounting entry would be tied to a user, but also reconciled against a master account.

Recommendations? Latest and greatest?

One suggestion was to look at the code that Wesabe open sourced code when they closed their doors.

  • Error message when opening Rubymine “Invalid Git Root”

This is likely because the project included a submodule that wasn’t configured correctly, fix this in under Rubymine’s version control preferences.

Add submodule screen in Rubymine

Interesting Things

  • Test 404 handling (e.g. rescue_from ActiveRecord::RecordNotFound, :with => :render_record_not_found) with Cucumber by temporarily setting ActionController::Base.allow_rescue = true. This is usually set to false in features/support/env.rb
  • JSON.pretty_generate hates Rails 3 Hashes

 

  • Use window.postMessage to communicate between IFrames in a standard way

This should work in most modern browsers. Follow the Mozilla docs, NOT the various blog posts about this.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 08/03/2010: Bundle me this Batman!

Abhijit Hiremagalur
Tuesday, August 3, 2010

Ask for Help

  • I asked if there’s a date library in Ruby as rich as Java’s JODA

Suggestions included Chronic and RI_CAL though I’m hoping for something that can represent arbitrary periods (ranges?) of time JODA and handles interval calculation and other such date/time arithmetic.

  • is(‘:visible’) doesn’t always work as expected in Jasmine

One project reported that using this to as part of a Jasmine spec to ensure that an element becomes visible doesn’t appear to be reliable.

  • Annotate and Git History failed for a team using Rubymine 2.0.2 and git 1.7.2.1 in combination with svn.

They solved the problem by downgrading to git 1.7.1.1:

I followed instructions here to create a local set of portfiles:

http://guide.macports.org/#development.local-repositories and grabbed the older portfile from here:

https://trac.macports.org/browser/trunk/dports/devel/git-core?rev=69357

After I could do a port search git-core and have 1.7.1.1 show up, I was able to sudo port deactivate git-core @1.7.2_0+doc+svn and sudo port install git-core @1.7.1.1+doc+svn

  • One person was experienced compile errors when installing memprof on Ubuntu, fortunately somebody else had gotten this working before and offered to help him through thee.
  • A team noticed that Bundler ran multiple (4) times on CI taking nearly 11mins overall and wanted to know to make Bundler run only once

It was suggested that the problem may be due to the way they’d setup their preinitializer.rb and they should move the bundle install into a Rake task.


if ENV['IS_CI_BOX']
puts "IS_CI_BOX is set, running bundle install..."

system(‘bundle install’) || raise(“‘bundle install’ command failed. Install bundler with gem install bundler.”)

end

It was pointed out that they should make sure their Gemfile.lock file is checked into version control, which it was. Additionally Bundler 1.0.0 RC1 will allow isolating gems to a local path using bundle install path --disable-shared-gems

Interesting Things

  • The Facebook Graph API doesn’t appear to implement OAuth 2.0 properly/completely so it doesn’t work with the OAuth2 gem
  • One Pivot noticed that the version of ImageMagick installed on the default EngineYard solo image is out of date and had to upgrade this manually.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 08/02/2010: weird errors and convenient Jasmine fixture generation

Abhijit Hiremagalur
Monday, August 2, 2010

Interesting Things

  • One team noticed an odd error when they mistyped a Thor constant name.

ArgumentError: Thor is not missing constant Sandbox!.

This appears to due to how #const_missing in activesupport handles nested constant names. Specifically when trying to reference one nested constant from within another nested constant that isn’t its parent:

 

Curiously the spec that exposed the previous issue also returned this odd summary:

0 examples, 1 failure, -1 passed

This is also similar to another standup blog post from almost a year ago.

  • When using JB’s technique to save fixtures
    for Jasmine in controller specs
    , considering naming all your examples that create fixtures identically. This way you can easily run just these examples to regenerate your fixtures with something like spec -e 'should generate a fixture for jasmine'
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup Blog: 11/19/2009

Abhijit Hiremagalur
Thursday, November 19, 2009

Help

One project is releasing soon but has not yet been indexed by Google, what’s the best way to get Google to index the website quickly?

How do people distinguish between nil and a cache miss when using Memcached and Ruby?

  • Some suggested using a :symbol to represent nil

form_for @object sometimes posts to the wrong action, has anybody else seen this?

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup Blog: 11/18/2009

Abhijit Hiremagalur
Thursday, November 19, 2009

Help

“Recommendations for a configurable embedded video player”

  • Lot’s of people recommend Flowplayer
  • Other’s suggested looking the Youtube APIs
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup Blog 02/07/2009: RM 1.1.1 + Java 1.6 on OS X Solved, Pivotal video, PDF Libraries

Abhijit Hiremagalur
Monday, July 6, 2009

Interesting Things

  • Answer to RM 1.1.1 + Java 1.6 on OS X issues
  • Pivotal/EngineYard video

Help

“What Ruby PDF libraries are people using?”

  • Especially for HTML to PDF generation
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 06/30/2009: (Really) delete git tag, rails filter action and matrix knot!

Abhijit Hiremagalur
Tuesday, June 30, 2009

Interesting Things

  • Rails controller filters can also be objects
    • Any object with a before, after or filter method can be a filter
  • Will Read attempts the Matrix knot
    Image

Help

“How do you permanently remove a git tag?”

  • One team would like a delete a tag created by their CI, but it keeps coming back if somebody who has pulled the tag locally does a push.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 01/16/2009: onReady() for AJAX, Web Sprites & Detecting UTF-8

Abhijit Hiremagalur
Monday, January 19, 2009

Interesting Things

  • Web based sprite generator – here

This also makes the generated sprite really small which is great if you care about page load times. A Ruby+ImageMagick sprite generator might also be a good thing to build.

  • Cool way of detecting if a file is UTF-8 enconded using Ruby+IConv – here

Ask for Help

“Is there an onReady() for AJAX events?”

  • onAJAXReady() ?
  • JQuery Live Events might do the trick
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Abhijit Hiremagalur

Abhijit Hiremagalur
San Francisco

Subscribe to Abhijit's Feed

Author Topics

ruby (3)
bundler (1)
websockets (1)
cucumber (1)
javascript (1)
json (1)
rails (2)
rails3 (1)
rubymine (2)
testing (2)
ey (1)
facebook (1)
imagemagick (1)
jasmine (2)
thor (1)
agile (3)
ajax (1)
css (1)
design (1)
iconv (1)
jquery (1)
utf-8 (2)
character encoding (1)
unicode (1)
acts_as_fu (1)
selenium (1)
  • 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 >