<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hackdiary &#187; python</title>
	<atom:link href="http://www.hackdiary.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hackdiary.com</link>
	<description></description>
	<lastBuildDate>Wed, 10 Feb 2010 13:34:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Radio 1 takeover reprise</title>
		<link>http://www.hackdiary.com/2005/01/02/radio-1-takeover-reprise/</link>
		<comments>http://www.hackdiary.com/2005/01/02/radio-1-takeover-reprise/#comments</comments>
		<pubDate>Sun, 02 Jan 2005 22:58:09 +0000</pubDate>
		<dc:creator>Matt Biddulph</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.hackdiary.com/?p=66</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>Bank Holiday Monday comes around again in a few hours time, and I&#8217;m off to BBC Radio 1 to help out on another <a href="http://www.bbc.co.uk/radio1/djs/tenhour/">Ten Hour Takeover</a> show.</p>
<p><i>UPDATE:</i> <a href="http://pants.heddley.com/2005/01/03/2005-01-03.html#1104743596.959025">related random links and pictures</a>.</p>
<p><span id="more-66"></span><br />
There&#8217;s plenty of fun <a href="http://www.bbc.co.uk/radio1/djs/tenhour/works/6.shtml">python code</a> running behind the scenes (and some perl and java too), which you can read about in <a href="http://www.hackdiary.com/archives/000051.html">a previous entry on this site</a>. If you look closely, you can even see me in the studio in <a href="http://www.bbc.co.uk/radio1/djs/tenhour/aug04/backstage/">the backstage photo gallery</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackdiary.com/2005/01/02/radio-1-takeover-reprise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>python for perl programmers</title>
		<link>http://www.hackdiary.com/2004/12/10/python-for-perl-programmers/</link>
		<comments>http://www.hackdiary.com/2004/12/10/python-for-perl-programmers/#comments</comments>
		<pubDate>Fri, 10 Dec 2004 23:59:59 +0000</pubDate>
		<dc:creator>Matt Biddulph</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.hackdiary.com/?p=65</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>Tomorrow I&#8217;m giving a talk at the rather wonderful <a href="http://london.pm.org/lpw/">London Perl Workshop</a>. I&#8217;ve worked with quite a few languages in my time, including about 4 years or so of writing mostly perl. These days I write in python when I have a choice, so I&#8217;m going to give an introduction to python for perl programmers. <a href="http://www.hackdiary.com/slides/lpw2004/">Here are the slides</a>. Nothing fancy, just the basics.</p>
<p><span id="more-65"></span><br />
I&#8217;m most definitely not a GUI person, and I find Powerpoint quite distressing. I&#8217;m most happy authoring in VIM. This is the first time I&#8217;ve used <a href="http://www.meyerweb.com/eric/tools/s5/">Eric Meyer&#8217;s S5</a> HTML slide templates, and it&#8217;s been a very satisfying experience.</p>
<p>If you&#8217;re at the workshop, do come and have a chat. Should be a great Saturday.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackdiary.com/2004/12/10/python-for-perl-programmers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Taking automated webpage screenshots with embedded Mozilla</title>
		<link>http://www.hackdiary.com/2004/06/13/taking-automated-webpage-screenshots-with-embedded-mozilla/</link>
		<comments>http://www.hackdiary.com/2004/06/13/taking-automated-webpage-screenshots-with-embedded-mozilla/#comments</comments>
		<pubDate>Sun, 13 Jun 2004 14:35:11 +0000</pubDate>
		<dc:creator>Matt Biddulph</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.hackdiary.com/?p=58</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>The other day I discovered <a href="http://dev.upian.com/hotlinks/">Hotlinks</a>, a rather nice link aggregator. It collects links from sites (including those of a couple of my <a href="http://www.paranoidfish.org">respected</a> <a href="http://www.plasticbag.org">colleagues</a>) and combines them into a good-looking summary page. I particularly like the automatic webpage thumbnails it makes, which are created using <a href="http://www.babysimon.co.uk/khtml2png/">khtml2png</a>. I couldn&#8217;t get khtml2png to compile on my machine. After finding that there are now <a href="http://sourceforge.net/projects/pygtkmoz">python wrappers for GtkMozEmbed</a>, I made my own screenshotter-and-thumbnailer by embedding the Mozilla browser component using a little <a href="http://www.hackdiary.com/src/screenshot.py">python script</a>.</p>
