seshblog

Icon

Simplest API Ever?

Last week I announced on Twitter that I had written a really simple python script to rip AFL scores from the AFL’s Game Day Live page. It had a pretty decent response so I’ve turned it into a quick and dirty web server for anyone to use.

twitter-post

Using web.py meant that the web service took all of about 20 minutes to actually code up, the biggest problem was getting Lighttpd virtual hosts to play nice on a server with multiple domains hosted.

For anyone interested the complete code (all 2Kb of it) is available here: http://sesh.gubbyprojects.com/labs/score/

And now to the fun part - explaining the single API call that this makes available.

I’ve created a sub domain specifically for this API, and it has just two parameters:

http://scores.gubbyprojects.com/{sport}/{team(s)}/

You’re going to need to fill in those two parameters with valid values; for the sport you need to put “afl”, and for teams you need to put the name of the AFL teams you want scores for - seperated by commas.

Here’s an example for this Friday’s game:

http://scores.gubbyprojects.com/afl/essendon,collingwood/

Check out what it returns - it’s so self explanitory that it’s hardly worth exaplaining:

Return Value:
ESSENDON,{Q1},{Q2},{Q3},{Q4},{total}
COLLINGWOOD,{Q1},{Q2},{Q3},{Q4},{total}

One little gotcha is that you can’t put spaces in the domain. You just need to make sure that you’re using a unique piece of text from the team name that appears on the Game Day Live page. For “West Coast” you can use “Coast” and for “Western Bulldogs” you can use either “Western” or “Bulldogs”.

That’s about it for now, I’m going to be expaning this a fair bit in the next going of weeks - but this call won’t change at all.

Plans for the immediate future:

  • Get a list of games for the week
  • Get more details about a specific game (time remaining, goal scorers, etc.)

It’s Your Ride


It’s Your Ride from Cinecycle on Vimeo.

2009 Melbourne Summer Cycle

Swan Hill Supporting MS - Team Photo

Swan Hill Supporting MS - Team Photo

On Sunday 22nd of Feb myself an around 4,000 others rode in the 2009 Melbourne Summer Cycle.

Our team, Swan Hill Supporting MS, managed to raise of $17,500 for MS Australia - a cause very close to the hearts of many of the team members.

You can still help out by sponsoring the team (even though the event is over, all 40 members managed to ride the 40kms) by clicking on the link below.

http://register.melbournesummercycle.org.au/?Swan+Hill+Supporting+MS

Hannah live at the Empress

Using Cron to Automate Tasks on Linux

Note: This was originally posted on my *old* blog. Posting here to add some content while I write a couple of things on my mind.

An exteremely useful feature of most *nix based systems is the ability to use a tool called cron (or crontab) to create what are called “cron jobs”. These are actions that can be made to be executed at a specific time on a specific day.

The two most useful commands for most users are:

crontab -l (list the crontab file for the current user)

and

crontab -e (edit the crontab file for a particular user)

Once you are editing the crontab file (you will generally need to be root to do this) you simply need to follow this format:

min hour day month dayofweek command

So if you wanted to run a command at 3am every morning, then you would do something like this:

0 3 * * * pacman -Syu

This is all well and good, and nothing more that you would get from the crontab man file, but there are a couple of handy tricks I can share. For starters, if you want to run a graphical application you need to send it to a screen. This can be done using a command like:

DISPLAY=:0 deluge

One of the main applications that I have for cron tab isn’t a system administration task at all, it’s to open and close a bittorrent client to download files while I’m asleep. Since most Australian ISPs now offer larger download quotas overnight it’s quite handy to be able to start downloads at 3am and kill them at 9am. It’s easy to do to. You simply use the DISPLAY=:0 trick to start the graphical bittorrent application, and then use killall to make sure that it’s shutdown at the right time:

0 3 * * * DISPLAY=:0 deluge
0 9 * * * killall deluge

I’m sure there are at least a few people out there that will find this helpful.

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

Latest Twitter Posts