Joe Moore's blog



Joe MooreJoe Moore
Pivotal Android Tidbits 06/07/2011
edit Posted by Joe Moore on Wednesday June 08, 2011 at 06:53AM

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…

Joe MooreJoe Moore
Standup 12/2/2010
edit Posted by Joe Moore on Thursday December 02, 2010 at 09:27AM

Ask for Help

"Recommendations for stripping blank lines before and after a block of text?"

  • In Ruby, "a string".strip will do it.
  • Regex recommendations?

Interesting Things

  • If you need to change the author on your git commit message, use

    git commit --amend --author=username

Joe MooreJoe Moore
Standup 07/09/2010: Jumbo Edition
edit Posted by Joe Moore on Friday July 09, 2010 at 07:50PM

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-Length header against the actual content length of the asset.
  • Did you set the Content-Type header? 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:

"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

  irb> "Mr.\tBob\tSmith".split("\t")
  => ["Mr.", "Bob", "Smith"]
  irb> "Prince\t\t".split("\t")
  => ["Prince"]

Joe MooreJoe Moore
Standup 07/07/2010: Hello, Operator
edit Posted by Joe Moore on Thursday July 08, 2010 at 08:00AM

Interesting Things

  • The << operator in Rails has_many relationships 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.

Joe MooreJoe Moore
Standup 07/06/2010
edit Posted by Joe Moore on Tuesday July 06, 2010 at 08:42PM

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!

Joe MooreJoe Moore
Standup 06/26/2009: Poor ScrewUnit...
edit Posted by Joe Moore on Friday June 26, 2009 at 01:45PM
  • JQuery Events/live + ScrewUnit = :-(. ScrewUnit swaps the DOM "out from under" the elements that Events/live is watching, which messes with ScrewUnit. Call die on 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.

Joe MooreJoe Moore
Standup 06/25/2009: return vs. next vs. break vs. yslow vs. cap
edit Posted by Joe Moore on Thursday June 25, 2009 at 01:40PM

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 return
    

    But, you can pass next and break arguments, 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.

Joe MooreJoe Moore
Standup 06/24/2009: Nginx URL Rewrite Fu?
edit Posted by Joe Moore on Wednesday June 24, 2009 at 03:34PM

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

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.

Joe MooreJoe Moore
Standup 06/23/2009: Multi-table Inheritance?
edit Posted by Joe Moore on Tuesday June 23, 2009 at 04:29PM

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?

Joe MooreJoe Moore
Standup 06/22/2009: RubyMine Tweaking
edit Posted by Joe Moore on Tuesday June 23, 2009 at 04:21PM

Interesting Things

Other articles: