Social Media
More About This Website

My name is Wayne Robinson and I'm a web applications developer from Queensland, Australia. In August 2005 I discovered Ruby on Rails and instantly fell in love. From that point forward, Ruby on Rails has been my language of choice for new projects however, I still use PHP to maintain some legacy applications.


Open letter to the Australian NBN2 detractors

What's the point of the National Broadband Network Version 2.0 (NBN2)? It seems simple to me, the existing copper network is aging and unmaintained. What do we replace it with?

Wireless services, on the face of it, seem like a great solution. The issue is, there is only so much bandwidth (in Hz) available through the air, a figure which is dwarfed by the quantity available via copper which is dwarfed again by that available for delivery via light. 

You may say that ADSL & wireless technologies are adequate for the average user. Right now, you're probably right. 

However, this usage pattern is going to continue to change. Mid-to-high range TVs now are being released with Internet-based connectivity options bringing streamed services like YouTube, ABC iView, radio, etc to the average user. A wireless network, even if its density was increased by a significant factor, would fall over with a few thousand video streams at 400kbps each in a single regional zone. 

This assumes providers & consumers of this content are going to be content with their low-quality versions of content. How long will it be before people start streaming 720p (> 2Mbps) and 1080p (> 4Mbps) content in 3D (x2 the bandwidth) in a way that is accessible to anyone?

Again, you may say that the existing copper-based network could handle this, but speaking as someone who lives in a suburban area (the Gold Coast), the current copper-based network isn't suitable. Not only do I not qualify for ADSL2 on Telstra or other providers' networks, I am also lucky to max out my connection to 400KB/s to Australian servers - and this speaks nothing of the pitiful upstream capabilities available to me to make use of the many technologies to allow me to either communicate (video-conferencing) or work from home (requiring large amounts of uploaded data whether it be email, documents, source code or test data).

So, given the existing infrastructure is very quickly becoming inadequate for most users, what do we replace this with?

Do we build out the wireless network, increasing it's density, all the while, running out more fiber trunks to these new towers?

Do we increase the connectivity and technology used at the copper 'node', rolling out more fiber to them along the way? Not to mention increasing the density of the nodes to decrease the copper between homes and the nodes?

Do we replace the copper network with fiber? A technology that doesn't degrade at anywhere near the pace of copper cable. That continues to provide bandwidth capabilities that outstrip demand (1Gbps downstream and 100Mbps+ upstream available now for the last-mile connectivity - 40Gbps x 64 DWMP [with 100Gbps coming soon] over a single pair of fiber cables with regenerators throughout the network that aren't specific to the speeds being pumped through them using some interesting tricks of physics to increase single power). 

Sure, its a lot of money (or maybe it isn't... they haven't actually priced anything yet). But it is truly a future-proof option. We live in a world that is starting to provide access to higher-bandwidth content direct to its lay-man consumers. 

More and more bogans are going to demand access to their HD on-demand content to their living room TV and to their kids TVs whilst they download the latest magazines to their iPads, videoconferencing in HD to their relatives & friends. And they are going to do it whilst demanding that there be no slow-downs, huge usage bills and whilst their neighbours all do the same.


iPhone 4 and Telstra

I just couldn't stand the speed of iOS4 (or iOS3 for that matter) on my iPhone 3G any more.

Thankfully, my Optus plan was over, so getting a new phone was a no-brainer and, after seeing the iPhone 4 and its sexy glass and stainless-steel surfaces, how could I resist?

You see, my primary requirement for a phone, above everything else, is that it has a glass or sapphire-coated screen. When in my pocket, the screens of my phones get quite scratched up and I detest phone cases, so the screen needs to be as scratch-proof as possible. When it comes to the smart-phone market, Apple is about the only game in town when it comes to glass screens. And now, with the new iPhone 4, I get a glass back as well!

Another point of pain for me over the past two years is the Optus network. Whilst I understand that before the iPhone 4 the Optus network didn't support the 900MHz range however, given the similar issues I've had with Optus over-subscribing their network via my 3G dongle I just didn't want to chance it again. So, to cut a long story short, I ported to the Telstra network (on a plan cheaper than my original Optus plan anyway... the tribulations of being an early-adopter).

