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

Standup 6/30/2011: CI via Dropbox!

Pivotal Labs
Thursday, June 30, 2011

Interesting Things

  • To view the CI box remotely, a client has created a script that takes a screenshot of the CI build and uploads it to Dropbox every thirty seconds. On the remote machine, the screensaver has been set to this image file in the Dropbox folder, and has also been set to refresh every thirty seconds. The inventor’s name? Rube Goldberg. Next, he will be switching to FedEX.

  • When building Android Apps with IntelliJ, the first image in the image directory (alphabetically) often fails to load, and then sporadically reappears in random places in the app. The fix: Add a very small image that appears at the top of the image directory (e.g. “aaaaaaa.png”), or don’t build with IntelliJ. Since this issue doesn’t seem to show up with command line build tools (e.g. Ant or Maven), you could probably tell IntelliJ to use one of those to build with.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Kevin Fitzpatrick

Standup 6/29/2011: SSL?

Kevin Fitzpatrick
Wednesday, June 29, 2011

Ask for Help

“How can I make Watershed video streaming work with SSL? We changed page protocols and now it doesn’t work.”

This is probably a flash-based cross-domain (protocol) problem. You’ll probably have to contact Watershed support to get some help.

“How do I make the Facebook ‘Like’ button work over SSL?”

One team had luck with the FBML like button when using SSL. Remember to include the Facebook JavaScript library with a protocol-relative url
:

//connect.facebook.net/en_US/all.js

“We upgraded from Rails 2 to 3 and when upgrading RSpec to 2.0, our fixtures stopped loading. Halp?”

The options for global fixture have changed. The new version looks like:

RSpec.configure do |config|
  config.global_fixtures = :all
end

“Why can’t I run RSpec 2.6 focus tests in RubyMine 3.11? We downgraded to 2.5 and it works.”

Check out the new RubyMine 3.2 Beta. Apparently as of build 107.235 they have upgraded RSpec 2.6.0 compatibility.

Interesting Things

  • Hacknight at Sharethrough in San Francisco tomorrow, June 30th, 2011.

  • Rails Bridge is looking for Spanish speaking Rubyists to help with an upcoming workshop. You needn’t be fluent, they can help with technical vocabulary.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Danny Burkes

ActiveRecord callbacks, autosave, before this and that, etc.

Danny Burkes
Tuesday, June 28, 2011

The Ugly Truth

On a recent project, we had an ActiveRecord model that declared some relationships and callbacks like so:

belongs_to :credit_card
before_create :build_credit_card

The intent was that build_credit_card would build the associated CreditCard instance, and ActiveRecord’s default :autosave feature on the belongs_to would save it.

What we discovered was that no CreditCard object was being persisted. We confirmed that :autosave is on by default for belongs_to relationships, so we couldn’t immediately understand why the new CreditCard wasn’t being created.

Googling proved futile, so we dove right in to the ActiveRecord source- and boy did we have a good laugh about 10 minutes later.

What we found was that the :autosave option works by simply declaring a before_save callback- that makes perfect sense.

In our case, however, we were building the object to be autosaved in a before_create callback, which ActiveRecords runs after the before_save callbacks (cf. the callback ordering docs).

So our first problem was that we needed to move the call to build_credit_card from a before_create callback to a before_save :on => :create callback.

Did you catch that? There is a difference between before_create and before_save :on => :create. A big difference.

While I understand the how and why of this, the semantics don’t make it obvious. So beware!

Now with our declarations changed to

belongs_to :credit_card
before_save :build_credit_card, :on => :create

We ran our tests again, and, still, no love. Ahhh, we’ve still got an ordering problem. In addition to the ordering semantics detailed in the docs, ActiveRecord also runs callbacks within a single group in the order in which they are declared. So, even though we changed the call to build_credit_card to occur in a before_save, it was still occurring after the :autosave before_save callback, because of the declaration order.

Finally, we changed our declarations to

before_save :build_credit_card, :on => :create
belongs_to :credit_card

and our tests were happy.

Takeaways

  • When using autosave with any ActiveRecord association, be very careful of callback ordering if you are building or modifying the inverse objects using ActiveRecord callbacks.

  • before_create isn’t ever the same thing as before_save :on => :create, even if it sounds like it should be.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Matthew Kocher