<p><i>UPDATE:</i> Ross Burton picked up the script and <a href="http://www.burtonini.com/blog/computers/mozilla-thumbnail-20040614.xhtml">made a couple of enhancements</a>. Miguel de Icaza posted a <a href="http://primates.ximian.com/~miguel/all.html#6%2f14%2f2004%201%3a55%3a00%20PM">C# version</a>.</p>
<p><span id="more-58"></span><br />
To run, you&#8217;ll need PyGtkMoz, Gtk and the Python Imaging Library. Because it&#8217;s a GTK app, it needs an X server. To run headless, it&#8217;ll need an X server like Xnest or VNC. VNC&#8217;s working well for me.</p>
<p>The way it works is very simple:</p>
<p>Starting with the example.py shipped with PyGtkMoz, I created a stripped-down browser window app that loads a URL given on the commandline. By connecting the <code>net_stop</code> signal to a method, you can tell when network activity has finished. I couldn&#8217;t find a way to be notified when rendering has finished (images decompressed, etc) so I put in a 3 second pause here.</p>
<p>Following clues in <a href="http://mail.gnome.org/archives/gtk-app-devel-list/2003-December/msg00382.html"> a GTK mailing list post</a>, I wrote these lines to save a PNG of my widget&#8217;s window:</p>
<p><code>    window = self.widget.window</code><br />
<code>    (x,y,width,height,depth) = window.get_geometry()</code><br />
<code>    pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,width,height)</code><br />
<code>    pixbuf.get_from_drawable(window,self.widget.get_colormap(),0,0,0,0,width,height)</code><br />
<code>    pixbuf.save("<a href="http://www.hackdiary.com/misc/screenshot-hackdiary.png">screenshot.png</a>","png")</code></p>
<p>After that, producing a thumbnail just takes a few more lines of PIL code to open, thumbnail and save the PNG under a new name:</p>
<p><a href="http://www.hackdiary.com/misc/screenshot-hackdiary.png"><img src="http://www.hackdiary.com/misc/thumbnail-hackdiary.png"/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackdiary.com/2004/06/13/taking-automated-webpage-screenshots-with-embedded-mozilla/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Audioscrobbler meets the commandline</title>
		<link>http://www.hackdiary.com/2004/05/03/audioscrobbler-meets-the-commandline/</link>
		<comments>http://www.hackdiary.com/2004/05/03/audioscrobbler-meets-the-commandline/#comments</comments>
		<pubDate>Mon, 03 May 2004 22:50:14 +0000</pubDate>
		<dc:creator>Matt Biddulph</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.hackdiary.com/?p=55</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been around for a while, but suddenly <a href="http://cityofsound.typepad.com/">everyone&#8217;s</a> <a href="http://www.gyford.com/phil/writing/2004/04/15/audioscrobbler.php">talking</a> about <a href="http://www.audioscrobbler.com">audioscrobbler</a> again. I got interested when I saw a talk about <a href="http://last.fm">last.fm</a> at <a href="http://www.music.columbia.edu/pipermail/dorkbotlondon-blabber/2004-February/000277.html">dorkbot</a> a few months back. It&#8217;s based on the simple idea of instrumenting your music player to send a ping to a central site every time you&#8217;re listening to a track. Going further than just a &#8216;now playing&#8217; on a sidebar on your website, this leads to a world of potential new music toys using collaborative filtering and the like.</p>
<p>At home I play all my music from the commandline: my mp3 jukebox has no fancy user interface, I just SSH into it. Audioscrobbler have several player plugins for <a href="http://www.audioscrobbler.com/download.php">download</a>, but no commandline interface. I wrote myself some <a href="http://www.hackdiary.com/src/scrobbler.py">python code to play MP3s and talk to audioscrobbler</a> so that I could keep <a href="http://www.audioscrobbler.com/user/biddulph">my profile</a> up to date.</p>
<p><span id="more-55"></span><br />
Popping onto the <a href="irc://irc.phasenet.co.uk/audioscrobbler">audioscrobbler IRC channel</a>, I found <a href="http://www.audioscrobbler.com/user/Russ">Russ</a> and <a href="http://www.audioscrobbler.com/user/RJ">RJ</a>, two key guys behind the system. They were very helpful, sorting me out with a client ID for testing and giving debugging tips.</p>
<p>As so often happens, the python community had already supplied all the libraries I need to make the guts of my system: <a href="http://spacepants.org/src/pymad/">pymad</a> to decode MP3s, <a href="http://freshmeat.net/projects/pyao/">pyao</a> for audio output, <a href="http://pyid3lib.sourceforge.net/">pyid3lib</a> to read ID3 tags. Building the code was just a matter of following the protocol documentation and writing about 100 lines to stick it all together.</p>
<p>The <a href="http://wiki.audioscrobbler.com/index.php/Protocol1.1">Audioscrobbler protocol</a> is very nice. Top marks for using the web the way it was designed, letting me GET the details I need to start a session (MD5 challenge, URL to submit to, etc) and then POST my information to affect my user profile. The protocol used within the transaction doesn&#8217;t use RDF or XML, which would be my choice, but it is nice and simple, reminiscent of traditional text-based internet protocols such as SMTP and POP3.</p>
<p>Now I&#8217;ve reached this simple goal (a commandline MP3 player with no controls that submits &#8216;now playing&#8217; information), I&#8217;d like to take it further. If I had a newer iPod, it&#8217;d be great to write a bit of code to submit tracks I&#8217;ve been playing on the move to my profile, but sadly my iPod is of too early a generation to have that feature. More interestingly, I look forward to being able to make use of audioscrobbler&#8217;s analysis to build my own playlists and discover new music. For now this is mostly only doable through the audioscrobbler site, but there are also <a href="http://www.audioscrobbler.com/development.php">data dumps</a> available. It&#8217;d be great to have a combination of the two &#8211; an online REST query interface that gives machine-readable results.</p>
<p>Oh, and don&#8217;t forget&#8230; <a href="http://www.audioscrobbler.com/donate.php">donate to Audioscrobbler</a> and keep a great project online.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackdiary.com/2004/05/03/audioscrobbler-meets-the-commandline/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Moyles-proof code</title>
		<link>http://www.hackdiary.com/2004/04/11/moyles-proof-code/</link>
		<comments>http://www.hackdiary.com/2004/04/11/moyles-proof-code/#comments</comments>
		<pubDate>Sun, 11 Apr 2004 14:32:17 +0000</pubDate>
		<dc:creator>Matt Biddulph</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.hackdiary.com/?p=54</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>While the rest of the UK was enjoying a Good Friday lie-in, I dragged myself into Yalding House (home of <a href="http://www.bbc.co.uk/radio1/">BBC Radio 1</a>) at 7.30am. I was there to see our new text message system get its first live broadcast use on the Chris Moyles show in a preview of the  <a href="http://www.bbc.co.uk/radio1/djs/tenhour/index.shtml">Ten Hour Takeover</a>.</p>
<p><span id="more-54"></span><br />
<i>This is a long piece&#8230; <a href="#on-air">skip to the end</a> if you want to see how it went on the day.</i></p>
<h4>The project</h4>
<p>I work for the beeb at Radio and Music Interactive, in the software architecture team. We&#8217;re responsible for the behind-the-scenes plumbing, running the systems behind things like <a href="http://www.bods.me.uk/rantnrave/2003/09/26/dab_text_on_bbci_radio_stations.live">LiveText</a>, and providing toolkits for the guys on the apps team who build public services. When Radio 1 came up with the takeover day (ten hours of radio with music selected entirely by the listeners via text message and phone), they asked us to build them something to deal with the expected deluge of messages.</p>
<p>As you probably know, <a href="http://news.bbc.co.uk/1/hi/technology/3368815.stm">text messaging is huge in the UK</a> and it&#8217;s been taken up enthusiastically by the BBC&#8217;s radio networks. Radio 1&#8242;s incoming SMS provider have a web console that&#8217;s used by the broadcast assistants and DJs in the studio. It works rather like an email inbox, and like most email clients the user interface treats the incoming messages as a chronological stream of text rather than a database to be mined for information. This works for running a regular radio show, but the takeover day needs special treatment.</p>
<p>Since the web console had been enough for the networks so far, this was our department&#8217;s first project based on machine-processing of SMS.  Knowing how important text is to the radio networks, we wanted to build a foundation of components that would support future applications. As every software engineer knows, it&#8217;s hard to &#8220;<a href="http://www.amazon.co.uk/exec/obidos/ASIN/0201835959/">build one to throw away</a>&#8221; after the users have got their hands on it.</p>
<h4>The build</h4>
<p>In our team the language of choice is Python, whereas the apps team prefer Perl. Contrary to what some might expect, this mixed economy hasn&#8217;t yet given us any interop problems. We&#8217;re very keen on using abstractions such as <a href="http://www.spread.org">asynchronous messaging</a>, <a href="http://internet.conveyor.com/RESTwiki/moin.cgi/FrontPage">REST</a>ful web services and relational databases to act as language-agnostic intermediaries for our data flows.</p>
<p>My immediate thoughts about the architecture were that it should be built from a series of loosely-coupled layers. Even solving the simple problem of how to pull in a high-volume external XML feed of text messages and redistribute it to applications would show benefits later if it was simple to hook new code into. Further layers could process the data, with a web user interface layered on top of that. Working from a specification of the XML format used by the provider, Paul Clifford quickly built a gateway that collected messages and rebroadcast them over a message bus. Using asynchronous messaging as a transport gives us a good level of resilience and clusterability for free, while keeping the logic very simple. Building on this, he then started work on code to push messages sent to Radio 1 into a database and analyse their contents.</p>
<p>We wanted to provide simple, useful features to the users such as freetext search, but we thought we could do more given that the incoming texts would have a certain amount of implicit structure. The programme was going to ask people to text in &#8220;Artist &#8211; Track &#8211; Name &#8211; Dedication&#8221;, but we assumed that there would be a lot of variation in the accuracy of the texts and a lack of consistent punctuation to act as delimiters. We planned a system of &#8216;fuzzy matching&#8217; to group together texts using stopwords, sounds-alike phonetic matching and statistical analysis of text prefixes. If you see enough text strings beginning with words that sound like &#8220;Bob Dylan&#8221; then you can start to guess that Bob Dylan might be an artist, rather than a track called Dylan by a band named Bob. Paul did some great work on refining these techniques, and an on-air test a few weeks before the real broadcast showed that we could pretty accurately infer that &#8220;Weezer&#8221;, &#8220;Wheezer&#8221;, &#8220;Weazer&#8221; and &#8220;Wheeser&#8221; were all the creators of tracks called &#8220;Buddy Holly&#8221;, &#8220;Budy Holly&#8221; and &#8220;Buddy Holy&#8221;.</p>
<p>While Paul worked on the analysis, I created a Perl wrapper around the database so that the apps team could get to work on the user interface. At the same time, I passed on a few lines of sample client code to <a href="http://interconnected.org/home">Matt Webb</a> to see what he could do with it. When working on a toolkit or API, I always like to have more than one client using it, to make sure that the requirements of the main project haven&#8217;t kept the interface from being generic and useful in other contexts. He built a nice rolling graph of texts received per minute, tapping in at the message bus layer. As with any messaging system, adding a new message recipient affected neither the code providing the messages nor any other clients of the bus. Neil Slater and Conal Jones in the apps team did great work building a web interface with guidance from the Radio 1 team, and within a few weeks we were ready to go live.</p>
<h4 id="on-air">On air</h4>
<p>Chris Moyles likes to break things. He once managed to get listeners to send <a href="http://www.chrismoyles.net/mw/coranto/Radio_Reviews/Radio_Reviews-archive-8-2003.shtml#newsitemEpykpAuullxrucLuEy">14,000 texts at once</a>. When I arrived, <a href="http://www.bbc.co.uk/radio1/chrismoyles/biography/#aled">Aled the BA</a> asked me how many messages the new system could take, and told me that Chris was going to do his best to overload it. At 8.45am, Chris started trailing the feature, and the text messages started trickling in. Then flooding. I was impressed: on a UK Bank Holiday, thousands of people were not just listening but involved enough to get on their phones and interact with the programme.</p>
<p>Chris and his team did a great job of understanding our system. They caught onto the freetext search right away and used it to find interesting tracks, and messages to read out from people who requested them. We put a &#8216;quick stats&#8217; box on every screen of the app, which they used to goad on the listeners: &#8220;3000 text messages so far. That is simply not enough. I want that quadrupled!&#8221;. Once there were enough messages in the system for the pattern matching to kick in, they used it to navigate through the data and see which tracks by which artists were getting the most attention. As the listeners realised that the playlist had gone out the window and they could request anything, we got some great stuff coming in. Our system even got a little mention on air as Chris teased us for matching an Elvis Costello track to a bunch of requests for Elvis.</p>
<p>As the programme started I was sitting nervously next-door to the studio tailing logfiles and watching process tables, but as it went on and the code coped with everything they could throw at it, I relaxed and enjoyed the show. I don&#8217;t normally listen to the Radio 1 Breakfast Show but listening to this gave me new respect for the skills of a daytime DJ, sitting in a tiny room in a basement working a crowd of millions that they never see.</p>
<p>If you want to hear the show, there&#8217;s a <a href="http://www.bbc.co.uk/radio/aod/rpms/r1moylesfri.rpm">Listen Again</a> stream available from the BBC until April 16th. The request section is in the last hour. Tune into Radio 1 on Monday April 12th from 10am for the ten hour version.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackdiary.com/2004/04/11/moyles-proof-code/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Work at the BBC</title>
		<link>http://www.hackdiary.com/2004/03/08/work-at-the-bbc/</link>
		<comments>http://www.hackdiary.com/2004/03/08/work-at-the-bbc/#comments</comments>
		<pubDate>Mon, 08 Mar 2004 22:18:26 +0000</pubDate>
		<dc:creator>Matt Biddulph</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.hackdiary.com/?p=49</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s <a href="http://www.bbc.co.uk/jobs/e73114.shtml">a job</a> being advertised at BBC Radio and Music Interactive in London, where I work. It involves Python, XML, CMSes, digital radio and other interesting technologies. You&#8217;d like it there.</p>
<p><em>UPDATE: Applications have now closed.</em></p>
<p><em>FURTHER UPDATE: for unknown reasons, this page is (at the time of writing) number one hit on google for the search term <a href="http://www.google.com/search?hl=en&amp;ie=UTF-8&amp;oe=UTF-8&amp;q=work+at+the+bbc&amp;btnG=Google+Search">work at the bbc</a> (and perhaps some similar terms). For those who come here looking for work, I suggest you look at the <a href="http://www.bbc.co.uk/jobs/">BBC Jobs site</a> or perhaps <a href="http://www.bbc.co.uk/talent/">BBC Talent</a>, where budding writers, presenters and DJs are sought.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackdiary.com/2004/03/08/work-at-the-bbc/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Source distribution for Chumpologica now available</title>
		<link>http://www.hackdiary.com/2004/01/24/source-distribution-for-chumpologica-now-available/</link>
		<comments>http://www.hackdiary.com/2004/01/24/source-distribution-for-chumpologica-now-available/#comments</comments>
		<pubDate>Sat, 24 Jan 2004 19:05:17 +0000</pubDate>
		<dc:creator>Matt Biddulph</dc:creator>
				<category><![CDATA[foaf]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rdf]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://www.hackdiary.com/?p=46</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>Now available: the first source distribution of <a href="http://www.hackdiary.com/projects/chumpologica/">Chumpologica</a>, the system behind <a href="http://www.planetrdf.com">Planet RDF</a> and the <a href="http://pants.heddley.com/logica/">Daily Chump Chumpologica</a>.</p>
<p><span id="more-46"></span><br />
Although source for an earlier version was <a href="http://www.hackdiary.com/archives/000036.html">previously available</a>, this new version 1.0 includes all the improvements made by myself and <a href="http://journal.dajobe.org">Dave Beckett</a> for Planet RDF. I&#8217;ve also refactored the code to use an external configuration file, and packaged it up using python distutils with a simple control script. This means that a single global installation of the system can be used to run multiple clogica sites on a single machine. It&#8217;ll also make it easy to build distribution packages for Redhat and Debian.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackdiary.com/2004/01/24/source-distribution-for-chumpologica-now-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dumping Geo RDF from Garmin GPS units</title>
		<link>http://www.hackdiary.com/2003/09/21/dumping-geo-rdf-from-garmin-gps-units/</link>
		<comments>http://www.hackdiary.com/2003/09/21/dumping-geo-rdf-from-garmin-gps-units/#comments</comments>
		<pubDate>Sun, 21 Sep 2003 19:41:08 +0000</pubDate>
		<dc:creator>Matt Biddulph</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[rdf]]></category>

		<guid isPermaLink="false">http://www.hackdiary.com/?p=43</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>Having <a href="/archives/000039.html">connected my GPS unit to my laptop</a>, it was time to dump the data off into a usable RDF model.</p>
