| this is what goes around; and this.. this is what comes around |
[21 Dec 2009|03:44pm] |
It used to be that no applications would compile for 64-bit architectures, because everyone was trying to cram pointers into ints. Today I had the opposite. The head of some code I'm working on wouldn't compile in a 32-bit environment, because someone was trying to store 5 bytes in a long.
We have truly come full circle.
|
|
| Melbourne Tram Tracker for the N900 |
[20 Dec 2009|11:42am] |
So Collabora's robotic and non-robotic overlords very graciously bought everyone on staff an N900 for Christmas. In my opinion, it's actually a very nice phone (although possibly a little on the large side); but the let down is there just isn't the same host of applications for it. Still, possessing both the tools and the skills, I figured I should do something about this, rather than complain.
One of the most useful iPhone applications in Melbourne is the real-time tram tracker. For stops without a display board, you can type in the stop ID and get the upcoming arrivals at that stop. You can also find nearby stops via GPS and a bunch of other things. It turns out that Yarra Trams offer a SOAP WSDL web service that is reasonably well documented, so I've spent a few days putting together a basic tram tracker for Maemo 5 (even if only two people will ever use it).



 It currently can show upcoming trams for a stop by ID or by searching for stops by road names. Could possibly also do things like search for stop by route. There is a lot of information available. It doesn't yet do searching by location; the information is in the database, I've just not yet looked at how the location APIs work yet. Also need to add support for storing favourites.
