Tuesday, 26 April 2011
Blog moved
Maintaining my own wordpress instance was getting tiresome so I've switched to blogger. Article information should still work just fine but comments are missing. My apologies!
Saturday, 16 April 2011
Building Python2.5 for Ubuntu 11.04
I run a few appengine instances and so I was quite disappointed after upgrading to Ubuntu 11.04 to find no pre-packaged versions of python2.5 (the version on which appengine is currently based). Python 2.7 is not compatible with various parts of the appengine dev server. After a bit of playing around this is the easiest way I found to get everything working that I needed. YMMV.
edit the top of dev_appengine.py and replace
with
Python 2.6 is not ideal but it seems to do the job. If you want to go the extra mile (as I did) and install Python 2.5.5, you need to manually add ssl and address some bad assumptions python makes about sqlite3's library locations...
edit the top of dev_appengine.py and replace
#!/usr/bin/env python
with
#!/usr/bin/env python2.6
Python 2.6 is not ideal but it seems to do the job. If you want to go the extra mile (as I did) and install Python 2.5.5, you need to manually add ssl and address some bad assumptions python makes about sqlite3's library locations...
Saturday, 16 October 2010
Announcing iLatitude: A Google Latitude Daemon for jailbroken iPhones.
I have wanted a native background Google Latitude app for a while now but the only offering seemed to be a $2 application in the Rock Your Phone app store called "Longitude". Sure I could have paid for the app but I figured I was due for a bit of self-study and having never written anything using Objective C, the latitude API or OAuth before, I set about reading. A few days of tinkering later and the app is fully functional! How unexpectedly painless. :)
The actual location handling code on the iPhone side is mostly thanks to Chris Alvares and his very useful tutorial on writing an iPhone Daemon. (Thanks Chris!)
You can access the source code for both the appengine side (OAuth, Latitude API) and iPhone side (setup application + background daemon) at github.
My next step is probably to get it pushed into a cydia repository somehow. (i.e. More research.)
PS. I also half suspect I'll receive an email from Apple's lawyers demanding I change the applications name but time will tell. :)
Tuesday, 13 July 2010
Arduino power meter reading
Being the curious nerd I am, I decided the other day that I really needed to put an end to argument that pulling the plug on a WiFi access point when not in use does or does not provide any significant power / cost saving benefits.
Armed with an Arduino Decimilla I rigged up a very simple app that samples an analogue value from a photo resistor and waits for a transition from light to dark and back to light again. A transition was defined as a 2 standard deviation change in the sampled light level based on the previous 32 sampled values. The number of values sampled every 20 minutes was written to EEPROM, providing up to a week of recording on my tiny 512 byte EEPROM.
An LED and photo-receptor with a cardboard sheeth around it (to stop direct light from the LED from shining on the sensor) were placed on the meter in front of the rotating disk and to my suprise, things just worked - really well. I didn't spend a long time confirming it worked well under very slow rotations (low power usage) and fast rotations (high power usage) but the times I checked on it, it seemed to be doing its job perfectly.
Results were not super suprising. The power usage late into the night was the air conditioner set to turn off around 2:30am. The spike in the morning was the air conditioner, microwave / toaster + lights and PC that basically all came on at once.

Some more testing is required to confirm or reject my hypothesis. Of course, if I used decent gear I could figure this out with a lot less effort but where would the fun be in that?
Armed with an Arduino Decimilla I rigged up a very simple app that samples an analogue value from a photo resistor and waits for a transition from light to dark and back to light again. A transition was defined as a 2 standard deviation change in the sampled light level based on the previous 32 sampled values. The number of values sampled every 20 minutes was written to EEPROM, providing up to a week of recording on my tiny 512 byte EEPROM.
An LED and photo-receptor with a cardboard sheeth around it (to stop direct light from the LED from shining on the sensor) were placed on the meter in front of the rotating disk and to my suprise, things just worked - really well. I didn't spend a long time confirming it worked well under very slow rotations (low power usage) and fast rotations (high power usage) but the times I checked on it, it seemed to be doing its job perfectly.
Results were not super suprising. The power usage late into the night was the air conditioner set to turn off around 2:30am. The spike in the morning was the air conditioner, microwave / toaster + lights and PC that basically all came on at once.

