I wrote this little diddy a couple of weeks ago; Since then it has sat on my desktop as a constant reminder of the little time I have to do anything with the snippets of crap that I write on a regular basis.
Due to this very reason, its probably better on the web for anyone who was interested in grabbing colours from Kuler, Adobe labs' user submitted colour... thing.
Usage
require 'kuler'
include Kuler
Kuler::recent
=> ["0E2F32", "C1E6B7", "006A69", "AAC593", "236555"]
This will give you an Array of recently posted colours' in hex values, other options are Kuler::rating and Kuler::popular
Having a poke around the Kuler site should show you that no decent API exits, however you can send some query strings to their awfully formatted RSS feed.
So, I love Hpricot because it feels like an extension of my hand.
Google (and Yahoo) have awesome human searchable queries like “people in china”.
The top most search result will show you the amount of people in china.
I quickly decided that this would be useless; however incredible to show my mad-ill flow with css selectors.
First, grab the gem from Rubyforge using:
sudo gem install google_query
Leap your ass into irb, require the gem and start screwing around
See how you get spanked by the pound
GoogleQuery::Currency.get 'AUD to GBP'
=> 1 U.S. dollar = 0.490484599 British pounds
Population in Melbourne
GoogleQuery::Population.get 'melbourne'
=> Population: 3,850,000 (Est.) (2nd)
Current time in London
GoogleQuery::Time.get 'london'
=> 2:26 PM on Monday, July 30
On the command line
bens-pb:~ ben$ gpop melbourne
=> Population: 3,850,000 (Est.) (2nd)
bens-pb:~ ben$ gtime london
=> 2:26 PM on Monday, July 30
I couldn’t resist naming it gmoney
bens-pb:~ ben$ gmoney AUD GBP
=> 1 Australian dollar = 0.424269178 British pounds
There you have it, my first gem ever.
Some queries may be broken, this could be due to google changing their search results screen or just no damn results.