Wednesday, September 3, 2008

is checking out http://ping.fm

Monday, April 28, 2008

secure django+jetty+jython

UPDATE: since this is now 2 years old, and one of my key links is broken i've written a quick update here: http://tristanking.blogspot.com/2010/01/re-jettydjangojython.html

Today I enabled a ssl connector in jetty to run my django app securely. I then spent most of the day trying to figure out why HttpResponseRedirect's didn't work.

Turns out all I had to do was implement is_secure in my django handler.

updated servlet.py can be viewed here

Wednesday, April 2, 2008

iPod Touch On-The-Go FTW!

One thing that has always annoyed me about my iPod Touch is the inability to play all of an artists albums, album by album. You from the artist list, you can select a single album, or all songs for which you can play them in alphabetical order or shuffle mode.

I just figure this out! The trick is to use the On-The-Go playlist. Go to playlists and select the On-The-Go playlist. If there is stuff in it already you will have to hit the edit button (or clear it and start again). From there you navigate to your desired artist, and the button with is normally All Songs is now Add All Albums. click that, and then click done and play your playlist.

I don't know why i didn't look into this earlier. I guess i figurered i'd have to add all the songs one by one, but Apple has made it very simple. Still, a play all albums button in the standard menus would be much simpler!

Tuesday, April 1, 2008

One week old!

My dreadlocks have reached one week. They're all over the place! I re-backcombed a few of them over the week, mainly the ones that didn't hold together after a shower. I'm resisting the urge to redo the few on my left side, they're really loose but still keeping to their own distinct groups so I want to leave them to see what they do themselves. If there's no progress with them after a month I'll look at redoing them. I'm not sure what's going on with the very back ones. There are a lot of loose hairs getting around, but again, i'm gonna leave them to their own devices.

For now I don't go anywhere without a headband!

Photos

Wednesday, March 26, 2008

fixing dcommit maddness

when pushing changes from git back to the svn dcommit by default does a rebase afterwards, which causes all the time stamps of the checkins in the git log to change to the dcommit time, which is really annoying. reset can be used to get the times back, but then dcommit wont work since they're not synced. To get around this you have to use rebase before the dcommit, then reset again.

git commit
git svn rebase
git svn dcommit --no-rebase
git reflog
git reset --hard HEAD@{5}
reflog is used to list all the changes to a branch and find out the number to use between the braces in the reset command. The number you're looking for is the one of the last commit.

Unfortunately this needs to be done every time I want to push back to svn now. I would hope that using --no-rebase on every dcommit would have avoided this, but I can't test it now without messing up my repos.

Sunday, March 23, 2008

shitty senheiser cables


shitty senheiser cables
Originally uploaded by tristan.king
god damn it! they're not even a year old. And from the black tape around the jack, you can see it started to fray ages ago.

Apart from that, they're very comfortable headphones, which I was perfectly happy with whilst running and riding. They're still good, except i have to keep the cables at specific angles to get the full sound.

I shall have to find myself some new sports headphones now.

On another note: this picture was uploaded from my n82, and the post was made from flickr. very cool.

twitter status messages as an image

I love twitter, and I like to have my status message everywhere possible. Unfortunately most forums and such don't allow having the flash or javascript badges in signatures etc. What was needed was an image generater which could create a dynamic image based from the current twitter status message. After some quick googling I cam across this site which generates an image similar to the flash based twitter badge. I'm not very fond of this badge tho. It's ugly. I much prefer the facebook badge for the official twitter facebook app. So I decided to build an app which generated an image similar to the facebook badge. After a few hours of pluggin away with django and the pil I had done it!

the source can be found on github.

The app currently grabs the status message from twitter every time the image is requested. Thus I don't think this app would scale very well (altho if it was run by twitter themselves, and connected directly to their databases it probably would). But for the forum or two that I have it on, it should be fine.

dreadlocked!

Seeing that I had nothing much to do on the 4 day Easter weekend, I decided to try dreading my hair myself.

After the first minute of attempting to section the hair myself, I realised it was not gonna work. So I convinced Hai to section it for me, then went onto the backcombing myself and managed to do it all over 2 days. My left arm is still sore! It's amazing how much work it is to hold your hands above your head for an extended period of time.

