RESTful Rails. Part II. Now with more Sitepoint article goodness

My follow up RESTful Rails blog post-cum-article has been released into the wild. If you have been looking at RESTful Rails, and wondering what the hell is going on, go and have a read. If you don’t know what REST is, go and check out the earlier blog post to get up to speed.

Personal promotion over.

Freelancer Friday February

Oh how I love alliteration. Especially on a leap year. This Friday, the 29th is the next installment of everyone’s favourite open house co-working day, Freelancer Friday. At this point I would make some smart-alec remark about how Freelance Fridays would only fall on a leap every x-number of years, however, I can’t be bothered working it out (I’m sure someone out there who will) so instead I’ll point you at the wiki, where you can put your name down. Hurry, time is limited.

88 Miles now supports OAuth

Now that the OAuth standard has been finalised and the Rails plugin (as well as libraries for a number of other languages) has stablised, I thought it time to become an early adopter and add it to 88 Miles.

OAuth works like this:

  1. A developer create a third-party application (a consumer). They login to the the provider website and add their application. The website will then given them a secret key and three URLs: one to get a request token, one to get an access token and one that users can use to authorize an application.
  2. When another user decides to use the third-party application, they first need to authorize it’s use. So the application will request a Request Token by posting some data to the request token URL.
  3. Once this returns, the application should redirect, or at least point to the authorization URL. On this page, the user is asked whether they really want to give access to the third party application.
  4. If the user says yes, the provider will redirect the user back to the consumer website, or at least notify the user that the consumer has authorization (It’s a bit hard to redirect to a desktop application for example).
  5. Once the consumer is notified that it has been given access, it will then swap it’s Request Token for an Access Token.
  6. Now the consumer can freely access resources from the provider by using this Access Token.

Obviously, if a given instance of an application has a valid Access Token, it can skip steps 1-5, and just continue using the Access Token.

Although the Rails plugin is aimed at people using acts_as_authenticated, a little bit of hacking and code diving meant it was relatively easy to shoe-horn it into my custom login system. Because I wanted 88 Miles to drop-back to basic authentication if OAuth wasn’t available, I needed to work out what authentication system each request required. This can be done by:


request_proxy = OAuth::RequestProxy.proxy(request)
if(request_proxy.signature_method != nil)
  # It's an OAuth request
  if oauthenticate
    # They get access
  else
    # Denied!
  end
end

Nice and easy. I did go through and spruce up some of the authentications screens, but if you aren’t that anal, the boilerplate code from the plugin would suffice.

EEE-PC. So cool!

I’m writing this blog post using my brand-spanking Eee PC - the 7″ mini-laptop brought out by Asus. This thing is small, I’ve taken a picture of it sitting on my regular 15″ widescreen laptop, and you can see the difference:

Asus Eee Pc compared to a Toshiba M30

They have managed to squeeze a pretty decent machine in there - it is a 900Mhz Celeron (under clocked to 630Mhz) with 512Mb of RAM and 4Gb of SDD drive space, not bad considering the size and the fact it weighs less than a kilo! Even with the specs, it is suprisingly zippy - I suppose because there isn’t really anything running on it. Boot up time is less than a minute, and shutdown is even quicker.

There is an 8Gb one as well (exactly the same, just with a bigger drive), but I threw in a $25 2GB SD card and that suits me plenty.

It comes loaded with Xandros Linux, a Debian derivative, and with a little hacking, you can unlock the less than useful “simple” mode to reveal KDE. So me further hacking still, and you can pretty much load up any software that will run on Linux. I have a LAMP stack, and I nearly have Rails working (getting Rails to work on Debian is a pain at the best of times).

One of the other great things about this machine is the hackability - many people have managed to install internal USB hubs and bluetooth adapters, touch screens and even digital tv tuners behind the screen (I’m very tempted by this…).

Alas, there are a few downsides. The battery life is pretty average (mind you I’ve been spoilt by my extended 5 hour battery on my main laptop) and hibernation takes longer than shutting down, so the default action when shutting the lid is sleep, which surprisingly chews through the battery. I had it fully charged the night I got it, closed the lid and it was almost dead by morning.

The keyboard takes a little getting used to (but what do you expect). For example, I keep hitting PgUp instead of shift.

The only other annoyance (and this is probably a Linux thing more than anything else) is the WiFi doesn’t auto-connect and it doesn’t seem to like JoikuSpot, so I’m still stuck with my iPod Touch on the train.

All in all though, for a $AU500 miniature laptop, it is freaking awesome!

Perth Ruby on Rails user group. Edition 1

Matt Didcoe has finally gotten the ball rolling on a Perth Ruby on Rails user group with the inaugural meetup happening at the Silicon Beach House on Wednesday 20 February 2008 from 5:30pm. The first one will be pretty informal - no talks (although, I’m sure there will be plenty of taking).

So if you you use Rails, have tried Rails, are thinking about learning Rails or have only just heard of Rails, come along and watch me and Matt try to out geek each other :P

Details in a nutshell:

Ruby on Rails User Group Perth inaugural meetup!: 20 Feb 2008 at 5:30 until about 7:30 at the Level 2, 90 King St Perth WA

« Previous Entries