I also want to add support for tracking a tram by tram ID. I'm wondering if it's possible to use the GPS to detect periods of immobility and check the upcoming tram stop after the tram starts moving again. I habitually miss stops; so what I think would be neat is to dial in a stop number or cross road you're looking for, and have your phone notify you when you're approaching it.
The web service uses python-suds, which is unfortunately not packaged for Debian, so I can't just rebuild it for Maemo (if anyone wants to package this up for me, that would be really awesome). Then I'll find out how well my app actually runs on the device.
In case anyone cares, the source code is here.
|
|
| snOMG |
[19 Dec 2009|02:18pm] |
This was my deck two hours ago. It's still snowing,and there's a blizzard warning until 6 and then a winter storm warning until 6 AM tomorrow. Do I start shoveling now to make a little dent in the problem, or wait until tomorrow?
|
|
|
[18 Dec 2009|11:12pm] |
| [ |
mood |
| |
cold |
] |
The Sterling Wegmans was seriously cleaned out; I don't think I've ever seen so many empty shelves in a grocery store. A couple of us snapped pics of the bread shelves that contained only a single (opened) loaf of wheat bread. I did manage to get a gallon of milk, but failed at finding snow boots at the Target across the street.
ZOMGIT'STHESNOWPOCALYPSEANDWE'REALLGONNADIIIIEEEEE!!!! Or something.
'Sokay, I have eggs and bread and bacon and booze and a big pan of mac-n-cheese and booze and egg nog and booze and enough cat food to keep us from getting gnawed on in our sleep, plus I'm on vacation for the next two weeks. Let it snow!
|
|
| Are you a Browncoat? |
[18 Dec 2009|10:48am] |
The folks over at "Browncoats: Redemption" are putting together some clips for their website and upcoming DVD. You might be surprised at who has participated thus far ...
Cross-posted to bc_redemption.
|
|
| a threaded processing queue in PyGTK |
[19 Dec 2009|12:30am] |
I'm currently writing a PyGTK client that needs to make network requests using a library that doesn't integrate with the GLib mainloop (python-suds), so I found myself wanting to be able to make network requests without blocking the mainloop, and getting callbacks in my main thread when operations were done. The pattern to use is clearly having a dedicated network thread. In C I might have used GAsyncQueue, however I've found myself quite liking queue.Queue.
The following is a fairly generic class for queuing asynchronous requests. Calling the add_request() method from the main thread queues a function to be run in the worker thread. If the callback or error keywords are provided, these will then be called from the GLib mainloop in the main thread (queued via g_idle_add).
from threading import Thread
from Queue import Queue
import gobject
class ThreadQueue(object):
def __init__(self):
self.q = Queue()
t = Thread(target=self._thread_worker)
t.setDaemon(True)
t.start()
def add_request(self, func, *args, **kwargs):
"""Add a request to the queue. Pass callback= and/or error= as
keyword arguments to receive return from functions or exceptions.
"""
self.q.put((func, args, kwargs))
def _thread_worker(self):
while True:
request = self.q.get()
self.do_request(request)
self.q.task_done()
def do_request(self, (func, args, kwargs)):
if 'callback' in kwargs:
callback = kwargs['callback']
del kwargs['callback']
else:
callback = None
if 'error' in kwargs:
error = kwargs['error']
del kwargs['error']
else:
error = None
try:
r = func(*args, **kwargs)
if not isinstance(r, tuple): r = (r,)
if callback: self.do_callback(callback, *r)
except Exception, e:
if error: self.do_callback(error, e)
else: print "Unhandled error:", e
def do_callback(self, callback, *args):
def _callback(callback, args):
callback(*args)
return False
gobject.idle_add(_callback, callback, args)
We can then inherit this class to provide setup for our specific application:
class WebService(ThreadQueue):
def __init__(self, guid=None, **kwargs):
"""Initialise the service. If guid is not provided, one will be
requested (returned in the callback). Pass callback= or error=
to receive notification of readiness."""
ThreadQueue.__init__(self)
self.guid = guid
self.add_request(self._setup_client, **kwargs)
def _setup_client(self):
print "Setting up client"
...
return self.guid
Which we call from our program like this:
class Client(object):
def __init__(self):
self.w = WebService(guid=guid, callback=self.client_ready)
def client_ready(self, guid):
print "client ready:", guid
gobject.threads_init()
Client()
gtk.main()
What's really cool though is adding methods to the API that are called asynchronously for you. Python makes this possible through the power of decorators. Add the following decorator to a method, and it instead of it being called directly, it will be added to the processing queue.
def async_method(func):
"""Makes the given method asynchronous, meaning when it is called it
will be queued with add_request.
"""
def bound_func(obj, *args, **kwargs):
obj.add_request(func, obj, *args, **kwargs)
return bound_func
class WebService(ThreadQueue):
@async_method
def GetStopInformation(self, stopNo):
print "Requesting information for stop", stopNo
...
And that's it! If you can't follow it, don't worry too much. This is possibly the most Pythonesque bit of code I've ever written, but I've tried to make it generic enough that other people can use it for whatever they need. It's currently part of my app that's beginning to take shape, but the source is here.
Incidently, Maemo people: are there Glade definition files allowing me to use Hildon widgets, GtkBuild and Glade 3? That would be super awesome if there were.
|
|
| Lies, damn lies, and... |
[16 Dec 2009|08:31pm] |
Coolio. http://www.livejournal.com/statistics/ (For paid/permanent accounts; widely announced in this news post and marta elaborates in paidmembers over here. Please direct all wank about it over to one of the community posts; thank you, drive through.)
If you don't want to show up in the "My Guests" stats (which means you don't get that data in your own stats either), you can check your privacy settings here and enable or disable it. For the record, I don't intend to enable it here
|
|
|
[15 Dec 2009|01:38pm] |
Update from the LJ advisory board user rep ( kylecassidy) regarding the reports that specifying gender on your profile would be made mandatory. (Short version: It won't be. Kyle's post has further information.)
So this is what it's like to have a user rep that doesn't disappear off the face of the earth post-election, eh?
|
|
| Prompt-ly |
[14 Dec 2009|03:37pm] |
Tangential to the meme currently making the rounds and inspired by the fact that I haven't really posted anything of substance (or even pretending to be) for a good long while, the floor is now open to questions. Anything you want to know? Leave questions in comments, I'll answer in a separate post.
Two-week vacation countdown: 4.5 days
|
|
| Noting more stuff read in the last several months |
[13 Dec 2009|08:29pm] |
- The Children of the Company - Kage Baker
- The Machine's Child - Kage Baker
- The Sons of Heaven - Kage Baker
- The Library: An Illustrated History - Stuart A.P. Murray
- The Fallen Sky: An Intimate History of Shooting Stars - Christopher Cokinos
- Worlds That Weren't - Harry Turtledove, Walter Jon Williams, S. M. Stirling, and Mary Gentle
- The World Without Us - Alan Weisman
- Lord Darcy - Randall Garrett
- The Island of Lost Maps - Miles Harvey (True cartographic crime story;
mactavish, you might like it.) - Peshawar Lancers - S.M. Stirling
- Childhood's End - Arthur C. Clarke
- To Your Scattered Bodies Go - Philip Jose Farmer
- Dead Boys - Richard Lange
- Boneshaker - Cherie Priest
- Dreadful Skin - Cherie Priest
- Blood Lite - Kevin J. Anderson (ed.)
- A Long Way Down - Nick Hornby
- Special Assignments - Boris Akunin
- Solaris - Stanislaw Lem
- Leviathan - Scott Westerfeld
- Soulless - Gail Carriger
- Heat Wave - Richard Castle (Best. Tie-in. Ever.)
- Remaking History and other stories - Kim Stanley Robinson
|
|
|
[13 Dec 2009|01:30pm] |
Been doing a pretty poor job of blogging my life lately. Mostly it's been photos and no text.
Took a week off from work (the week before last) because a number of our Perth friends came to visit. I've never dropped someone off and picked someone up from the airport in the same run before.
 It was a fun, but exhausting week that culminated with my 25th birthday. Not as traumatic as I might have anticipated 6 months ago. Ended up eating every meal out that day, breakfast at Grigons + Orr, lunch at Friends of the Earth, and dinner at the East Brunswick Club.