I ended up with 30 dreads, some small some fat (and one extra fat one that wont sit flat at all!). Photos here

It feels good to be back on the path to dreads! :)

Wednesday, March 19, 2008

django+jython+jetty

UPDATE: since this is now 2 years old, and one of my key links is broken i've written a quick update here: http://tristanking.blogspot.com/2010/01/re-jettydjangojython.html

Yep, you read that right. Django, running ontop of jython, running inside jetty.

Why? The idea just popped into my head while in a meeting discussing our project's deployment strategy. I thought "hey, we already have a tomcat server running for other people's projects, I wonder if i can get django+jython running inside a servlet container". Seeing that jython already came with a PyServlet class, i figured the base work was already there and decided to give it a go.

So I started off looking at the PyServlet class that ships with Jython. PyServlet allows you to write servlets from python code, implementing the standard doPost, doPost, etc functions, from which you access by going to a URL which matches the path name of you .py file. This doesn't match the REST method django uses, so the PyServlet needed some work. It turned out to almost be an entire rewrite, the only things remaining from PyServlet being the PySystemState initialisation.

As well as the DjangoServlet, a django handler module had to be created to bridge the gap between the java servlet request and response objects and the django python request and response objects. The already existing modpython handler provided a great guideline to make this, and it turned out to be a breeze.

Currently, I build the DjangoServlet on it's own using maven and install it into my local maven repo (for people who have not used maven before, this involves a single command line call). The servlet handler module is put straight into django in the same location as the other handlers (django.core.handlers.servlet). I then have another maven project with a dependency on the DjangoServlet project, and a web.xml. The web.xml requires a few init-params: one for the jython home, one for the django handler class and one for the django app location.

With everything set up, using the maven jetty plugins, i fire jetty up, which loads the DjangoServlet and BAM! django running in a servlet container.

So far I've not noticed any difference in performance, but one nice 'feature' is being able to use maven's dependency management to set up the classpath with the jars required to run your app (it definitely beats having the edit the $CLASSPATH before starting jython and my settings.LIB_DIRECTORY method).

A few things still need to be done to make this really easy to setup and use, It may be best to try move the handler module out of the core django code, so that once jython is up to the task of running django without any modifications it is possible to deploy this on a pure django+jython install. I also need to write scripts to build the pom.xml and web.xml files.

If you want to have a look at this, or deploy it yourself, you can grab the projects from github. Here for the DjangoServlet project, servlet.py for the django handler module and hydrant is my django app which has example pom.xml and web.xmls for you to use as a reference for your own (until i have proper scripts/docs to build them).

Wednesday, March 5, 2008

Music and motobikes, solved!

I went for a motorbike ride out to Charters Towers on sunday, which gave me a chance to try out the Etymotic Research ER-6 Isolator headphones that I bought specifically for highway riding.

When riding a motorbike there is a lot of noise. There's the noise of the engine, the road noise, the sound of the wind rushing past your head, and it's all very loud. This is easily pointed out by the fact that to listen to music using standard headphones i have to crank my iPod to full volume just to hear it. This is annoying for two reasons. One: The quality of the music is greatly reduced when turned up that loud, and two: the damage it is doing to my ears at that volume. But it's not only my headphones, what damage am I doing to my ears just riding the bike with all that other noise? Hence, I decided to invest in a pair of headphones to try combat these problems.

First I tried a pair of Sony MDREX52SLB in-ear headphones, which didn't work out too well. They were better then my standard iPod headphones, but not by much. The only real advantage was that the in-ear model made it easier to get my helmet on without pulling them out. So I decided to look for a noise-canceling set of Sony headphones, and in my searches instead came across the ER-6.

The ER-6 is a set of in-ear noise-isolating headphones, for which Etymotic Research claim it's noise-isolating design "far surpasses that of active noise-canceling earphones". My opinion? pretty damn good. I plugged in the headphones, cranked the iPod up to half way (which is what I put it at if i want to block most other noise out) threw my helmet on away I went. I was instantly impressed. 100km/h and i could still hear the music. 110km/h, music was fine. 140km/h, still singing along! Of course it wasn't perfectly clear. The other sounds were still there (which is a good thing, for safety reasons), they were just a lot quieter. When driving through the city, I could hear the other bikes and the cars, which is impossible with normal headphones without stopping (or fumbling around while riding) to turn the music down or off.

