Caolan McMahon

The Development Graveyard

19 Mar 2009

Just doing a little clean up of my projects directory. Its amazing the number of projects I've started that just never got off the ground. Most of them were made just for fun or to learn about a topic, but some of them I wish I had finished.

It seems most developers have a tendency to do this. I'm affected to the extent where I wonder what other people do to fill their time! I always have something on the go. Shown above is a screenshot from a project that was simply called 'Isometric Engine', which I was amazed to find out actually runs, and furthermore looks kinda swish... Inspecting the code however reminds me that this was probably my first project in python.

Anybody else have some interesting code/ideas in the development graveyard?

Multiple account tweet script

15 Jan 2009

Trying to manage multiple accounts on twitter is a real pain. I just can't find a twitter client I like so I usually post on the site itself or from a Gnome-Do plugin. Both those options are only designed for users with one account in mind. Posting to a different account means logging out and then back in again.

I know there are some Twitter clients which handle multiple accounts, but most of them seem too clunky for me, or they only post the same message to multiple accounts simultaneously.

Anyhow, I hacked together a little python script in about 5 mins (don't like bash scripting!) and I find it really convenient to use, so heres the code:


#!/usr/bin/env python
import twitter, sys


# Edit to include the username and password for each account you wish to use:
ACCOUNTS = {
'username1':'password1',
'username2':'password2',
'username3':'password3',
}


def main(user, msg):
if user in ACCOUNTS:
try:
api = twitter.Api(username=user, password=ACCOUNTS[user])
status = api.PostUpdate(msg)
print "Tweet successful: %s" % status.text
except twitter.TwitterError, e:
print "Error: %s" % e
else:
print "Error: Unknown account '%s'" % user


if __name__ == "__main__":
if len(sys.argv) > 2:
main(sys.argv[1], " ".join(sys.argv[2:]).strip())
else:
print "Usage: tweet USERNAME STATUS"

Usage: $ tweet USERNAME STATUS

Download

There's something really nice about just typing:

$ tweet caolan hello world!
$ tweet otheruser @caolan be more original!

Of course, all the heavy lifting is being done by the python-twitter library, available here (also requires simplejson), alternatively:

$ sudo easy_install python-twitter

To use, stick the script in ~/bin and chmod +x, make sure you have python installed (this was written for Python 2.5.2), and add your account login details at the top of the script.

Don't forget you're storing login credentials in a plain text file, be sure to consider the security implications for your situation!

JSLint Plugin for Gedit

7 Oct 2008

JSLint Plugin Screenshot

I was running a bunch of Javascript through JSLint and decided it would be nicer to verify directly inside gedit, my editor of choice. A short Google later I come across a plugin by none other than Stuart Langridge of LugRadio fame, unfortunately it had a few major drawbacks:

  1. It runs every time you save a document (and only then)
  2. It seemed to get a bit messed up when flicking between tabs, and
  3. it took AGES...

Luckily these problems were easily solved by adding a menu entry under tools for checking the current document, clearing the results when changing tab, and changing from rhino to spidermonkey for running JSLint. But what the hell do you care? Here's a download link...

Download JSLint for Gedit: Zip | Tar

Thanks to Langridge for making the plugin this is based on, his version can be found here. If you think my version is still too crap you can fork on github.

Good Morning York

23 Sep 2008

morning view in york

Well, it's taken 23 days but I'm finally online. I learned no interesting lessons about modern life during this internet fast, apart from the fact that having no internet really really sucks...