Reversing Latitude

Posted by on June 17, 2009

I have recently been playing around with the (relatively) new Google service named Latitude. This service may be either used from your mobile phone (including the Nokia S60 range) to allow you to see where your friends are located.

Something I have wanted to do with this service for a while is to use it to keep track of where I have been. Recently Google released an API to do this. The only problem with this is that your are required to change your privacy settings, effectively allowing everybody to know where you are.

This lead me on the quest to reverse engineer the data that the latitude iGoogle gadget uses to update itself. So far, I can parse the data into a set of lists once given a url to where the data is.

To obtain this url, you will need to use firebug to watch all of the requests made by the iGoogle page (with the latitude gadget loaded into that page) and look for the one that contains makeRequest. Copy this url, with all of it’s parameters to get access to the data.

I have written a small parsing library (in python) that will grab the data, and parse it out into the specified data structure. This library is available from my mercurial repository under the latitude project.


Default email addresses for contacts in OSX

Posted by on April 16, 2009

Have you ever wondered how OSX decides what email address to use when you email a contact? A lot of the time, you get to choose, but there are times when the system decides for itself… Such as when you are using iCal to send out event invitations.

There is actually a way that the system decides on which address to pick, and this is even a public API. The problem though, is that Address Book does not expose this interface to the user.

So, after some researching (to find the actual way this is implemented), I developed a small (command line) tool to change the default email address for a user. This tool, takes the form of a small python program, using the pyobjc bindings to the AddressBook framework.

The source code is avaliable from my repository in the stuff repository under the osx/addressbook/edit_default_address.py path.

You will also find in the same folder: a script to create a mutt alias file from the system address book, and a script to convert all of the phone numbers into the international format (from the Australian format).

These three programs form the basis of a good set of examples of the python objective-c bridge for the AddressBook format.


Adding fonts to linux

Posted by on April 7, 2009

I have been complaining for the last few days about my the font that I have been using in my terminal, so I decided to actually do something about it.
What I didn’t know, was how to go about installing some nicer fonts. While talking to James about this, he suggested that I can just create a ~/.fonts directory, and place the fonts in there. A great little piece of information, that I had no idea about.


Fixing audio on Ubuntu 8.10 for an iMac

Posted by on March 31, 2009

I was having problems where the sound was crackly and quiet. So the fix seems to be reload the snd_hda_intel driver (kinda annoying… but at least it works)

sudo rmmod snd_hda_intel
sudo modprobe snd_hda_intel

Making RSS less crap – Feed Fixer

Posted by on March 9, 2009

As some people know, I read a lot of RSS feeds. I am currently subscribed to 69 separate feeds, and this number is slowly growing.

Something that I am starting to notice, is that quite a few websites/blogs don’t give you the whole story within the RSS feed. This is quite annoying, I read a lot of things while I am mobile (read with limited Internet connectivity), so clicking on each article’s link before I leave for the train is just annoying.

I have finally gotten around to creating a (web) service that will take these said feeds, and ‘fix’ them. To do this, I take the RSS feed that is provided by the website/blog, and grab the full page that is linked from it. Then I run a xpath query over this page and dump the result of it into the the output RSS feed.

You can grab the latest version of the service from it’s development repository at http://tsukasa.net.au/~hg/feed_fixer, or you may use my installed version at http://tsukasa.net.au/feed_fixer.

Remember that I am actually using this service, so DO NOT delete any of the entries that are there.

Some features that will be coming in a future version will be the ability to have ‘hidden’ feeds (with a special key to gain access to the feed), the ability to add feeds requiring a password, the ability to add password protected trac feeds (as they decided to require user’s to have a cookie). Feature requests are welcome.


Stop Google.com Redirecting to Your Local Google « Techstatic.net

Posted by on March 9, 2009

I just discovered this little gem: Stop Google.com Redirecting to Your Local Google. Now, I am sure you would be asking why I would want to stop the redirection.

My answer is quite simple… Google has a bad habit of letting the ‘local’ google page lag behind the US version, meaning things like latitude don’t work on google.com.au.


Handy bash one liner for getting the ip address of a host

Posted by on February 19, 2009

Something I find that I have to do in bash scripts occasionally is to grab the ip address of a specific computer. This requires a little parsing in most cases (due to cnames and multiple ipv4 addresses for a host).

The following one liner should handle all of this correctly:

host ServerName | sed -rne 's/.*has address ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/\1/p' | head -n 1

Note: Syntax error was picked up by freespace


Handy wordpress plugin

Posted by on February 9, 2009

This is just a really quick post to mention that I have found (well, actually Mat found it) a nice plugin for wordpress to support dumping source code into entires. This pluging is called syntaxhilighter-plus. It allows you to easily drop source code into a page.

It also adds a few nice buttons. Here is an example:

def main():
  print "This is python^^"

if __name__ == "__main__":
  main()

Multiplayer Snake

Posted by on January 5, 2009

Well, here we have yet another challenge… Though this one does not involve any prizes, as I want my students at the NCSS camp to actually do their projects and not spend all their time on my competition.

So, what is has to be done here? Well it is quite simple really… Design a bot to play snake for you. I am forcing people who submit to write their solution in python (though there is no real need, other than I am teaching python at the moment). The input/output of the program is quite simple… The output consists of one of the following four letters: ‘U’, ‘D’, ‘L’, ‘R’ (corresponding to Up, Down, Left and Right).

The input consists of the following:
width height snake_id
board layout

An example is:
7 7 A
..*....
..A....
..a....
..a....
.......
.......
..Bbbb.

Where * is an apple, . is an empty cell, the uppercase letters are the head’s of the snakes, with the lowercase being the body.

Code for the engine is located in my repository under the snake project. Submissions should be made to my email address, or in person.

The initial competition will have bots go up against each other, with no time limit given per move. The later rounds will ensure that all bots get equal cpu time (by running the faster bots more often).


PyGolf – Winner of competition 1

Posted by on November 29, 2008

Well the deadline has come and passed, and we have a clear winner. That winner is Katie. Her solution comes in at a tiny 121 characters, with the closest solution coming from Tim with 187 characters.

The main difference came down to the fact that Katie decided to avoid using the regular expression that was given in the sample, and just parse the lines with str.split.
So without much more talking, here is the winning solution.

import sys
s=sum(([l[0]]*int(l[-1])for l in map(str.split,sys.stdin)if l[-1]!='-'),[])
for x in set(s):print x,s.count(x)

It is also interesting to note how she uses the sum function to append a set of lists together.