Standup 6/28/2011 – At least it’s pretty inside the walled garden

Matthew Kocher
Tuesday, June 28, 2011

Interesting

  1. The the Riak Client gem uses nethttp by default. While it allows you to specify a timeout for a map reduce job, it doesn’t set the nethttp timeout for the connection to riak. This means that all requests are effectively limited to 60 seconds. The project that discovered this is switching to curb.

  2. The Mac App Store is actively hostile to business users. There is no way for us to buy software through the app store without setting up a separate account for every three computers, and then you can only reuse a credit card for three accounts. We won’t be purchasing any software through the app store that isn’t absolutely necessary until there’s a way to purchase N licenses and use those on N machines. Pixelmator is the first app to lose our business.

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

Standup 6/24/2011: How pure is your json?

Pivotal Labs
Friday, June 24, 2011

Ask for Help

“We’re using the json gem in production, but jasmine is requiring the json_pure gem for our tests. How can we run our rspec tests with the json gem (instead of json_pure) to better reproduce production?”

Nobody had a definitive answer, but one suggestion was to explicitly declare the json_pure gem in your gemfile with require: false.

Interesting Things

  • Mysql will not let you insert a record with an id of 0 if you have auto-incrementing ids turned on. However, if you really need to create a record with an id of 0 in your tests, you can turn off the auto-incrementing id feature in a before suite block.

Update:

Here is the SQL command to turn off the auto incrementing feature in mysql:

SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'

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

Standup 6/23/2011: The Only Way to be Sure

Pivotal Labs
Friday, June 24, 2011

Ask for Help

“Why did my .profile stop being sourced? It still works if I source it by hand.

You may have created a .bash_profile, which supercedes the .profile. One solution is to include your .profile from your .bash_profile. A pattern we sometimes use for this is to include every file in ~/.bash_profile_includes from the .bash_profile

“How do I get bash to automatically answer yes to questions programs ask?

There are various ways to do this, but the short answer is to use the “yes” program built into bash.
yes | my_program

“How do you delete a file called ~
Not by typing rm -rf ~
The simplest thing is to do this through the OS file system GUI.

Interesting Things

Canvas Slow on Chrome

Canvas can get very slow on Chrome sometimes. If this happens, the only thing found to work so far is to delete the Library/Application Support/Google directory

Facebook Connect De-Auth rules

It was claimed that when a user de-authorizes your Facebook application, the Facebook API terms of service require you to delete all data about the user that you got from the API. This includes fields you pre-filled that the user then submitted.

Facebook does provide you with a de-auth callback if you want one, but there is no explicit mention of it in the ToS. The ToS does say you must remove user data “upon request” and that you have to provide a way to make such a request.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Sean Beckett

Zep Solar Seeks Lead Rails Developer in San Rafael, CA

Sean Beckett
Thursday, June 23, 2011

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.

Zep Solar is looking for a lead Rails developer to join their team in San Rafael, CA.

Are you passionate about solar energy and interested in making a difference in the world? Can you see yourself leading the development of the most innovative solar design tool on the market? If you answered yes to both questions, keep reading…

Zep Solar Inc. is one of the fastest growing solar manufacturers in the world and has developed an award-winning, patented photovoltaic (PV) mounting system that is revolutionizing the solar industry and helping to make solar energy safer and more affordable for the masses. Our technology enables solar installations up to 5X faster than standard mounting systems while reducing raw materials up to 90%. As part of the new platform, we have developed a design tool that enables a user to calculate complex structural loads and automatically configure an optimal system layout while determining a bill of materials with the click of a few buttons.

Now we’re ready to add new features, products and internationalize the design tool and are therefore seeking a brilliant lead developer to manage the project and take responsibility for the whole technical stack (front-end and back-end) while weighing priorities and costs of development. The successful candidate will begin by working in a pair environment with a top development team at Pivotal Labs while learning the design tool’s system architecture inside and out before taking control over the project.

