Skip to content

Mashing up Twitter Trends and Google Images

I recently released the latest entry in my series of nano-apps.

As with my previous efforts, istrending.com serves serves no real purpose other than as an act of deliberate practice: going through the process of coming up with an idea, writing code, registering domain names, setting up Cron jobs and configuring deployment systems to get it all up and running in a production environment.

I questioned why I was even bothering with an app that was likely not going to see any traffic or be of use to people and when I hit a minor javascript problem the project was shelved for a few months. I recently had a fresh burst of enthusiasm though and got the usual sense of achievement when I deemed the code “ready enough” and a quick cap deploy took care of the rest.

The main problem I’ve faced with this app concerns the script used to update the list of trending topics: the Twitter search api has a known issue of returning HTML instead of JSON, which has on occasion caused my inbox to be filled with emails from the Cron daemon alerting me to failed jobs. I’m also not very happy with how the javascript carousel functions, so there’s some scope for improvement there.

The code is available on GitHub as usual.

Next up is probably something bigger, very likely involving Rails. I’ve been reading up on the various testing methodologies used in the Ruby world and have written my first set of RSpec tests so I hoping my next release will at least have some test coverage. Other than that I’ll just have to see what ideas come to mind between now and then.

Any suggestions on what I should do next?

5×5 strength training program

Since my last update strength training I’ve progressed from 3 sets of 5 reps to 5 sets of 5 reps: the infamous 5×5.

I’m still training 3 days a week, Monday, Wednesday and Friday before work, still not doing any cardio and the Osgood Schlatters is still giving me gip.

Here’s what my routine has been like lately:

  • Monday
    • Front Squat
    • Overhead Press or Dumbbell Bench Press
    • Clean
  • Wednesday
    • Front Squat
    • Overhead Press or Dumbbell Bench Press
    • Barbell Row
  • Friday
    • Front Squat
    • Overhead Press or Dumbbell Bench Press
    • Deadlift

I’m training the front squat every session and alternating the overhead press and the dumbbell bench press between sessions. Taking into mind my knee difficulties I’m training the squat with relatively low intensity and wearing a knee sleeve which is giving me a much needed opportunity to work on my form and control.

As an aside, I’ve been working towards another goal: making it into the light-heavyweight division. It’s been tough going, I’m sick of the sight of food a lot of the time and have even been supplementing with vitamin B12 to see if I can boost my appetite sufficiently. I’ll be sure to let you know if I hit this milestone :D

Developer Rehab

My unemployment is over! Last week I started as a developer with Rehab Studio. Code on!

Because everyone needs their own URL shortening service

At the moment I’m in between paid work and have been using my time to generally enjoy life but to also improve my skills. I’m all about the skills.

As an act of deliberate practice to hone my skills with web-application development and to deepen my understanding of the Rails framework I’ve been adding to my collection of nano-apps.

A while back I had an idea to develop a URL shortener just to see how little code would be required but decided the world really didn’t need another one. With time on my hands over Easter & the curiosity of a technology entusiast I just started hacking and had a functioning prototype within a short time-frame.

I wasn’t keen on parting with my shiny pennies for a domain name considering my lack of income but I’d written the code and thought I’d may as well go the whole hog and get my work into the wild.

So, without further ado, I present io.gd . As usual, code is available on GitHub.

Finally, after 2 and a half years, my Rails DVD catalogue is go

Well, it only took me 2 and a half years but I finally used Rails to develop a catalogue for my DVD collection.

The catalogue loosely fits in with my series of nano-apps and is hosted on movies.stevenwilkin.com. The code is publicly available on GitHub for anyone who’s interested.

All’s left now is to actually use the system and fill in the details of my collection!

An experiment with Sinatra, HAML and Blueprint CSS

In my last post I considered transforming stevenwilkin.com into a Sinatra app.

Well, I did it, although I’m only mentioning it now.

Not only was this my first experience with Sinatra but I also decided to try using HAML for the markup and Blueprint CSS to help with the styling. If I’m going to play with a new technology why not play with a few new technologies?

I found Sinatra quite straight forward: you match up a HTTP verb (eg ‘GET’) and a url (eg ‘/’) with a block of Ruby and the results can be sent directly to the browser or an optional view template can be rendered. Simple!

Instead of a Model-View-Controller pattern like many of us are accustomed to, Sinatra provides more of a Controller-View setup which I believe would make it more suited to smaller apps which don’t necessarily make use of a database or where a full-stack framework like Rails would be overkill. If I create any more nano-apps in the future I’ll more than likely use it again.

What really struck me during this experiment and made the whole thing worthwhile was HAML. The simplicity and clarity of it’s syntax was super refreshing and meant I had to do a lot less typing and didn’t have to remember to close divs etc, never mind it being white-space sensitive! All Ruby-based web development I’ve done since has used it.

I wasn’t fussed on Blueprint. I found having a grid background during the *ahem* design phase to be great but I probably didn’t make enough use of it’s features for it to really shine through. In terms of styling and CSS I didn’t take much time to look at SASS and didn’t use it, but I’ve since reread the documentation and may well make use of it in the future.

The app was deployed onto Passenger, like my previous experiments. It took a small bit of google-fu to get the Capfile and Rack configuration tweaked correctly but once this was done pushing the code into production with Capistrano was a breeze. How did I ever survive without Capistrano?