Some more testing is required to confirm or reject my hypothesis. Of course, if I used decent gear I could figure this out with a lot less effort but where would the fun be in that?
Sunday, 27 June 2010
KanjiVG + HTML5 Canvas = Free stroke animations for all!
I spent half the day yesterday at 梅.py (a python "hack-a-thon" event in Osaka hosted by Accense) writing a 100% HTML5 Kanji stroke renderer that makes use of the excellent open-source KanjiVG dataset. The result is not what I'd call production ready but it still works quite well:
http://nippongrammar.appspot.com/
The KanjiVG XML data is parsed and thrown into a Google appengine data source and a JSON interface is provided to query individual kanji. The queried kanji's stroke data is retuned along with a group of up to 63 other kanji to save on server round-trips (the grouping is static).
My next step is to move the data to static JSON files that can be hosted anywhere and write client-side code to download the appropriate kanji data files directly.
http://nippongrammar.appspot.com/
The KanjiVG XML data is parsed and thrown into a Google appengine data source and a JSON interface is provided to query individual kanji. The queried kanji's stroke data is retuned along with a group of up to 63 other kanji to save on server round-trips (the grouping is static).
My next step is to move the data to static JSON files that can be hosted anywhere and write client-side code to download the appropriate kanji data files directly.
Monday, 19 April 2010
Flash Quirks
IE Reserved Words for Method Names (and lack of debug message support?)
You know Internet Explorer is flakey when naming a method "play" or "stop" causes IE6,7,8 to give JavaScript errors.
A note for those with similar problems, this code cannot be used in IE.
You know Internet Explorer is flakey when naming a method "play" or "stop" causes IE6,7,8 to give JavaScript errors.
A note for those with similar problems, this code cannot be used in IE.
ExternalInterface.addCallback("play", play);
ExternalInterface.addCallback("stop", stop);
In my case, it gave this cryptic error: "オブジェクトでサポートされていないプロパティまたはメソッドです。" On line 48 of some unknown file. It took a little while to figure out what was going on!
Having done almost all of my debugging in Firefox, Chrome and Safari to date, I also didn't realise that IE won't correctly render uncaught Flash exceptions. NPAPI browsers seem to render these fine as popups but IE gives a similar confusing error to the above.
The Windows 7 64-bit SoundChannel Bug
Yet another sneaky little Flash 10.x bug that won't rear its ugly little head until you start using a 64-bit Win7 machine. The flash.media.Sound class creates a flash.media.SoundChannel instance every time you play a sound. An audio player app I made for work creates a new SoundChannel every time the user seeks in the audio file. Internally flash has a limit of 32 concurrent sounds it will mix.
On Win7 though, the mixing channel is not freed when the sound stops. It seems to persist for the lifespan of the SoundChannel instance. This, coupled with an infrequent garbage collection sweep interval makes it possible that all available mixing slots are in use, even though no sound is playing. I can't seem to find a reference to this particular bug elsewhere on the web. Anyone else seen this one? Any workarounds?
ExternalInterface.addCallback("stop", stop);
In my case, it gave this cryptic error: "オブジェクトでサポートされていないプロパティまたはメソッドです。" On line 48 of some unknown file. It took a little while to figure out what was going on!
Having done almost all of my debugging in Firefox, Chrome and Safari to date, I also didn't realise that IE won't correctly render uncaught Flash exceptions. NPAPI browsers seem to render these fine as popups but IE gives a similar confusing error to the above.
The Windows 7 64-bit SoundChannel Bug
Yet another sneaky little Flash 10.x bug that won't rear its ugly little head until you start using a 64-bit Win7 machine. The flash.media.Sound class creates a flash.media.SoundChannel instance every time you play a sound. An audio player app I made for work creates a new SoundChannel every time the user seeks in the audio file. Internally flash has a limit of 32 concurrent sounds it will mix.
On Win7 though, the mixing channel is not freed when the sound stops. It seems to persist for the lifespan of the SoundChannel instance. This, coupled with an infrequent garbage collection sweep interval makes it possible that all available mixing slots are in use, even though no sound is playing. I can't seem to find a reference to this particular bug elsewhere on the web. Anyone else seen this one? Any workarounds?
Thursday, 15 April 2010
A comparison of IPC methods for Mac OSX
For a project I'm working on, I needed to transfer 6 600x300@30fps video feeds from one process to potentially 6 others. Thats around 31MB/sec. It had to be fast as other processing, compression and decompression was also required simultaneously.
A survey of various IPC techniques was in order and I was surprised I couldn't find any similar comparisons on the web. I spent about a day running through various options and benchmarking my results in a not-so-rigorous-but-still-quite-useful way. I figured I'd post my results here in the hopes it saves someone a bit of time.
A survey of various IPC techniques was in order and I was surprised I couldn't find any similar comparisons on the web. I spent about a day running through various options and benchmarking my results in a not-so-rigorous-but-still-quite-useful way. I figured I'd post my results here in the hopes it saves someone a bit of time.
Subscribe to:
Posts (Atom)