My experience with the new iPhone 4 and the Telstra network have been stellar. On the Telstra network I have connectivity everywhere, including parking garages and bathrooms (yes, eww). It's fast (much faster than the Optus network ever was) with extremely low-latency. Additionally, I can't replicate the antenna problem the iPhone 4 is meant to have with any consistency. In the worst case, I drop a couple of bars but, on the Telstra network at least, this doesn't affect call-quality or Internet connectivity.

The iPhone 4 itself is a big improvement over the iPhone 3G. In fact, it even appears faster than my iPad 3G (also on Telstra), even though it should have the same CPU. iOS4 or the 512MB of memory might be contributing to this speed-boost. Especially applications that support "multi-tasking" well like the Facebook and Twitteriffic applications. It's also nice to get an extra 20-30% out of the battery during the day and I haven't managed to run it flat yet.

Anyway, I would highly recommend both the iPhone 4 and Telstra networks to anyone coming out of their contracts. I know the new Optus plan is very temping however, do you really want to put yourself through the same crap again for the next two years for the sake of $20-30 per month?


Selecting an element/object in an IFRAME

I recently needed to get an object from a child IFRAME from its parent. Without using any helper libraries, the easiest way to do this is with the following:


A JRuby/Rails Message Driven Bean

A while ago I found this tutorial on getting an EJB message-driven bean up and running utilising JRuby and Rails at This website now appears to be down so I am reproducing it here for posterity (and my own reference).

I'm building a system which receives messages from a larger application platform and records the details in its local database. It's built with Rails and JRuby, with Apache ActiveMQ as the message broker. Using JRuby lets me use ActiveMQ's native JMS-based client, rather than speaking STOMP to the broker (as our larger platform does on the other end of the queue). My deployment platform is Glassfish, and I'm deploying the Rails app to it in the usual way with Warbler.

To begin with, I wrote a standalone script to subscribe to the JMS queue, based on the suggestion to use JMS rather than ActiveMessaging. This works well, and is very simple to deploy for development. As Shane points out, it's just a literal translation from Java to (J)Ruby. A problem is that even when configured to use a failover transport to a pair of message brokers, the script will frequently exit and need restarting. Not only that, but starting the script as a separate process means I've got two JVMs running - one for Glassfish and one for the JRuby script, and they can't share a common JDBC connection pool, so there's more to manage there.

Finally, I'd have to manage any concurrency required myself - the script is resolutely single-threaded, and if I need multiple threads to saturate the hardware, I'd need to write the thread management code as part of the script.

Since I'm already using an app server for the web part of the system, the answer seems to be to move the script into Glassfish as a message-driven Bean.

There are a few issues to be solved: I only want a single copy of the Rails environment, and I need to arrange for the relevant parts of our application to be packaged so it can be correctly deployed with the bean.

The upside is that with Rails 2.2, I can share that Rails environment among as many threads as I need, without having to synchronize access to the app - given a JDBC connection pool, Glassfish will start many bean instances to handle incoming messages.

Unfortunately there doesn't seem to be anything like Warbler to help out with packaging the app into an MDB, so it's all rather manual. Here's what I needed to do to set this up:

  • Provide an app entry point which would accept a message, and run the required business logic in ruby
  • Create a standard J2EE Message-driven Bean in Java, and hook it to an external ActiveMQ instance
  • Spin up a single Rails instance inside the container
  • Arrange for the message receipt handler to call the app entry point with the contents of the message

App entry point for messaging

This is a class method on the model the app will create as a result of receiving the message. My messages are simple YAML strings, and this method accepts that YAML directly.

That means I'm converting to a Ruby data structure from YAML in Ruby code, and it might be better to make sure it's done in Java - the messages are small enough that this isn't a big deal though.

Create an MDB

I'm using NetBeans for this, simply because of its integration with Glassfish. Everything is done with Java 5 annotations, bar the selection of activemq instead of the built in broker (which doesn't have native STOMP support).

All that's needed beyond the standard Bean that NetBeans sets up is this stanza in sun-ejb-jar.xml:

