A Ruby interface to the GatherContent API

GatherContent is an awesome tool for planning, structuring and collaborating on web content (they have a short video demo).

They have a read-only API, but only a couple of implementations, so here is mine, in Ruby.

The API is read-only and HTTP POST-based, and so I use HTTParty to manage that side of things, and method_missing to emulate the relevant API calls, and then Hashie to convert the returned Hash into an object. It’s very simple, so give it a try.

I have forked Charbot Green

About a year ago Libby Miller wrote Charbot Green, a BBC Radio 4 announcement bot for Twitter. It’s written in JRuby, uses the H2 database and the source code is in SVN here.

A screenshot of CharbotGreen on Twitter

It’s a really great app and I thought I’d have a play, but half-way through the install I realised that setting up an H2 DB server was a step too far, so instead I rewrote it to be a pure Ruby app using the SQLite3 database. Using SQLite3 keeps it a self-contained app in a single directory without the need to run a database server.

You can get the code from GitHub here.

My small changelist looks like this:

  • H2 replaced by SQLite3
  • links to iPlayer use the short form of the URL
  • if available, the subtitle, such as episode number is displayed
  • now a pure ruby app!

I haven’t tested it very hard, just run it up a couple of times, so please do let me know of bugs or feel free to go fork it yourself!

Ruby and memcached in Bristol

I have rather hastily promised to do a talk about memcached at the Bristol Ruby User Group meetup on Thursday evening (we’ll start after 6pm at the Jiva offices, see the map, no need to know about ruby or memcached in advance!).

As ever, this event is on Upcoming.

There’s a pub next door which I plan on visiting both before and afterwards, and I also want someone to guide me through the capabilities of Passenger (specifically, with nginx) as well as showing me why all my code is horribly wrong. Come along!

Bristol Ruby User Group

Tonight was the third Bristol Ruby User Group meeting, but the first with room for laptops and a projector (thanks to petef for organising and The Watershed for giving us somewhere to meet for free!).

Bristol Ruby User Group

About ten people showed up and we took some time to settle in because lots of us hadn’t met before, we ranged from total novices to professional Ruby programmers (I sit very close to the bottom rung in that ladder!) and didn’t have any concrete plans on what we were going to be doing.

In the end we decided to set up a GitHub repo for any work we might do in other sessions (which you can see here) so spent some time getting that up and running for everyone and then naturally gravitated into two main groups: one getting Jekyll integrated so that we could have a website, and another doing some introductory Ruby work.

(I’m afraid to say that I’d gone beyond tired and into slightly manic which was alarming for me, let alone everyone else, so I worry slightly about the impression on others but hope I can ascribe it to the beer.)

It was good to hear Steve from Beef praising Sinatra, since I’ve written a couple of apps based on it the last few weeks and it seems like the perfect way of writing lightweight web applications in Ruby.

In conclusion, there is an Upcoming Group, a mailing list and of course the GitHub repository we set up and the associated website/blog! We meet on the third Thursday of every month so if you’re local and interested in programming, come along!

Sinatra from scratch

I wrote a small Ruby app the other day which was chucking out JSON which was being parsed by some PHP.

So I thought I’d convert it to all-Ruby using Sinatra (my first real attempt at a Ruby web framework that’s not Hello World).

Installation was harder than expected on my clean Ubuntu box, but for reference:

gem install 1.8-dev
gem install mongrel
gem install rack --version 0.4
gem install sinatra

It was the third line which really caught me out – Sinatra is bound to version 0.4 of Rack, even though it’s at 0.9.1 right now!

Everything seems fine so far, I’ll post a URL if I ever get it running!

update: Sinatra 0.9 was released two days after I wrote this, and it is now dependent on Rack 0.9.1 so the “–version 0.4” is no longer needed

Java makes me passionate


I really like Java, it’s a fundamentally great language. Verbose at times, but great.

