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:
- script/generate performance_test homepage
- edit test/performance/homepage_test.rb
- Oh wait, I don’t have a test database set up
- ssh dev
- pg_dump -Fc devdb > db.dump
- exit
- scp dev:~/db.dump .
- Wait for 700Mb compressed dump file to download over wi-fi connection
- pg_restore -d testdb db.dump
- errors: could not access $libdir/pg_trgm, $libdir/uuid-ossp, $libdir/fuzzystrmatch, tons of no relation errors
- Search Google: what is all this stuff?
- uuid-ossp depends on http://www.ossp.org/pkg/lib/uuid/
- Download, untar, configure, make, make install
- Oops, forgot to build with postgres support
- GOTO 13 and return
- That didn’t work; GOTO 11 and return
- Oh, compiling uuid-ossp on Mac has problems: http://cvs.ossp.org/tktview?tn=81
- Try running one user’s suggestion of renaming uuid_t
rgrep -l uuid_t | grep -v ChangeLog | xargs perl -i -pe 's/uuid_t/ossp_uuid_t/g'
- rgrep: command not found
- GOTO 11 and return
- sudo port install rgrep (nope)
- Is rgrep source available? (nope)
- Ah, rgrep is part of the jed text editor
- sudo port install jed (installs slang and jed)
- GOTO 19, 20, (swear once), 21
- What was my goal again?
- locate rgrep (nope)
- locate jed (nope)
- How do you update the locate db again? GOTO 11 and return
- sudo /usr/libexec/locate.updatedb (receive warning, “the Lord will kill you for running as root”)
- Why am I doing this?
- 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)
- Let’s go over the steps again, start from the beginning
- rake test:benchmark (database structure loads with errors, but the test runs; what?!)
- “rake aborted: undefined method
`use_transactional_fixtures=' for Test::Unit::TestCase:Class"
- edit test_helper.rb: replace
Test::Unit::TestCase with ActiveSupport::TestCase
- rake test:benchmark (it works: “wall_time: 5 ms”)
- GOTO 32 and return
- Why are memory, objects, gc_runs, and gc_time all zero?
- GOTO 11 and return
- Oh, I need to patch Ruby with a GC patch
- cd /usr/local/src/ruby-1.8.6-p369
- curl http://rubyforge.org/tracker/download.php/1814/7062/17676/3291/ruby186gc.patch | patch -p0
- “8 out of 28 hunks FAILED”
- Does it compile? ./configure; make (error)
- Oh well
- GOTO 27 and return
May 14, 2009 | Comments Off |
Apparently this is beneath the Scala documentation team.
- Download the most recent stable build
$> tar zxvf scala-x.x.x.final.tgz
- Move the untarred directory to your preferred location; this will be SCALA_HOME
- Modify ~/.profile (or wherever you modify your PATH variable):
SCALA_HOME=/path/to/your/scala/directory
PATH=$SCALA_HOME/bin:$PATH
$> source ~/.profile
- 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.
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.
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.
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!