exchange_rate = YahooCurrency.get_rate!("JPY", "USD") exchange_rate.from #=> "JPY" exchange_rate.to #=> "USD" exchange_rate.rate #=> 0.0111 exchange_rate.timestamp #=> Wed Feb 11 22:20:00 +0800 2009Get the source or the gem from http://github.com/scottbarr/yahoo_currency/tree/master Hopefully this will be the first of many projects that GITC releases as Open Source.
Code, aimless meanderings and occasional outbursts from an Australian expatriate living in Singapore.
Sunday, February 15, 2009
YahooCurrency Gem
Thursday, February 12, 2009
Horror Movie Code
Monday, September 22, 2008
Rails with NO Fixtures?
norway: code: NO name: NorwayI added a unit test to make sure I could get Norway by it's country code, which is NO
def test_find_by_code assert_equal countries(:norway), Country.find_by_code('NO') endAgreed, I probably don't need a unit test for this, but this should have worked, but it was failing with the following message.
Country id: 318845244, code: "1", name: "Norway" expected but was nilApparently NO in the yaml file is interpreted as a 0 (zero). To prove the theory I changed the code of norway to YES. The unit test failed, and indicated that the model it expected should have had code: "1". Changing countries.yml to be...
norway: code: "NO" name: NorwayI personally really like fixtures and the nice features they bring in, but sometimes they can catch you out. I'm sure it's not a bug, I've just never encountered this before. Ever found anything strange in your fixtures?
Sunday, August 31, 2008
View source code for iPhone RSS feed
I tried to view the Slashdot RSS feed on my iPod Touch, but instead of an RSS feed I was redirected to a specially formatted feed for iPhones. Very nice!
The iPhone specific URL is http://reader.mac.com/mobile/v1/http://rss.slashdot.org/Slashdot/slashdot .
I was curious to about the source code of the page, really just to see if there was any interesting markup. So I tried to view the URL in Firefox... no dice. I was shown a page saying, "This Application Is Viewable Only On iPhone".
Hmm... it was time to cheat a little then. I googled around for the User Agent that the iPhone sends, opened a terminal and entered...
Thursday, August 14, 2008
Ruby on Rails doesn't scale you say?
Thursday, August 7, 2008
Stop and start PostgreSQL on OSX
To manually stop or start a PostgreSQL 8.2 server that was installed via macports, use the following commands.
Stop
# sudo launchctl stop org.macports.postgresql82-server
Start
# sudo launchctl start org.macports.postgresql82-server
Obviously this will also work for PostgreSQL 8.3 or 8.4 if you change the commands slightly.
I prefer the approach Linux distros have generally taken for service management, where all services are listed under the /etc/init.d diretory. To me /etc/init.d/postgresql-8.2 is easier, and you can use command completion to type it.
Friday, July 18, 2008
sudo bash > /dev/evil
After ssh'ing to the machine, the first command entered was:
# sudo bash
Ouch!
Most of the time when we log into a remote server we are intending to perform admin tasks, but not every command needs to be executed as root. Executing "sudo bash" defeats the whole purpose of using sudo to begin with.
Sudo helps provide elevated privileges to multiple users of a machine. I don't want to limit the sudo rights on these machines as they are development and integration machines and many services are experimented with, configured, stopped, started, and generally played around with. I just want the team to treat root with respect.
Am I being picky about this?
What do you think?