my recent reads..

Using Twitter OAuth with Rails + sample

I've been using rails with the Twitter REST API of late, using the oauth gem as the base. It works well, but keeping up with the API changes can be a challenge!

In the recent update to OAuth 1.0a, there were two critical changes required:

Web-apps should specify the oauth_callback


Through trial-and-error, I found that if you don't explicitly specify the oauth_callback when going through the authorization process, twitter will halt at the PIN page (behaving as if you are using a client application). That's easily fixed..
request_token = consumer.get_request_token( :oauth_callback => TWOAUTH_CALLBACK )
session[:request_token] = request_token.token
session[:request_token_secret] = request_token.secret
# Send to twitter.com to authorize
redirect_to request_token.authorize_url

NB: the root cause is that oauth 0.3.5 sets "oob" as the oauth_callback if you don't explicitly set it. This triggers the twitter desktop PIN flow.

Include the oauth_verifier when exchanging the request token for an access token


Next, the major change in 1.0a was to add an oauth_verifier parameter. Twitter sends this back to you after the user has authorized access, and you need to include this parameter when exchanging the request token for an access token.
request_token = OAuth::RequestToken.new(consumer, session[:request_token], session[:request_token_secret])
access_token = request_token.get_access_token( :oauth_verifier => params[:oauth_verifier] )


An example application


I've created a minimalist application that demonstrates the twitter API with OAuth 1.0a in rails. I've set this up to run at heroku.

The source is at github for all to share: http://github.com/tardate/rails-twitter-oauth-sample/tree/master

And there's a running demo site at http://rails-twitter-oauth-sample.heroku.com.
read more and comment..

Running Heroku on Windows

What! Do rails development on Windows?

I've raved about heroku before, and it still roasts my bacon.

In recent months, there's been a bit of a switcheroo - first the migration to herokugarden, which retains all the original online editing and hosting. The perfect solution for hobby projects or prototypes. Now I'm migrating back to heroku itself, which has become their solid production hosting facility for rails applications.

As Sarah Mei reported, the heroku gem (used to create and manage your heroku application instances) had problems running under Windows, due to gem dependencies that do some decidely un-Windows things.

There is now an updated heroku gem (1.0) that I just tested out, and am happy to say it is now working fine under Windows. There are some dependent gems and it can be required to make sure you get the version that specifically supports windows. That used to include json, but at the moment the main version-pegged gem I'm using is sqlite3-ruby (at 1.2.3 instead of the head at 1.2.4)

$ gem install sqlite3-ruby -v 1.2.3
$ gem install heroku
Successfully installed heroku-1.0
1 gem installed
Installing ri documentation for heroku-1.0...
Installing RDoc documentation for heroku-1.0...

Perfect! Testing it out..

$ rails myapp
$ cd myapp
$ git init
$ git add .
$ git commit -m "init"
$ heroku create myapp
Created http://myapp.heroku.com/ | git@heroku.com:myapp.git
Git remote heroku added
$ git push heroku master
Enter passphrase for key '/d/MyDocs/My Dropbox/Config/Security/ssh/id_rsa':
Counting objects: 65, done.
Compressing objects: 100% (58/58), done.
Writing objects: 100% (65/65), 80.48 KiB, done.
Total 65 (delta 14), reused 0 (delta 0)

-----> Heroku receiving push
-----> Rails app detected
Compiled slug size is 80K

-----> Launching...... done
App deployed to Heroku

To git@heroku.com:myapp.git
* [new branch] master -> master

Sarah gave the hint as to how to fix the older heroku gem (0.9.1), and has a forked version on github. A few people collaborated to fix up the code there so no longer any script editing required (basically to remove any dependency on taps for the gem build). Installing Sarah's version involved cloning the repository, building the gem and performing the local gem installation:

$ git clone git://github.com/sarahmei/heroku.git
$ cd heroku
$ gem build Rakefile
$ gem install heroku

read more and comment..

Sex & Drugs & Rock & Roll

Heard that the movie Sex & Drugs & Rock & Rollhas just started production. Probably shouldn't hold my breath, but I can't wait to see it.

It's based on the life story of Ian Dury, IMHO the best lyricist/poet who ever got a gig. And Laughter was the best album I ever bought as a teenager. I still have the cassette tape at home, even though the ferrite oxide has long rusted and worn away.

In what could turn out to be a masterful bit of casting, they have Andy Serkis playing Dury in the movie. I can well imagine Serkis doing a great Dury. Having done mega-blockbusters with Peter Jackson, Andy seems to be picking up quite a number of intriguing, not-so-mainstream roles. I guess he can afford to;-)

I also realize there's an obscure connection between Dury and Serkis. Dury is well known for having created and performed a version of the Bus Driver's Prayer, which ends with the line..

For Iver and Iver ... Crouch End

Which is - at least according to wikipedia - where Serkis now lives. So Andy is picking up from where our dear departed Ian Dury (RIP) left off...

OK, so that's a stretch. Time to reminisce over the Blockheads and wait for the movie to come out..


read more and comment..

Oh boy, got to get one ...Zimplistic Rotimatic

This sounds great, and congrats to the winners of Start-Up@Singapore 2009 for the Zimplistic Rotimatic.

But I want to know ... can it also do the perfect prata?

Chapati or roti is a staple in Indian diet. Yet it can take over 30 minutes to prepare a simple meal of roti. Repeating this at least three times every day is a cumbersome process.

Zimplistic’s invention is an elegant automatic roti-maker set to be the rice cooker of India. With a push of a button, the roti-maker can mix, make and bake rotis from just the addition of water and flour to the machine.

Zimplistic’s founder Pranoti Nagarkar Israni is no stranger to product design. Only in her 20s, she left her job at a leading electronic manufacturer to start-up on her own. She graduated from NUS and majored in mechanical engineering. Zimplistic aims to go one step further by developing more innovations such as the roti-maker, to make every meal more convenient to make and consume.

read more and comment..