Joe Moore's blog
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…
Ask for Help
"Recommendations for stripping blank lines before and after a block of text?"
- In Ruby,
"a string".stripwill do it. - Regex recommendations?
Interesting Things
If you need to change the author on your git commit message, use
git commit --amend --author=username
HELP!
"Any recommendations for a recurring-payment system that has to support charge amounts that change?"
Check out Active Merchant, PayPal API, Chargify, or simply rolling your own and charging the credit cards directly.
"I'm having a hard time debugging jQuery live events..."
Check out FireQuery. You can also look at the data attributes attached to the target DOM elements.
"Sometimes our S3 assets download incompletely when using Net::HTTP."
Things to try include:
- Save a checksum for all assets and compare that after download to detect incomplete downloads.
- Check the
Content-Lengthheader against the actual content length of the asset. - Did you set the
Content-Typeheader? Maybe Net::HTTP is confused. - Try witching from Net::HTTP to the S3 gem.
"How can we prevent users from printing the web page?"
Though nothing can prevent users from making a screen shot, deterrents might include:
- A custom print.css.
- Some printers will not print the EURion constellation. Try embedding it in the image.
"Our Solr commits have sloooooooooooooooowed doooooooooooooooooooooooown."
As Solr commits increase the warmers might take longer to spin up. You might need to add more servers or space our your commits.
Interesting Things
- Pivotal is trying to retire our saucelabs-adapter for Sauce Labs. Sauce has improved their adapters -- if you are having problems with them, let Sauce (and us) know!
- MySQL Partial Indexes can be super handy.
- YouTube announced a while back that they are changing their URL format for videos. In a nutshell they are moving away from query parameters, changing the "?" to "#!", so http://www.youtube.com/watch?v=ylLzyHk54Z0 changes to http://www.youtube.com/watch#!v=ylLzyHk54Z0.
- My Tether turns your Palm Pre into a WiFi hotspot. Sprint only!
- RubyMine blah blah Rspec blah blah... check out this blog post to find out how to fix Rspec stack traces.
- SproutCore Founder Leaves Apple to Build HTML5 iPad Apps
- Don't use Ruby's
split()method to parse tab-delimited files -- you might lose the extra white space at the end of the file when you have empty columns:
irb> "Mr.\tBob\tSmith".split("\t")
=> ["Mr.", "Bob", "Smith"]
irb> "Prince\t\t".split("\t")
=> ["Prince"]
Interesting Things
- The
<<operator in Railshas_manyrelationships acts strangely, such as silently failing validations when performing a save. Watch out! - RSpec has overloaded the
=~operator as an order-independent equality, so[1,2,3].should =~ [3,2,1]will succeed. - Tired to opening tab after tab in OSX Snow Leopard just to perform the same action? Label your tabs instead and reuse the same one for the same actions or tailing that one log: CMD+i => Info => Title => escape.
- Progress on Cedar, our BDD framework for iPhone development, is rolling right along: read all about Cedar device specs and CI.
- We noticed that the new RubyMine 2.5 ERP no longer gives us useful stack traces in Rspec; we reverted back to an earlier build. It has awesome features, though.
Interesting Things
- Here's something funny... literally: our very own Will Read's sketch-comedy troupe, Reply All, will be performing at The Clubhouse this Friday, July 9. RSVP here to see the show.
UPDATE: now with less inaccurate info! GoGaRuCo dates were wrong. Stay tuned!
JQuery Events/live + ScrewUnit = :-(. ScrewUnit swaps the DOM "out from under" the elements that Events/live is watching, which messes with ScrewUnit. Call
dieon the DOM elements that live events are watching.ScrewUnit + CI + IE = :'-( Also, When ScrewUnit suites become large, they trigger IE's "slow script" warning, which can freeze your continuous integration build. Check out the Registry Hack to set your own timeout.
We have a fan of Thor in the house: "Map options to a class. Simply create a class with the appropriate annotations, and have options automatically map to functions and parameters." Which, as is (not) obvious, indicates that Thor is a replacement for rake.
Interesting Things
You can never return: ... except when you can. From a block, that is. Returning from a block rarely works:
result = ['one', 'two'].each do |x| return x end => LocalJumpError: unexpected returnBut, you can pass
nextandbreakarguments, which will allow you to assign return values from the block:result = ['one', 'two'].each do |x| break(x) end => "one" result = ['one', 'two'].each do |x| next(x) end => ["one", "two"]
You can return from a lambda, though.
Check out Google Page Speed, which is like Yahoo's YSlow, only "better."
Page Speed is an open-source Firefox/Firebug Add-on. Webmasters and web developers can use Page Speed to evaluate the performance of their web pages and to get suggestions on how to improve them.
Like chef? Love capistrano? Check out chef-deploy, which "... Uses the same directory layout as capistrano and steals the git remote cached deploy strategy from cap and adapts it to work without cap and under chef."
SFTUG FTW! Another successful SF Tracker User Group Meetup on 06/24. Watch for future events on the Meetup site.
Ask for Help
"Does anyone have Nginx URL rewriting fu?"
The pretty documentation is actually quite hard to work with. Does anyone else have a good reference?
Interesting Things
- Pivotal in the New York Times: Regarding Palm Pre development and our own Tweed:
Some developers who were granted early access to Palm's new operating system said it was worth the wait. "We find it's the easiest one to develop for," said Christian Sepulveda, vice president for business development at Pivotal Labs. "It allows for a richer experience, like having a pop-up menu and background processing, which is helpful."
Mr. Sepulveda's company developed four of the first programs available for download through Palm’s app store, including an item for Twitter called Tweed.
- The next SF Ruby Meetup will be held here at Pivotal Labs. Sign up) and attend!
- BART strike warning! In the Bay Area we take our commute options seriously. Here are your options if BART goes on strike
Ask for Help
"Has anyone implemented mutli-table (class table) inheritance in Rails, as apposed to single table inheritance (STI)?"
- There are some plugins that nobody has tried, such as inherits_from
- What about a view to represent the super set of tables and rows?
"We're looking for a dead-simple, drop-in JS rating or 'starting' plugin."
Check out the start-rating jQuery plugin. Any other suggestions?
Interesting Things
- RubyMine 1.1 + Latest Mac OS X Java Upgrade + configuring RubyMine to work with Java 1.6 = Complex FAIL. We downgraded to RubyMine 1.0.5 and it works again.