These headphones are exactly what I wanted. I hope my ears will thank me. And as for Etymotic Research's claim about it's noise-isolation, I've got a pair of Sony MDR-NC22 noise-canceling headphones just waiting to be tested out on my next long highway ride. They've got a lot of impressing to do though!

Connecting my n82 to uni wifi

I got a N82 yesterday, and have finally figured out how to connect it to the Wifi (ssid: walkabout) at JCU. So here's a quick run down on how I did it.

Get CA certificates

I used the Keychain access app on my MacBook to export the certificate authority that JCU uses (CACert.org), then sent the cert to the phone using bluetooth. My phone has already been paired with my mac when i set up iSync, so you may have to do that before continuing.

  1. Start "Keychain Access"
  2. Find the cert named "CAcert Class 3 Root"
  3. Right click on it, and select "Export "CAcert Class 3 Root"..."
  4. Select the directory you wish to save the file to, and click Save (make sure the file format is .cer).
  5. Find the file in Finder, Right click on it, go to: More -> Send "file name" to -> Phone name. This will send the file in a message to the phone.
  6. Open the message on the phone, it will detect that it's a cert file automatically.
  7. Select "Save" to save the cert file.
Set up WLAN
  1. Goto: Tools -> Settings -> Connection -> Access points
  2. Open the options and select New access point
  3. Set Connectiong name to "Walkabout"
  4. Set Data bearer to "Wireless LAN"
  5. Set WLAN network name to "walkabout"
  6. Set WLAN security mode to "802.1X"
  7. Enter WLAN security settings
  8. Set WPA/WPA2 to EAP
  9. Enter EAP plug-in settings
  10. Highlight EAP-PEAP, hit options, and select Enable
  11. Enter EAP-PEAP
  12. Set Authority certificate to "CAcert Class 3 Root"
  13. Set User name in use to "User defined"
  14. Set User name to jc number
  15. Set Realm in use to "User defined"
  16. Leave Realm blank
  17. Set Allow PEAPv2 to Yes
  18. Go to the EAPs settings (click the right button on the nav control)
  19. Highlight EAP-MSCHAPv2, hit options and select Enable
  20. Enter EAP-MSCHAPv2
  21. Set Username to jc number
  22. Set Password
  23. DONE!
Now when you open up the web browser, and it asks for a connection, select Walkabout and everything should work fine! The auth server will ask for your jc number and password again to auth you to the firewall, and after that everything runs smoothly.

I'll do a quick write up on what i think about the N82 in a week or two when i've played with it some more.

Monday, February 18, 2008

Bittorrent for file storage and replication

After a lengthy hallway discussion this morning, the idea for a Bittorrent based file storage and replication to replace the need for SRB/gridftp popped into my head. Here is my current musings for such a system.

Note: i'm using similar terms to bittorrent, when i refer to the actual bittorrent concepts, i will prefix the terms with BT-.

The "tracker":

Each institution will set up a tracker. The tracker would have a list of all the other institution's trackers which it replicates with. When a user starts uploading a new file to the tracker, the tracker notifies the other trackers of the new file, and starts sending the file to them using the bittorrent protocol. The idea is that all the trackers perform the tasks of a BT-tracker as well as a BT-peer. Thus replication is an ongoing process and is achieved automatically without having to specify specific replication times.

File access for users:

Because each institution is notified about a new file, all users can see the files instantly, regardless of which institution they're at. The users would download files in the same way bittorrent does. The user's institution's tracker would provide the user with a list of peers that are available, which may contain other users at their institution, or even other institution's trackers and users. The user's client would then download the file from all available sources, providing the maximum throughput. Uploading a file may work in a similar way, the user may upload the file to all peers, which would include other users and other institution's trackers. Of course, these things would have to be explored to find an optimal process.

AAA:

certificate based authentication, same as gridftp.

File sharing:

This will be a tricky section. I'm thinking the best idea might be groups. So when a user uploads a file they specify which group they wish to make the file(s) available to specific groups. All users of that group can see all the files for any groups they belong to.

Metadata:

Another tricky section that needs to be sorted out.