<p><span id="more-43"></span><br />
There&#8217;s a useful RDF Interest Group <a href="http://www.w3.org/2003/01/geo/">Geo namespace</a> for describing simple lat/long/alt properties of points, so using<br />
<a href="http://pygarmin.sourceforge.net/">PyGarmin</a> I wrote <a href="/src/garmin2rdf.py">some code</a> to pull off the waypoints and tracklogs and produce a model like <a href="/rdf/tracks.rdf">this</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackdiary.com/2003/09/21/dumping-geo-rdf-from-garmin-gps-units/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>XML TV Listings in RDF</title>
		<link>http://www.hackdiary.com/2003/09/07/xml-tv-listings-in-rdf/</link>
		<comments>http://www.hackdiary.com/2003/09/07/xml-tv-listings-in-rdf/#comments</comments>
		<pubDate>Sun, 07 Sep 2003 17:18:33 +0000</pubDate>
		<dc:creator>Matt Biddulph</dc:creator>
				<category><![CDATA[bots]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.hackdiary.com/?p=41</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>In preparation for a TiVoBot that I&#8217;m planning to write as a wrapper for scheduling <a href="/archives/000018.html">digital WinTV recordings</a>, I&#8217;ve been looking at TV listings data produced by tools from the <a href="http://membled.com/work/apps/xmltv/">XMLTV</a> project. I started out using the XML directly and storing it using <a href="http://www.sleepycat.com/xml">Berkeley DB XML</a> but soon found (like most of my projects) that I&#8217;d be happier if the data was expressed as an RDF model.</p>
<p><span id="more-41"></span><br />
The current <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/xmltv/xmltv/xmltv.dtd?rev=1.27">XMLTV DTD</a> turns out to be pretty <a href="http://www.xml.com/pub/a/2002/10/30/rdf-friendly.html">RDF-friendly</a> in its structure. This <a href="/rdf/xmltv.xml">XML example</a> looks very similar <a href="/rdf/rdftv.rdf">as RDF</a> (<a href="/rdf/rdftv.png">graph</a>). The major changes I made in the translation were in assigning URIs to channels and programme categories, using identifiers such as <code>http://xmlns.com/2003/rdftv/channel#bbc3.bbc.co.uk</code> and <code>http://xmlns.com/2003/rdftv/category/ananova#News/CurrentAffair</code>, and giving the tv data a namespace under <a href="http://xmlns.com">http://xmlns.com</a>. The conversion is performed by <a href="/rdf/xmltv2rdf.xsl">some XSLT</a>.</p>
<p>Taking a <a href="/rdf/rdftv_complete.rdf">complete TV feed as RDF</a>, I can now write <a href="/src/tv.py">query code</a> using <a href="http://www.redland.opensource.ac.uk">Redland</a> and Python to print out details of all films on TV this week.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackdiary.com/2003/09/07/xml-tv-listings-in-rdf/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Ericsson Bluetooth phone as remote control</title>
		<link>http://www.hackdiary.com/2003/08/03/ericsson-bluetooth-phone-as-remote-control/</link>
		<comments>http://www.hackdiary.com/2003/08/03/ericsson-bluetooth-phone-as-remote-control/#comments</comments>
		<pubDate>Sun, 03 Aug 2003 23:36:27 +0000</pubDate>
		<dc:creator>Matt Biddulph</dc:creator>
				<category><![CDATA[hardware]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.hackdiary.com/?p=40</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>After seeing Richard Clamp&#8217;s excellent talk at a london.pm techmeet on <a href="http://unixbeard.net/~richardc/cgi/blog.cgi/dea.pod/">using Ericsson phones as remote controls</a> I went away to code something similar (but less fully-functioned) in python for my own use. My code plugs into the <a href="http://www.twistedmatrix.com/">Twisted</a> framework and listens for phone keypress events. It uses the AT commands defined in <a href=" http://www.ericsson.com/mobilityworld/developerszonedown/downloads/docs/r320/R320s_WP_R1A.pdf">an Ericsson PDF for the R320 phone</a>, and it works with my T610.</p>
<p><span id="more-40"></span><br />
My main need for a remote was for controlling slides when doing presentations, so I looked into how to send fake keypresses to X applications. My presentation format of choice is PDFs, so I just needed to be able to send PgUp and PgDown events to Acrobat Reader.</p>
<p>X has a useful extension called XTEST that is designed to help automated testing of GUI apps. It has <a href="http://member.nifty.ne.jp/tsato/xvkbd/events.html">a fairly simple API</a>, and with the help of the source of the <a href="http://search.cpan.org/author/CTRONDLP/X11-GUITest-0.16/">X11::GUITest CPAN module</a> I created a python extension that lets me write code such as <code>keycontrol.tapkey('PGU')</code> to simulate tapping on the PgUp key.</p>
<p>The <a href="/src/blueremote-1.0.tar.gz">resulting code</a> defines an <code>Ericsson</code> class that can be subclassed to receive events such as <code>cursor_left</code> and <code>camera</code> when the keys are pressed on the phone. It helps to have the keypad lock activated when using it so that you don&#8217;t end up triggering events on the phone itself.</p>
<p>Libby Miller took <a href="http://swordfish.rdfweb.org/photos/2003/07/30/2003-07-30-Pages/Image3.html">a photo of me using it</a> at the <a href="http://www.xmlsummerschool.com">XML Summer School</a> Semantic Web forum, where it came in very handy. The phone is just visible in my right hand.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackdiary.com/2003/08/03/ericsson-bluetooth-phone-as-remote-control/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