assuming the ActiveMQ RA is deployed in Glassfish as "activemq". This configuration is taken from this forum post

Rails Instance

I only want to start one Rails instance to be shared among all the bean instances. I'll create a RailsRuntime class, which loads JRuby, initialises Rails and provides a "string eval" method, and then another class, RailsRuntimeSingleton, to maintain that single instance.

Here's the RailsRuntime class:

There's a hardcoded path to the JRuby home directory here, which isn't ideal - really I should just include a jruby-complete jar but I don't have the infrastructure in place yet to also include all the required gems, so I'm relying on that fixed path for now.

I do bundle up the Rails app into the jar, and so there's a fixed path available to environment.rb. Production mode is also set here.

The singleton class is very simple. A static property is guaranteed to be initialised only once, so this avoids the need for any synchronization around the RailsRuntime setup.

Call the app when we receive a message

Now I've got a Rails instance spun up, and messages coming into the bean, it's time to plug it all together. Here's the bean's onMessage method and the hook into the Rails app:

Before Rails 2.2, I needed to synchronize around the eval() method, to serialise access to Rails. Now that's not necessary, and I can allow the container to spawn as many threads as I have connections available in the JDBC pool.

My test environment is a simple, single-threaded Perl STOMP sender running flat out to an ActiveMQ instance, plus the bean in Glassfish all on a Macbook Pro. When the bean runs serialized, the receiver isn't able to keep up and a backlog of messages builds up. Simply removing the synchronized block means the receiver can keep up with the sender easily.

Next steps

There's a lot to get right with this setup even leaving aside the dependency on the external JRuby.

  • The message queue configuration in Java in the Bean class
  • The external message broker configuration in sun-ejb-jar.xml
  • Packaging up Rails and the application as part of the Bean

More work is required to include jruby-complete.jar and remove that external dependency. Beyond that, making the Java parts generic, allowing configuration in Ruby and building outside of the IDE in the style of Warbler seems to be the way to go.


yUML makes UML fun?

Thankfully, due to the way I work and the 'clients' I work for I have few requirements to diagramme the applications I work on. However, there is the odd occassion where I need to create documentation for less (or traditionally) technically-minded people.

This usually results in me pulling out OmniGraffle or Visio and fighting with GUI-based design tools for presentation that really just represents fairly simple relationships, but I think I've found an answer.

yUML is a UML digramming tool that uses a simple, text-base DSL to describe your diagrammes, rather than fighting with mice and grids to get everything to fit together nicely.

For example, the below diagramme is generated with this very simple code:


If you want a simple, command line script to generate these images, check out the yUML Me Gem (although you will have to install Gemcutter first).

yUML can also make class and activity diagrammes, so check it out today.


Xero is greater than the rest

Well, that title definitely sounds like a marketing introduction but I swear, I have no affiliation with Xero apart from thinking that they have some of the best SME accounting software that I've come across.

Being web-based, getting transaction feeds directly from banks, having multi-currency support, simple expense claims, fixed-asset register and most importantly, an API for developers; Xero is highly integrated and, most importantly (and rarely), is actually fun to use.

For the last week or so I have been hacking away at the Ruby xero_gateway library project started by Tim Connor and have been having quite a lot of fun. It's great to take a break from customer-facing software for a while and developing code that will be used by other developers.

If you want to check out Xero, head on over to their main site or their developer's site.

Now, shameless plug, if you are an SME and looking to get some extra efficiency by integrating your current business processes/software with your accounting package, give me a shout and I'm sure to be able to help you get more (time/information/money) from less.



Word/Excel HTTP POST

A little essoteric, but I recently needed to post some merge fields on a Word application form to a server to save on rekeying when the application form is completed.

Thankfully, VBA in Word can utilise any of the built-in Windows libraries and therefore the above can be easily accomplished using the MSXML2 library.

Some sample code for posting data to a HTTP server in VBA:

Private Sub PostData()

Set http = CreateObject("MSXML2.ServerXMLHTTP")
http.Open "POST", "", False
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.Send "field1=a&field2=b"

MsgBox http.responseText

End Sub