Just a Typical Rails Testing Session

June 18, 2009 | Comments Off |

Goal: Find out how fast this code runs.

Solution: Write a performance test using Rails’ built-in script/generate performance_test

Steps:

  1. script/generate performance_test homepage
  2. edit test/performance/homepage_test.rb
  3. Oh wait, I don’t have a test database set up
  4. ssh dev
  5. pg_dump -Fc devdb > db.dump
  6. exit
  7. scp dev:~/db.dump .
  8. Wait for 700Mb compressed dump file to download over wi-fi connection
  9. pg_restore -d testdb db.dump
  10. errors: could not access $libdir/pg_trgm, $libdir/uuid-ossp, $libdir/fuzzystrmatch, tons of no relation errors
  11. Search Google: what is all this stuff?
  12. uuid-ossp depends on http://www.ossp.org/pkg/lib/uuid/
  13. Download, untar, configure, make, make install
  14. Oops, forgot to build with postgres support
  15. GOTO 13 and return
  16. That didn’t work; GOTO 11 and return
  17. Oh, compiling uuid-ossp on Mac has problems: http://cvs.ossp.org/tktview?tn=81
  18. Try running one user’s suggestion of renaming uuid_t
  19. rgrep -l uuid_t | grep -v ChangeLog | xargs perl -i -pe 's/uuid_t/ossp_uuid_t/g'
  20. rgrep: command not found
  21. GOTO 11 and return
  22. sudo port install rgrep (nope)
  23. Is rgrep source available? (nope)
  24. Ah, rgrep is part of the jed text editor
  25. sudo port install jed (installs slang and jed)
  26. GOTO 19, 20, (swear once), 21
  27. What was my goal again?
  28. locate rgrep (nope)
  29. locate jed (nope)
  30. How do you update the locate db again? GOTO 11 and return
  31. sudo /usr/libexec/locate.updatedb (receive warning, “the Lord will kill you for running as root”)
  32. Why am I doing this?
  33. I know, I’ll write a funny post on how great it is to be a programmer and how 90% of your time is debugging your system or your code (because no one’s ever written about that before)
  34. Let’s go over the steps again, start from the beginning
  35. rake test:benchmark (database structure loads with errors, but the test runs; what?!)
  36. “rake aborted: undefined method `use_transactional_fixtures=' for Test::Unit::TestCase:Class"
  37. edit test_helper.rb: replace Test::Unit::TestCase with ActiveSupport::TestCase
  38. rake test:benchmark (it works: “wall_time: 5 ms”)
  39. GOTO 32 and return
  40. Why are memory, objects, gc_runs, and gc_time all zero?
  41. GOTO 11 and return
  42. Oh, I need to patch Ruby with a GC patch
  43. cd /usr/local/src/ruby-1.8.6-p369
  44. curl http://rubyforge.org/tracker/download.php/1814/7062/17676/3291/ruby186gc.patch | patch -p0
  45. “8 out of 28 hunks FAILED”
  46. Does it compile? ./configure; make (error)
  47. Oh well
  48. GOTO 27 and return

How to Install Scala on Mac

May 14, 2009 | Comments Off |

Apparently this is beneath the Scala documentation team.

  1. Download the most recent stable build
  2. $> tar zxvf scala-x.x.x.final.tgz
  3. Move the untarred directory to your preferred location; this will be SCALA_HOME
  4. Modify ~/.profile (or wherever you modify your PATH variable):
    • SCALA_HOME=/path/to/your/scala/directory
    • PATH=$SCALA_HOME/bin:$PATH
  5. $> source ~/.profile
  6. Done.

You should now be able to run the Scala interpreter ($> scala) from the command line. I've only just started with Scala so I don't know about compiling and deploying and all that good stuff yet. Hopefully that's in the documentation somewhere.

Taking What They’re Giving

April 9, 2009 | Comments Off |

’cause I’m working for a living.

Just wanted to say that I started working at PublicEarth almost three weeks ago and I’m loving it. The people are great and smart and we’re making cool stuff. That being the case, everything else is going to slow way down, including Jetrecord and posting updates here and just about everywhere. Working in a startup and having a family, I’m just too busy and I learned a long time ago that it’s okay to say no.

Of course I will do what I can and when I have things to share, I’ll write them here. I just wanted to, you know, let you know. Although, sometimes just giving yourself permission to say no actually frees you up to do more than you thought you could so maybe I should just say, “We’ll see.”

Cheers. With apologies to Huey Lewis and the News.

How to Post Your Flights to Twitter via OAuth

March 19, 2009 | Comments Off |

I just posted a writeup of the new Twitter posting feature on the Jetrecord blog, complete with a short screencast hosted on Vimeo. Hopefully you’ll get a good idea of how the OAuth handshake works from an end user perspective.

Twitter’s OAuth

March 17, 2009 | Comments Off |

Earlier today I added Twitter’s OAuth authentication process to Jetrecord, making it possible to post your logged flights to Twitter in the same manner that you can post your location via Brightkite or photos via Twitpic, the difference being that Jetrecord doesn’t store your Twitter password.

The process was surprisingly easy, thanks to the Ruby tutorial on the Twitter API wiki and the documentation from the OAuth gem. No other gems were necessary, other than the dependencies of the OAuth gem. I’ve been using the Twitter4r gem to communicate replies and handle Jetrecord followers, but even that may be unnecessary in the future.

Some day I may post a more detailed writeup with code but I just wanted to report that it was possible.

Here’s one thing not covered in the tutorials which may trip you up but it’s worth getting into your app from the beginning. Make sure you include a workflow for revoking access. What happens if users cancel their accounts on your app or with Twitter or if they just want to revoke privileges from your app? In the world of data portability and transparency, it’s not enough to facilitate the setup process. You’ve got to make it easy to cancel, too.

Thankfully, Twitter makes it really easy on their end to revoke access. The burden is on us to match that ease of use.

Cheers!