Went to Prahran on Monday for Jo's birthday (who is actually 2 days older than me). Turned out everyone there was vegan (I think?) but there weren't really that many vegan (veganisable) things on the menu. There somewhat of a dearth of vegan food south of the Yarra. Felt bad for the people who still ended up paying full-price for a seafood noodles minus the seafood.
 Also went to Fitzroy twice on Monday, once to have lunch with Steph between her meetings and then later that day with Furry (before heading on to Prahran). Thankfully I still managed a couple of early starts this week, and a few late evenings, so somehow I still managed to finish all my work by Friday (even with all the distractions). Worked on the telepathy-gabble codebase for the first time this week.
We became just that little bit more Victorian this week. The registration and insurance on our car was running out, so we had to transfer the car to Victorian registration. This meant new license plates.
 I've personally been very slack with doing any Christmas shopping. Although we have been to a lot of markets, at which I've seen a lot of great stuff, for the same couple of people, there are people who remain notoriously hard to find something useful and meaningful for (I hate just buying crap).
I think I'll propose family-based secret-Santa for next year. Steph's cousins do this. The way it works is everyone writes down a list of stuff they want, and it all gets put into an (electronic) hat, and then you buy a bunch of stuff for just one person. Plus instead of buying 10 books or DVDs or whatever you buy the person a larger present to the same cumulative value, allowing them to ask for something they want but may be unable to afford (without the hassle of asking everyone if they want to go shares in a gift).
Went to the Walk Against Warming yesterday. Estimates place the attendance at 40,000 people. Looking down Swanston St was kinda amazing. I didn't take any pictures, but given the number of cameras, I'm sure lots exist. We walked from the State Library down Swanston St, past Federation Square, to the Princes Bridge (which spans the Yarra), where we formed a human sign photographed by blimp (safe climate - do it: looks like this).
 by takver, CC BY-SA The sign took a while to make, so I was amazing sore and hungry by the end. Caught the tram back to Friends of the Earth for lunch and to see Steph (who had to miss the walk because of her FotE shift). Ended up wiping down the tables and packing things up so they could close for the afternoon before coming home to have a nap. SJ dropped by later that evening to drop around some Christmas noms, and have a cup of tea and a catch-up.
Spent all of today so far in my PJs. Taken some photos. Have made an attempt at fruit bread, but I think our yeast is stale. I had to put it in a warmed oven to get it to rise. It's just cooling now, so we'll see how it went in a bit. My brother is meant to be showing up tomorrow, having been in Melbourne for a University motorsport event (they built a car!).
|
|
| GTK+ is crushing my spirit |
[10 Dec 2009|06:53pm] |
I want a widget that is the combination of GtkComboBoxEntry and GtkEntryCompletion that can display a tree of options in a nice, indented way without the expanders (but with the rows expanded). Basically, a search box with a drop-down and hierarchical entries. I think I'm going to have to write my own, thought it sounds like something that might be more widely useful than just my application.
 Visited nixwilliams and daniel_bethany for a cup of tea, which become lunch (which was delicious) which became more tea, which became waiting out the rain and watching Nicholas Crane trip over a lot. Got wet going home anyway. Now waiting out the rain again before going to the shops. It's a good thing that I like rain; though mostly I like wearing a giant, warm jumper while it rains outside.
|
|
| navigation |
| [ |
viewing |
| |
most recent entries |
] |
|
|
|
|