A great candidate should…

  • have publicly released a Ruby on Rails site or web service (please include links)
  • be a “full-stack” developer and be proficient from the database to javascript and
    everything in between
  • prefer test-driven development and demonstrate proficiency in this area
  • be able to translate the business needs of Zep Solar into implementation
  • be interested in enabling the proliferation of solar installations worldwide
  • value precision and be mathematically savvy
  • want to work in Marin County at our San Rafael headquarters

Send resumes to Chad Medcroft at chad@zepsolar.com. Emails only, no calls will be taken.

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

Android Tidbits 6/23/2011: Tabs and Colors

Joe Moore
Thursday, June 23, 2011

Pivotal Android Tabs

We have published a simple Android project that illustrates how to use tabs in an Android app: TabActivity, TabHost, TabWidget, and android:divider. Thank you Pivot Ryan, the original author, for taking the time to write and open source this. Check it out, fork it, and enjoy — https://github.com/pivotal/Pivotal-Android-Tabs

Tabs 1

Tabs 2

See Hex’d Colors

IntelliJ trick: in a colors.xml file, place your cursor on a hex value and hold down Shift. You’ll see a large preview of the color.

Hex colors in IntelliJ

Colors and States

(Repost from the 6/22/2011 Standup blog): You can use a selector drawable to set Android text color for the various states (focused, selected, etc.) using a drawable xml file. IntelliJ will complain and say this is invalid syntax but the application will use the file as you would expect. This only seems to work for the android:textColor attribute in TextViews.

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

auto_tagger and alternate tag refs

Pivotal Labs
Wednesday, June 22, 2011

A recent addition to Jeff Dean’s auto_tagger is the ability to use an alternate tag ref type instead of standard git tags. I pestered Jeff to add this feature after Scott Chacon explained to me how bad it is to create a large number of tags in git. Thanks, Jeff, for the feature addition!

There are a couple problems with generating autotags as standard git tags. One is that it pollutes the tag namespace which makes it harder to find tags for releases, etc. And it defeats the tags menu in the GitHub UI. The other is that git will automatically sync tags on every fetch and push, which can noticeably slow things down when you have a lot of tags. And it looks like running GitX with thousands of tags can make the app seriously slow and prone to crash.

A little background: A git tag is just a kind of ref in a special namespace. A ref is a file that contains a SHA-1 has identifying a commit, and is an entry point into the big network of blobs in the git object database. It’s quite easy to create new kinds of refs; you just put a new directory in the .git/refs dir and go from there. auto_tagger will now do this for you simply by adding one configuration option.

Drop a .auto_tagger options file into your project with these contents:

--ref-path=autotags

auto_tagger will automatically fetch and push tags in a custom namespace when it needs to. You almost never need to look at autotag refs in development, but if you do, you may need to fetch them manually. That’s part of the point of using an alternate tag type, avoiding syncing them automatically on every fetch. To manually fetch all the autotags (when using the ref-path=autotags option as above), do

$ git fetch origin refs/autotags/*:refs/autotags/*

I also really like the auto_tagger option to format tag names so they are human readable timestamps by adding a separator character. To make that work, set the date-separator option. Your .auto_tagger options file should look like:

--ref-path=autotags
--date-separator=-

Then your autotags look like “ci/2010-10-09-00-56-21″ instead of “ci/20101009005621″

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

Standup 6/22/2011: Cache bust revisited

Pivotal Labs
Wednesday, June 22, 2011

Ask for Help

“How do you make sure that an Android activity registered for an intent is always shown when that intent occurs? If the app is running and another activity is visible, the intent doesn’t seem to have any effect.”

There was one suggestion to try making the activity a singleton.

“What is the recommended way to cache bust assets referenced in CSS files?”

  • Use a sass function to append the cache bust value to the URL
  • Use css_asset_tagger plugin. This won’t work on read-only file systems like Heroku.
  • Rails 3.1 is adding asset management features, so keep an eye out for that.

Interesting Things

  • You can use a selector drawable to set Android text color for the various states (focused, selected, etc.) using a drawable xml file. Intellij will complain and say this is invalid syntax but the application will use the file as you would expect. This only seems to work for the android:textColor attribute in TextViews.

  • RubyMine has trouble locating code definitions for code in gems installed with bundler via a git url when using rvm. rvm puts gems installed with git into another directory that RubyMine doesn’t seem to know about.

  • 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. 5
  6. →
  • 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 >