Nate Clark's blog



Nate ClarkNate Clark
Standup 9/15/2009: Hashing a String, Nginx Security Patch
edit Posted by Nate Clark on Tuesday September 15, 2009 at 09:13AM

Interesting Things

  • String#hash does not always produce the same hash on different machines and/or different architectures. Don't use the hash of a string across machines to identify it.

  • Nginx has released a security patch to fix a remote execution security vulnerability.

Ask For Help

"Anybody use an off-the-shelf State Machine plugin for Rails? Which one?"

Our team recommends using the rubyist-aasm gem from Github. It works well for our current applications, and it appears to be the most actively developed and frequently updated. This gem is the successor to the acts_as_state_machine plugin.

Interesting Things

Don't use comments in ERB. Writing comments (or any '#' character, for that matter) inside an ERB evaluation block was never right, but some versions of Ruby 1.8.6 allowed it anyway. This is trouble if you upgrade to Ruby 1.8.7 (for example, when upgrading to Snow Leopard) which does not allow comments within ERB.

This is wrong:

<%= link_to "/", home_path #link to the homepage %>

If you really need comments in ERB, do it this way:

<%# link to the homepage %>  
<%= link_to "/", home_path %>

test-unit 2.0.3 breaks RSpec. If you upgrade to test-unit 2.0.3, you may notice that your RSpec specs no longer run. Roll back to test-unit < 2.0 (or remove the test-unit gem completely) and you should be back in business.

RubyMine 1.5 early release is available for trying out. Preliminary reports from one Pivot are positive. If you are using Snow Leopard, which ships with Java 1.6, you'll need to do this hack to get it to run

Nate ClarkNate Clark
Standup 4/24/2009: libxml-ruby on Windows, pivotal-apdex gem
edit Posted by Nate Clark on Friday April 24, 2009 at 04:18PM

Interesting Things

  • libxml-ruby doesn't work on Windows (surprise, surprise!). One of our teams discovered that the version of Ruby on Windows has a XML::Parser class, but it is NOT libxml-ruby even if you try to install the gem. A workaround is to rename or delete the libxml.so file, and then you can use the real XML::Parser.

  • A few Pivots just whipped up a pivotal-apdex gem that allows you to calculate your application's Apdex performance index via a simple command line tool by parsing Nginx or Apache server logs. Apdex is an emerging standard in measuring application performance. We were inspired by Lew Cirne, CEO of New Relic, who gave a talk about Apdex a few weeks ago at Pivotal's office.

Nate ClarkNate Clark
Standup 4/23/2009: helper methods in view tests, mecached client
edit Posted by Nate Clark on Thursday April 23, 2009 at 04:19PM

Interesting Things

  • memcache-client is broken in the sense that if it fails to connect to your memcached server, it will automatically try a new server. It does this 20 times. Not what one would expect. You can turn off this weird behavior by setting :failover => false

Ask For Help

  • When writing view specs, is there a better way to include your helpers if all helpers are not automatically included in ApplicationController? Some suggestions from the crowd: mock the helpers (test helpers separately), or reopen the template and define helpers there directly.

Interesting Things

  • Rubymine, just released a new beta revision 856. So far it "seems to work".

  • When using Object-Mother patterns for creating objects in tests (i.e. Fixjour, FactoryGirl) one gotcha that caused one of our teams some pain was when inadvertently setting an object and object_id for the same association. For example, setting person = @nate and person_id = @david.id in the same object creation will cause really weird problems. Our team debugged and solved this by validating object creation ... essentially writing tests for your test objects.

  • Try mapping SHIFT + Space to the underscore character, and save your underscore finger from unnecessary travel.

Interesting Things

  • Webrat, the acceptance testing framework that is all the rage right now, has a neat lesser-known save_and_open_page command that is helpful for debugging when your tests go wrong. Essentially, this command dumps the current HTML to the browser and lets you inspect the state of the page visually at any point within your test.

  • Rubymine, Pivotal's favorite Ruby IDE, doesn't really support UTF8. You can type UTF8 characters seemingly fine ... but somewhere along the way it doesn't save properly. Apparently this has been an issue with Rubymine for quite some time. Frustrating.

Ask for Help

  • Anyone know a reliable way of CSS regression testing? When we are refactoring CSS or markup, it would be great if there was an automated way to detect visual breakages. Some ideas floating around involve taking screenshots through Webkit's API and comparing them pixel by pixel. This kind of thing has been attempted twice by Pivots without much success. Anybody have a good solution?

Interesting Things

  • Many thanks to Pivot Josh Susser for his hard work co-coordinating this past weekend's Golden Gate Ruby Conference. We also want to thank our Live Blogging team: Chad, Ryan, Zach, and David -- who all did an excellent job of documenting the event. We also recorded videos of every talk, which will be posted to Talks within a week or so.

  • Something to be aware of if you are running your production app on EngineYard: Because of their shared disk setup, running disk intensive jobs on your staging environment may affect the performance of your production environment on the same slice. One of our teams ran into severe slowness on production due to tasks running on staging. This problem isn't immediately apparent because of the way the EY storage system is well abstracted for each environment. Submit a ticket to EY support for more details if this is a problem for you.

Ask for Help