Over the weekend I was fortunate enough to attend #RailsGirlsPerth. This was an opportunity for girls to learn about Ruby on Rails, a web programming framework. It was a free event organised by the wonderful Darcy and Marcus, held at Spacecubed.
It kicked off on Friday night with an installfest. I had already installed Rails on Craig’s laptop (which I borrowed for the event) but I went along to meet people and take in the vibe. There were a few people I knew there, but many more that I hadn’t met yet. It was great to see so many women keen to learn how to program in Ruby and so many guys there to help get them started. Railsgirls events were also happening in Brisbane and Sydney. We caught up with them on Skype and I spied a @web_goddess at the Sydney event.
Me and Jo (@history_punk) coding all the things (via @history_punk)
The coding started in earnest on Saturday. Before I knew it, I was up over my head in the niceties of Ruby with the very capable help of Myles and the assistance of some excellent coffee that Darcy had organised. I had decided that I wanted to use the Trove API after being inspired by the wonderful things created by @wragge.
I’ve been hearing about APIs for a few years now but had never used one and I wanted to change that. I also wanted to do something with Twitter. I came up with the idea of extracting vintage knitting patterns from Trove using the API and visualising them in such a way that they can be tweeted.
Initially I was really confused. It had been 12 years since I’d done any really serious programming (in my undergraduate degree) or even used the Windows terminal. I was grouped with three girls who had experience programming in .NET which was a bit intimidating. By lunchtime I was feeling like a rather dim bulb and doubting that I’d have any finished code to show by the end of the day.
Things started coming together as I began to map Rails terms to concepts I’d learned when programming previously (e.g. gems == libraries). It also helped that the Rails framework does a lot of stuff for you (a bit confusing at first if you’re not used to it) and the Ruby syntax is very clean and easy to read. This made it possible to get working stuff together in a day.
I was also grappling with the Trove API and trying to make it output what I wanted. Getting an API key for Trove was super simple and took a few minutes. Coming to terms with the syntax of the API was harder. What I really wanted was an output of the contents of this list. After quite a bit of fiddling, I ended up compromising with a list of the newspaper articles tagged with ‘knitting’. Then it was a matter of harmonising my variables with the metadata I wanted to capture in my database and adding the ability to tweet items. As Myles promised and I had trouble believing, the Twitter part was very easy (about 2 lines of code). It produced tweets like this:
So now I had a working chunk of code that could grab specific content from Trove, display the metadata I was interested in and give the ability to tweet it. However it was only running locally on my laptop. The next challenge was porting it to Heroku, a cloud based service for hosting web apps, so that other people could see it and interact with it. Fortunately, the documentation for setting up Rails on Heroku was top notch and I was mostly able to follow it without hitch. It involved using my first Postgres database which was cool as Postgres helps pay my mortgage (via Craig who is a Postgres developer/consultant).
After some work and a bit of fiddling, I had a working Rails web app hosted on Heroku, pulling in information from Trove and allowing people to tweet items from it. You can see it here. Not bad when I’d just started learning Ruby on Rails that day! Much kudos must go to Myles who talked me through quite a lot of it (and had great patience with me). I don’t fully understand the code I wrote, but I can revisit it and hopefully get my head around it better. I’d like to clean it up a bit, make it more visual and iterate through the Trove output so I can capture and display all 700+ records (rather than just the first page). Still, it’s a great start and far more than I thought I’d be able to get done in one (admittedly 10 hour) day.
I really can’t thank the organisers and sponsors of RailsGirlsPerth enough. It was an amazing and inspirational event. I met a number of really interesting people who I’m hoping to stay in touch with and learned an enormous amount. It’s given me a whole lot more confidence about playing with APIs and coding in general and it provided a very welcome distraction in what was a really hard week.
If you’re interested in trying something like this, keep an eye on the RailsGirls website and Twitter feed to find out when more events are happening (they are worldwide). You can also get a taste of Ruby at the TryRuby website. I’d highly recommend giving Ruby on Rails a try if you’re interested in playing with APIs or increasing your tech knowledge in general.
The Rails Girls Perth crew and participants (via @GentlemanTech)