Monday, September 22, 2008

Rails with NO Fixtures?

I have a Rails project, and I created a Country model. I added the basic details of Norway to the countries.yml fixture.
 code: NO
 name: Norway
I 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')
Agreed, 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
Apparently 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...
 code: "NO"
 name: Norway
I 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?

Tuesday, September 16, 2008

Phantom Butterlies OSX Screensaver

I've had the Phantom Butterflies screensaver installed for a while now. It's a very attractive screen saver, isn't too distracting, and my 14 month old daughter Mishca loves it. She has a good shot at saying, "Butterflies!". I poked around a bit more and found that White Knight Logic has a few other nice screen savers that are also worth downloading. Whats your favorite OSX screen saver?

Thursday, September 4, 2008

My Psychic Inner Child

Damn my Psychic Inner Child, he (or is it a she??!) let me down once again. We had a great meeting with a client a few days ago, and we're busily putting together an estimate to do the project. Yet we are still raising questions!! Why didn't my psychic inner child fast forward a few days and see what we had dug up in the analysis, and then whisper them to me that I needed to ask these questions in the meeting? Big let down this time, psychic inner child.

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 .

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?

You might want to read this how this Bumer Sticker, a Linked-In application, that is serving 1 billion page views per month. From the article... "Ruby on Rails is frequently criticized for lacking the ability to scale. While the road to a billion page views per month has certainly had some potholes, Bumper Sticker has clearly demonstrated that the Rails platform can scale quite well, so as long as the team behind it understands that many of the bottlenecks are exactly those faced by developers on any other database-driven web platform." Joyent also blogged about this. How many Rails application have you developed, then found scaling the app was fast, relatively simple... not to mention cheap? How many Java web applications have you developed, then found scaling the app was difficult, slower, and expensive? You probably aren't even aware of the extra work you're going through here if you've never tried to scale a Rails app. You can take your pick of frameworks, I'm not citing any specific Java web application frameworks here. I'm not directly comparing Rails to Java, but Rails to insert-your-java-framework-here. I've been working with Java for a long time, and it still has it's place. But I think Rails is eating Java's lunch in a lot of areas these days, particularly in the web application and web services area.

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.


# sudo launchctl stop org.macports.postgresql82-server


# 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

Today I sat down with one of my team while he logged into a linux server to perform some administration tasks.

After ssh'ing to the machine, the first command entered was:

# sudo bash


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?

Sunday, June 22, 2008

Re-Architecting J2EE with REST

I'm investigating re-architecting parts of an existing client's application. I prefer not to re-architect existing applications of non-trivial size but the current application has outgrown its current lack of architecture. Because of it's size (not to mention the development environment being used!), development work on the application runs at a snails pace, fear of breaking code is high, and deployment is a long, painful process. The state of the project is at least partly my responsibility, as I have worked with this project in the past. My previous attempts to get client buy-in on improving the architecture failed. I am planning to use other methods and tactics to try and illustrate to the client just what they are getting out of this. But I digress... I have become a big a fan of REST over the last few years with success on various projects built using REST. I looked at the Restlet project about a 6-9 months ago, but the documentation was inadequate for me at that stage. This isn't surprising because Restlet was quite early in the development at that time, so I'm not having a go at the Restlet team here in any way, they've been doing some really good work with their REST implementation. But on having the need for REST in Java again, I've taken another look at Restlet. The documentation has improved a lot. The examples, tutorials and explanations of the Restlet implementation are now at a stage where you can quickly evaluate Restlet, and decide if it can work for you. I would of course rather do all of this in Ruby or Python, but with the existing application in Java/J2EE the Restlet implementation of REST will mean the current team can still use Java, and means I have one less hurdle to try and negotiate. As I have experienced on other large applications, when you move components out into discreet services you end up with a nice SOA application that naturally enforces separation of layers. I am expecting to see large improvements in development speed, quality of code, and deployment. I'll blog about how the proof of concept goes in a later post.

Thursday, June 19, 2008

MacBook Pro Trackpad Gestures

Sometimes its like a light bulb just got switched on in your head, and you have a strong suspicion you were the only one still floundering around in the dark :) I was just reading some pages at the memcached site using my MacBook Pro, when I accidentally dragged 2 fingers down the trackpad. And what do you know... the page scrolled! I didn't realise that using two fingers on the trackpad was a gesture for scrolling. After a little investigation theres a whole bunch of gesture options under the Mouse and Keyboard options in System Preferences.

ARDAgent Local Explot on OSX

Ouch... Nice one. # osascript -e 'tell app "ARDAgent" to do shell script "whoami"'; root Hopefully this is patched soon. I'm sure there are some apps out there that could make creative use of this hole. This is discussed at length on Slashdot at, "Mac OS X Root Escalation Through AppleScript".

Wednesday, June 18, 2008

Firefox 3.0 is Shiny

Firefox 3.0 final was released today, so I thought I'd better take a look while it's still shiny :) I'm actually writing this post using Firefox 3.0 and all seems sweet. The look fits well with the OSX Leopard. After many years of running Linux desktops I really enjoy a unified GUI. Looks aren't everything of course. I really like the 'Awesome Bar', which is an impressive improvement over the Location Bar in Firefox 2. The drop down of suggested URLs is feature rich and should prove really useful. Think of the Awesome Bar as the Location Bar on steroids. Zooming in is also really nice, more like a true zoom than anything I've used before other than my iPod Touch. I switch between Firefox and Safari depending on my mood and the way the wind is blowing, but I always enjoy something new so I'm sure I'll favour FF 3.0 for at least a little while so I can get a feel for what it really has to offer over Firefox 2. There is a cool download counter at . For posterity I've captured a video of the counter in action. Oh yeah, and apparently the IE team sent the Firefox team a cake!

Tuesday, June 17, 2008

Back in Singapore... Again!

I'm back in Singapore again! My wife and I returned home to Australia in 2007, but both Australia and Singapore both have their plus sides, and after returning we eventually decided that Singapore is be a better place for us to be in the long run. We're really looking forward to making Singapore home again :) I accepted a position with the company I used to work for here previously, Global IT Creations. I'm quite excited about working with this company again, as we do some really interesting work for our clients. There isn't one other company I've previously worked for that I would return to work with, but I can easily make an exception for GITC. I really want to blog about bits of code I write and play with, and this will be the outlet for those experiments. At the moment I'm mostly using Ruby and Ruby on Rails, but I've had lots of development experience using Java/J2EE, Python and PHP in the past. I've also recently been toying with Flash after avoiding it for so long, and I've really taken a shine to ActionScript 3. Lets see what comes out of it all.