However, web application development in Java is painful. Additionally, the compilation and deployment of Java webapps completely suck. I mean, they’re terrible.

I dread to think how many frameworks exist in Java to ease web app development – each one claiming it’s the best and will solve all your woes, yet none come anywhere close to the ease of development in Rails, Django, or any of the PHP frameworks.

I remember being introduced to JSF at ApacheCon Europe 2006. I came back declaring that we would never use JSF for our internally-developed applications. When there was masses of hype, and everyone was claiming JSF was amazing, I got a few questions in the office.

Two years on and there’s finally some acceptance that JSF 1.0 was horrible for developing web applications, with some defensively claiming that JSF 2.0 will solve all the problems. Right, because that always works.

See the recent discussion:

Anyway this means I try and keep a close eye on things like JRuby and Grails but we’ve been pretty reluctant to use them at work because we tend to have large monolithic applications which require maintenance by different people over time which means code homogenisation is good.

To this end, our last couple of projects have been in Struts2+Spring+JPA+Hibernate. This is a nice combination, with a number of well-understood components working well together, especially since we’ve used the Zero Configuration plugin which allows us to drop tens of lines of XML in favour of a few lines of annotations. The Zero Configuration stuff is as buggy as hell and there’s no concrete date for Struts 2.1.2 where it should be fixed, but that’s by-the-by. For me, the fact that we haven’t had to be editing XML almost makes it worth it 😉 Also, Struts2 is highly testable which fits in nicely with our existing testing process.

But when you have a framework you’re (mostly) happy with for development, it highlights the other pain points you may have. For us, this was definitely the deploy/test cycle. We were already using TDD in the compile cycle so there’s a level of confidence about the backend code – tests always run after a successful compile, but when you’re amending the web interface either for small cosmetic changes or for larger changes of data representation there’s a long recompile, redploy, retest cycle that drives me insane. Obviously there are ways around it if you’re using something like Eclipse and have a web application in the structure it needs but we tend to have a number of files which are built at compile-time by Ant. Also, I don’t like being tied to an IDE for tooling purposes – I’m very happy with my current editor thank you very much. The only real missed opportunity was AppFuse – we remembered about it too late; any other Struts2 projects will probably start with it though.

All of this is why I was pleased to see Play! . It’s a just-in-time compilation framework where the controllers and model are pure Java and the view is Groovy; excellent!

This means that we can reduce the time taken to learn (we only need to learn one component – the view – plus config) whilst leaving all the business logic in a state maintainable by anyone in the team. It serves up locally through Apache Mina whilst also being deployable to a more conventional container like Tomcat or JBoss. Changes to both business logic and template are instant, and you can still test it to your heart’s content !

Unfortunately the latest stable version (1.0-stable3 at writing) doesn’t contain critical features like, um, if..else in the template language. Everything seems to be in the nightly, but having been burned with the Zero Configuration Struts plugin (which had the notice “This is experimental. Feedback is appreciated!”) I wouldn’t like to commit any real effort to writing an application in it. As soon as they have that core stuff nailed down though – I’m there.


Deskbot is a cross-platform desktop-based Jabber client for talking to a single user – normally a bot.


This is a screenshot of me using it to talk to the bot we run at work and asking for the details of a particular user.It’s written in wxRuby and uses xmpp4r-simple. There is a slight complication writing applications which need to poll a queue in wxRuby (such as the list of incoming replies from the bot) since you can’t just use green Thread objects and must use a Timer to make sure the Thread gets serviced. Very annoying.You can get the code like this:

bzr get http://philwilson.org/code/deskbot

You need to configure both who deskbot logs in as, and who it’s talking to in the code. There are some interesting questions around presence, invisibility, and client redirection here, but I just created a test account to log in as, and the bot already existed to talk to.

Theoretically I should be using things like ad-hoc commands and data forms, but I’m way too lazy.

It’s only a demo bit of code really and not enough to talk about, but I promised myself I would talk about more of the code I write!