John Pignata's blog



John PignataJohn Pignata
NYC Standup Roundup - Week of 12/7
edit Posted by John Pignata on Friday December 11, 2009 at 02:34PM

Interesting

   >> false.blank?
   => true
  • blank? first checks to see if a method responds to empty? and if not evaluates !self which in false's case will always be true. This caused a pair a bit of confusion when trying to validate the completeness of a form that had a checkbox.

  • Railscamp — an all-weekend hackfest — is being held in Rhode Island in March of next year.

  • All API keys were recently reset on Gemcutter due to a security bugfix - in order to publish gems you'll need to update your gemcutter gem to regenerate your key.

  • Postgres will return an error if you attempt to ORDER BY columns that are not specified in the SELECT. This is painful in cases where you're using DISTINCT with any kind of JOIN.

  • One team cut their deployment down from 7 minutes to 30 seconds with a few cap recipe tweaks. Most of the time was saved by symlinking gem bundler-related directories to prevent bundler from building native gems on each deploy and by only running database migrations when anything in db/migrate had changed.

  • When using the inherited hook for ActiveRecord::Base, beware of tables that have their name overriden by set_table_name. The inherited hook will execute prior to that statement being evaluated which can cause strange results.

  • Getting Selenium to work with Snow Leopard involves some manual file renaming hackery — for anybody struggling with this there are a couple of posts out there to walk you through the process.

John PignataJohn Pignata
NYC Standup Roundup - Week of 11/30
edit Posted by John Pignata on Friday December 04, 2009 at 09:06AM

Help

RubyMine and gem bundler don't seem to get along - RubyMine complains that bundled gems aren't attached but these gems aren't available when we try to attach them. Any ideas?

  1. RubyMine uses your gem path so you'll be able to attach to the gem if you add your gem bundler path to your ~/.gemrc file

  2. There's an option to disable this nagging alert in the preferences.

Is there a good Rails plugin skeleton/template out there?

Know of one? Let us know in the comments.

Interesting

  • Don't use sleep 1 or such in before blocks in rspec if you need to ensure a delay between two events. A before block is ran between all nested contexts so you're probably incurring a larger penalty. Instead, you should stub Time.now.

  • One team implemented git commit hooks to facilitate communication - on rebase or merge new messages from a text file in the project root are displayed to alert other pairs to changes such as gem upgrades, noteworthy database changes, etc.

John PignataJohn Pignata
NYC Standup Roundup - Thanksgiving Week
edit Posted by John Pignata on Wednesday November 25, 2009 at 12:09PM

Help

Is there a way to ensure at_exit will always be ran regardless of how the program exits without wrapping all code in an ensure block?

Ideas included:

  1. Use a runner class to execute the program and wrap that in an ensure block.

  2. trap("EXIT") { block } should get triggered no matter how the program terminates (sigint, exception, etc)

What are the likely causes of RangeError exceptions during test runs?

<RangeError: 0x23513ec is recycled object>
  1. This is generally caused by C extensions.

  2. Their appearance coincided with a Darwin ports update — perhaps you're running native gems against different versions of libraries than they were compiled against.

Are there any techniques out there to take a series of bytes and run some heuristics on them to determine the likely encoding of the string it represents?

Anybody out there have any ideas? Please let us know in the comments!

Interesting

  • Passing :multiple => false or nil to the select helpers causes unpredictable results — the helper still builds input element names assuming an array of items will be passed back. The helper checks only that the key is present in the options hash and not the value which means if you need to conditionally render a multiple, you'll have to make sure you don't specify the :multiple key at all.

  • Using $('textarea').val() causes unpredictable results as a textarea doesn't keep its data in a value attribute. Use text()) instead.

  • IE 7 and 8 (and more than likely 6) seem to have a problem with jQuery selectors that match links based upon the href attribute — changing the href of the matched elements does not get reflected in the document.

  • From a Blabs comment: Taps is a Sinatra web service from Heroku that's used to move data from one database to another. It transmits data as serialized arrays and loads them using ActiveRecord so it's DB agnostic.

  • Disabling a label via jQuery will not disable the input that it refers to in the for attribute as the label is not a container.

Happy Thanksgiving!