The deeper I get into Ruby the cruder PHP seems, not to mention C#. The future seems exciting.

First production Rails app

I released my first production Rails application, hugagoth.com, last night.

I first started playing with Rails over 2 years ago and it has taken me until now to take an app through from conception to initial deployment. And an interesting journey it has been.

When I first started investigating Rails I had never used a web framework before and the Ruby language really confused me, but there were a few things I liked. I liked the idea of convention over configuration, opinionated software and the amazing community that has built up around this set of technologies.

Not long after this, I started work on another project and considered using it as the motivation to fully get to grips with Rails, but getting the job done was more important so I headed down the PHP route, having had a bit of experience with it over the years. I’m amazed that I now have 2 years of CakePHP development experience. It gets a bad rep concerning it’s performance speed but if I’m doing any bespoke PHP work, Cake is never far away.

Deploying Rails apps a couple of years ago seemed like quite an involved process, what with application servers, web servers, proxies and clusters but now with Passenger, getting a production environment up and running is a breeze. I’ve also developed a great love for Capistrano, using it with non-Rails apps.

Calling hugagoth.com my first Rails app in the wild is a bit of a lie. When I discovered Passenger I wanted to see just how easy deployment now was so I converted my static, single-page professional site into a Rails app. A bit overkill I know as it doesn’t even do anything, but a worthwhile experiment none-the-less.

It’s unlikely I’ll ever use Rails in my current day job so I’m unsure what I’ll be doing with this framework in the future. I’ll probably convert stevenwilkin.com to run on Sinatra just for kicks and if any interesting ideas come to mind, you never know!

Nano-Apps

Last month Giles Bowkett in the trawls of his hypergraphia wrote a post on Nano-Apps, quirky one page apps which serve up a piece of trivia or answer a question like is George W. Bush still president?

Previously I had put together hometi.me, a little AJAX-y app to let me know how much longer I had to go until I could leave work for the day and when a new nano-app reporting Belfast’s goodonpaper’s coffee drinking habits surfaced the bug bit me and I wanted to do something and do it quick.

I had the embryo of an idea on a Sunday and had production code on the following Saturday morning.

The app attempts to answer the question is it raining in Belfast? by scraping the MET office forecast for Belfast and sometimes gets it right. It has a Ruby back-end and PHP front-end and is available on GitHub for anyone interested. The graphics need tweaked and it would no doubt be better displaying the weather that was previously forecast for the current time period, but it’s out there doing it’s thing which was the point in the exercise.

During this process something that caught my eye is Sinatra, a Ruby framework suited to creating web-apps with minimal code. Now all I need is a idea to implement with it…

2009 Irish Blog Awards Nominations

Irish Blog Awards 2009 - Nominated

I’ve been quiet lax on the blog front for a while now, both in terms of producing and consuming blog content. Curse you Twitter!

So it came as quiet a surprise while reading one of Matt’s blog posts to discover my humble blog had been nominated in the Best Personal Blog category of the 2009 Irish Blog Awards.

Must. Blog. More.

Update: Thanks to DavyMac for the great logo!

Simple example of accessing the Twitter REST API with Ruby

To date, a lot of interesting applications have been built on top of the Twitter service with new apps being released almost daily, each one more ingenious than the last.

In my spare time I’ve been tinkering with Ruby, my motivation being to learn something new and to see if Ruby lives up the hype that has been surrounding it in recent years. In conjunction with this I’ve also been experimenting with obtaining content from existing web sites and services, content being king after all.

On my list of software development goals I’ve wanted to do something with Twitter but have been lacking the all important idea of which problem to solve. Considering my learning objectives I decided to just get stuck in and see what basic task I could accomplish that involved:

  1. authenticating to the service
  2. making a request
  3. processing the response

After looking at the API retrieving the list of followers for a given account seemed doable.

If I were to undertake a non-trivial Twitter application I’d consider using Twitter4R rather than writing all the REST interaction from the ground up. Another possibility would be to request JSON rather than parsing XML with Hpricot. The luxury of decisions.

The result of my tinkering is followers.rb which lists the followers of the account accessed with USERNAME:PASSWORD credentials:

#!/usr/bin/env ruby
 
# followers.rb
# retrieve list of followers from Twitter
# SJW
 
require 'net/http'
require 'base64'
require 'rubygems'
require 'hpricot'
 
user	= 'USERNAME'
pass	= 'PASSWORD'
host    = 'twitter.com';
path    = '/statuses/followers.xml'
 
auth = 'Basic ' + Base64.encode64("#{user}:#{pass}").delete("\n")
 
# authenicate and retrieve XML, feeding it into Hpricot
doc = ''
Net::HTTP.start(host) do |http|
	res = http.get(path, 'Authorization' => auth)
	unless res.code == '200'
		puts "An error occured"
		exit
	end
	doc = Hpricot(res.body)
end
 
# each follower is within a <user />
users = doc/:user
 
# count the number of followers
count = "#{users.length} followers:"
puts count
count.length.times {print '-'}
puts "\n\n"
 
# output each name and corresponding twitter account name
users.each do |u|
	name = (u/:name).text
	screen_name = (u/:screen_name).text
	puts "#{name} | @#{screen_name}"
end