<?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>LuckyDonkey &#187; Code</title>
	<atom:link href="http://www.luckydonkey.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.luckydonkey.com</link>
	<description>Never knowingly knowing narwhals</description>
	<lastBuildDate>Wed, 17 Mar 2010 01:05:54 +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>FreeBSD 7.0: installing psycopg 2.07</title>
		<link>http://www.luckydonkey.com/2008/07/23/freebsd-70-installing-psycopg-207/</link>
		<comments>http://www.luckydonkey.com/2008/07/23/freebsd-70-installing-psycopg-207/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 17:37:35 +0000</pubDate>
		<dc:creator>dazza</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.luckydonkey.com/?p=209</guid>
		<description><![CDATA[While setting up a new FreeBSD 7.0 server I found that psycopg 2.0.7 doesn't easy_install on FreeBSD. It's because of a configuration problem in config.h at the bottom. #if defined(__FreeBSD__) &#124;&#124; (defined(_WIN32) &#38;&#38; !defined(__GNUC__)) &#124;&#124; defined(__sun__) /* what's this, we have no round function either? */ static double round&#40;double num&#41; &#123; return &#40;num &#62;= 0&#41; [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-9998980871049158";
//468x60, created 11/22/07
google_ad_slot = "6052810016";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>While setting up a new FreeBSD 7.0 server I found that psycopg 2.0.7 doesn't easy_install on FreeBSD. It's because of a configuration problem in config.h at the bottom.</p>
<pre class="cpp"><span style="color: #339900;">#if defined(__FreeBSD__) || (defined(_WIN32) &amp;&amp; !defined(__GNUC__)) || defined(__sun__)</span>
<span style="color: #ff0000; font-style: italic;">/* what's this, we have no round function either? */</span>
<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">double</span> round<span style="color: #000000;">&#40;</span><span style="color: #0000ff;">double</span> num<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
  <span style="color: #0000ff;">return</span> <span style="color: #000000;">&#40;</span>num &gt;= <span style="color: #0000dd;">0</span><span style="color: #000000;">&#41;</span> ? <span style="color: #0000dd;">floor</span><span style="color: #000000;">&#40;</span>num + <span style="color: #0000dd;">0.5</span><span style="color: #000000;">&#41;</span> : <span style="color: #0000dd;">ceil</span><span style="color: #000000;">&#40;</span>num - <span style="color: #0000dd;">0.5</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
<span style="color: #339900;">#endif</span>
&nbsp;</pre>
<p>However 'round' is defined in FreeBSD and has been since FreeBSD 5.3 (according to the manual page). The fix is simple, just remove the 'defined(__FreeBSD__) ||' part of the '#if' and you should be fine. Now you can 'easy_install .' psycopg2.</p>
<p>PS: I'd tried to raise a ticket but http://www.initd.org/ trac seems to have been down for ages.</p>
<p><map name='google_ad_map_209_afea9fcd39d8b84a'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/209?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_209_afea9fcd39d8b84a' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=209&amp;url= http%3A%2F%2Fwww.luckydonkey.com%2F2008%2F07%2F23%2Ffreebsd-70-installing-psycopg-207%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.luckydonkey.com/2008/07/23/freebsd-70-installing-psycopg-207/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Mac OSX: starting postgres on boot</title>
		<link>http://www.luckydonkey.com/2008/07/03/mac-osx-starting-postgres-on-boot/</link>
		<comments>http://www.luckydonkey.com/2008/07/03/mac-osx-starting-postgres-on-boot/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 16:57:41 +0000</pubDate>
		<dc:creator>dazza</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.luckydonkey.com/?p=208</guid>
		<description><![CDATA[Every bloody operating system has it's own unique way of starting things at boot time. Today I bothered to learn how OS X does it. Here's how I got PostgreSQL to start when my machine is turned on: What gets started is handled by a program called SystemStarter. On boot it looks through /Library/StartupItems for [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-9998980871049158";
//468x60, created 11/22/07
google_ad_slot = "6052810016";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>Every bloody operating system has it's own unique way of starting things at boot time. Today I bothered to learn how OS X does it. Here's how I got PostgreSQL to start when my machine is turned on:</p>
<p>What gets started is handled by a program called SystemStarter. On boot it looks through /Library/StartupItems for folders. Inside those folders it looks for a script with the same name as the folder and a plist called StartupParameters.plist.</p>
<p>So as super user:</p>
<pre class="bash"><span style="color: #7a0874; font-weight: bold;">cd</span> /Library/StartupItems/
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> PostgreSQL
<span style="color: #c20cb9; font-weight: bold;">touch</span> PostgreSQL/PostgreSQL
<span style="color: #c20cb9; font-weight: bold;">touch</span> PostgreSQL/StartupParameters.plist
&nbsp;</pre>
<p>Now we need to fill in the details. In PostgreSQL/PostgreSQL enter:</p>
<pre class="bash"><span style="color: #808080; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">sudo</span> -u postgres /usr/<span style="color: #7a0874; font-weight: bold;">local</span>/pgsql/bin/pg_ctl -D /usr/<span style="color: #7a0874; font-weight: bold;">local</span>/pgsql/data -l /usr/<span style="color: #7a0874; font-weight: bold;">local</span>/pgsql/data/logfile start</pre>
<p>This is a long line, but it's basically running postgres (via pg_ctl) as the user postgres. You'll need to change this to the whatever user you run postgres as and where ever your install of postgres is. I've used the standard names and directories so it's likely this will work for you too.</p>
<p>Now lets look at the plist. This file contains information for SystemStarter about when to start postgres, what postgres needs and provides and any messages to print to log files:</p>
<pre class="xml">&nbsp;
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="font-weight: bold; color: black;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE plist SYSTEM &quot;file://localhost/System/Library/DTDs/PropertyList.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;plist</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.9&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dict<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;key<span style="font-weight: bold; color: black;">&gt;</span></span></span>Description<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/key<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;string<span style="font-weight: bold; color: black;">&gt;</span></span></span>PostgreSQL<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/string<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;key<span style="font-weight: bold; color: black;">&gt;</span></span></span>Messages<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/key<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dict<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;key<span style="font-weight: bold; color: black;">&gt;</span></span></span>start<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/key<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;string<span style="font-weight: bold; color: black;">&gt;</span></span></span>Starting PostgreSQL<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/string<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;key<span style="font-weight: bold; color: black;">&gt;</span></span></span>stop<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/key<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;string<span style="font-weight: bold; color: black;">&gt;</span></span></span>Stopping PostgreSQL<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/string<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dict<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;key<span style="font-weight: bold; color: black;">&gt;</span></span></span>OrderPreference<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/key<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;string<span style="font-weight: bold; color: black;">&gt;</span></span></span>None<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/string<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;key<span style="font-weight: bold; color: black;">&gt;</span></span></span>Provides<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/key<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;array<span style="font-weight: bold; color: black;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;string<span style="font-weight: bold; color: black;">&gt;</span></span></span>PostgreSQL<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/string<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/array<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dict<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/plist<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>You can test your new settings by typing sudo SystemStarter -n -D, fix any error messages, reboot and you should have postgres all the time <img src='http://www.luckydonkey.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><map name='google_ad_map_208_afea9fcd39d8b84a'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/208?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_208_afea9fcd39d8b84a' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=208&amp;url= http%3A%2F%2Fwww.luckydonkey.com%2F2008%2F07%2F03%2Fmac-osx-starting-postgres-on-boot%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.luckydonkey.com/2008/07/03/mac-osx-starting-postgres-on-boot/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>More command line meme data</title>
		<link>http://www.luckydonkey.com/2008/04/11/more-command-line-meme-data/</link>
		<comments>http://www.luckydonkey.com/2008/04/11/more-command-line-meme-data/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 10:22:19 +0000</pubDate>
		<dc:creator>dazza</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Rant]]></category>

		<guid isPermaLink="false">http://www.luckydonkey.com/2008/04/11/more-command-line-meme-data/</guid>
		<description><![CDATA[Since everyone else is doing this... I thought I would join in dazza@macpro:~&#62;history&#124;awk '{a[$2]++ } END{for(i in a){print a[i] &#34; &#34; i}}' &#124;sort -rn&#124;head 96 svn 85 python 44 nosetests 40 ./start-tgmetalinfo.py 37 ssh 28 tgenv 20 mate 16 cd 14 curl 13 ls &#160; that's a bit weird. I do a lot of svn [...]]]></description>
			<content:encoded><![CDATA[<p>Since everyone else is doing this... I thought I would join in</p>
<pre class="bash">dazza@macpro:~&gt;history|awk <span style="color: #ff0000;">'{a[$2]++ } END{for(i in a){print a[i] &quot; &quot; i}}'</span> |sort -rn|head
<span style="color: #000000;">96</span>	svn
<span style="color: #000000;">85</span>	python
<span style="color: #000000;">44</span>	nosetests
<span style="color: #000000;">40</span>	./start-tgmetalinfo.py
<span style="color: #000000;">37</span>	<span style="color: #c20cb9; font-weight: bold;">ssh</span>
<span style="color: #000000;">28</span>	tgenv
<span style="color: #000000;">20</span>	mate
<span style="color: #000000;">16</span>	<span style="color: #7a0874; font-weight: bold;">cd</span>
<span style="color: #000000;">14</span>	curl
<span style="color: #000000;">13</span>	<span style="color: #c20cb9; font-weight: bold;">ls</span>
&nbsp;</pre>
<p>that's a bit weird. I do a lot of svn as I merge from development to release. I'm surprised (and pleased) to see nosetests (unit test suite) being called so frequently. tgenv is an alias I have for setting up my workingenv for TurboGears (I have many different version of turbogears installed). mate is the command line call to TextMate (text editor) from the current directory. I think the curls are there from debugging calls to AWS (Amazon Web Services).</p>
<p><map name='google_ad_map_187_afea9fcd39d8b84a'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/187?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_187_afea9fcd39d8b84a' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=187&amp;url= http%3A%2F%2Fwww.luckydonkey.com%2F2008%2F04%2F11%2Fmore-command-line-meme-data%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.luckydonkey.com/2008/04/11/more-command-line-meme-data/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Email HMTL standards</title>
		<link>http://www.luckydonkey.com/2008/04/11/email-hmtl-standards/</link>
		<comments>http://www.luckydonkey.com/2008/04/11/email-hmtl-standards/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 09:09:12 +0000</pubDate>
		<dc:creator>dazza</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[NewMetalArmy]]></category>
		<category><![CDATA[Rant]]></category>

		<guid isPermaLink="false">http://www.luckydonkey.com/2008/04/11/email-hmtl-standards/</guid>
		<description><![CDATA[I've been avoiding sending email from New Metal Army because it is SO hard to make it look good (without resorting to HMTL hacks and tables). I wish the Email Standards project good luck. Come on google... don't be evil Email Standards Project - Gmail Grimaces from Mathew Patterson on Vimeo.]]></description>
			<content:encoded><![CDATA[<p>I've been avoiding sending email from <a href="http://www.newmetalarmy.com/"><span style="color:#00923e;">New Metal Army</span></a> because it is SO hard to make it look good (without resorting to HMTL hacks and tables). I wish the Email Standards project good luck. Come on google... don't be evil <img src='http://www.luckydonkey.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><object type="application/x-shockwave-flash" width="400" height="302" data="http://www.vimeo.com/moogaloop.swf?clip_id=873823&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color="><param name="quality" value="best" /><param name="allowfullscreen" value="true" /><param name="scale" value="showAll" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=873823&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=" /></object><br /><a href="http://www.vimeo.com/873823/l:embed_873823">Email Standards Project - Gmail Grimaces</a> from <a href="http://www.vimeo.com/user430977/l:embed_873823">Mathew Patterson</a> on <a href="http://vimeo.com/l:embed_873823">Vimeo</a>.</p>
<p><map name='google_ad_map_186_afea9fcd39d8b84a'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/186?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_186_afea9fcd39d8b84a' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=186&amp;url= http%3A%2F%2Fwww.luckydonkey.com%2F2008%2F04%2F11%2Femail-hmtl-standards%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.luckydonkey.com/2008/04/11/email-hmtl-standards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microcontroller Demo Scene</title>
		<link>http://www.luckydonkey.com/2008/04/10/microcontroller-demo-scene/</link>
		<comments>http://www.luckydonkey.com/2008/04/10/microcontroller-demo-scene/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 21:31:29 +0000</pubDate>
		<dc:creator>dazza</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://www.luckydonkey.com/2008/04/10/microcontroller-demo-scene/</guid>
		<description><![CDATA[There is something really fucking cool about making demos and there is something even more cool about making the hardware it runs on as well. I should point out that I came across this video when reading Make Magazines RSS Feed.]]></description>
			<content:encoded><![CDATA[<p>There is something really fucking cool about making demos and there is something even more cool about making the hardware it runs on as well.</p>
<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/sNCqrylNY-0&hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/sNCqrylNY-0&hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
<p>I should point out that I came across this video when <a href="http://blog.makezine.com/archive/2008/04/sx48_microcontroller_musi.html?CMP=OTC-0D6B48984890">reading</a> <a href="http://blog.makezine.com/">Make Magazine</a>s RSS Feed.</p>
<p><map name='google_ad_map_185_afea9fcd39d8b84a'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/185?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_185_afea9fcd39d8b84a' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=185&amp;url= http%3A%2F%2Fwww.luckydonkey.com%2F2008%2F04%2F10%2Fmicrocontroller-demo-scene%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.luckydonkey.com/2008/04/10/microcontroller-demo-scene/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Data Visualisation</title>
		<link>http://www.luckydonkey.com/2008/02/21/data-visualisation/</link>
		<comments>http://www.luckydonkey.com/2008/02/21/data-visualisation/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 20:59:40 +0000</pubDate>
		<dc:creator>dazza</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://www.luckydonkey.com/2008/02/21/data-visualisation/</guid>
		<description><![CDATA[If you've ever had the displeasure to sit anywhere near me at work you will know that I love graphs. If I get a data set I love to graph it. I've used graphs in gnuplot to model player acceleration when writing the controls for a FPS, graphs to show people playing a game over [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-9998980871049158";
google_ad_slot = "6052810016";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br clear="all">If you've ever had the displeasure to sit anywhere near me at work you will know that I love graphs. If I get a data set I love to graph it. I've used graphs in <a href="http://www.gnuplot.info/">gnuplot</a> to model player acceleration when writing the controls for a FPS, graphs to show people playing a game over time and graphs to show memory allocation over time. I just can't stop myself.</p>
<p>For me graphs allow me to unlock the huge potential of the human mind to see data. Numbers are abstract but graphs are somehow more real, more tangible. There are huge areas of the brain devoted to image and pattern recognition so I see  no reason to ignore them with abstract data sets.</p>
<p>So when <a href="http://www.webbalert.com/">Webb Alert</a> put me on to this <a href="http://www.ted.com/">TED</a> talk I was really pleased to see graphs, graphs and oh yes animating graphs.</p>
<p>On an important note Hans Rosling uses his software to graph statistics for the third world and succeeds in changing my opinion on the nature of first and third worlds.</p>
<p>Here he is in 2006 with his graphs</p>
<p><!--cut and paste--><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="320" height="285" id="VE_Player" align="middle"><param name="movie" value="http://static.videoegg.com/ted/flash/loader.swf"><PARAM NAME="FlashVars" VALUE="bgColor=FFFFFF&file=http://static.videoegg.com/ted/movies/HANSROSLING_high.flv&autoPlay=false&fullscreenURL=http://static.videoegg.com/ted/flash/fullscreen.html&forcePlay=false&logo=&allowFullscreen=true"><param name="quality" value="high"><param name="allowScriptAccess" value="always"><param name="bgcolor" value="#FFFFFF"><param name="scale" value="noscale"><param name="wmode" value="window"><embed src="http://static.videoegg.com/ted/flash/loader.swf" FlashVars="bgColor=FFFFFF&file=http://static.videoegg.com/ted/movies/HANSROSLING_high.flv&autoPlay=false&fullscreenURL=http://static.videoegg.com/ted/flash/fullscreen.html&forcePlay=false&logo=&allowFullscreen=true" quality="high" allowScriptAccess="always" bgcolor="#FFFFFF" scale="noscale" wmode="window" width="320" height="285" name="VE_Player" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></object></p>
<p>and in 2007 with more graphs, more animated fun and good news about the opening of statistics about us (and mostly paid for by us as well)</p>
<p><!--cut and paste--><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="432" height="285" id="VE_Player" align="middle"><param name="movie" value="http://static.videoegg.com/ted/flash/loader.swf"><PARAM NAME="FlashVars" VALUE="bgColor=FFFFFF&file=http://static.videoegg.com/ted/movies/HANSROSLING-2007_high.flv&autoPlay=false&fullscreenURL=http://static.videoegg.com/ted/flash/fullscreen.html&forcePlay=false&logo=&allowFullscreen=true"><param name="quality" value="high"><param name="allowScriptAccess" value="always"><param name="bgcolor" value="#FFFFFF"><param name="scale" value="noscale"><param name="wmode" value="window"><embed src="http://static.videoegg.com/ted/flash/loader.swf" FlashVars="bgColor=FFFFFF&file=http://static.videoegg.com/ted/movies/HANSROSLING-2007_high.flv&autoPlay=false&fullscreenURL=http://static.videoegg.com/ted/flash/fullscreen.html&forcePlay=false&logo=&allowFullscreen=true" quality="high" allowScriptAccess="always" bgcolor="#FFFFFF" scale="noscale" wmode="window" width="432" height="285" name="VE_Player" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></object></p>
<p><map name='google_ad_map_182_afea9fcd39d8b84a'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/182?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_182_afea9fcd39d8b84a' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=182&amp;url= http%3A%2F%2Fwww.luckydonkey.com%2F2008%2F02%2F21%2Fdata-visualisation%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.luckydonkey.com/2008/02/21/data-visualisation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Debugging My ADSL</title>
		<link>http://www.luckydonkey.com/2007/11/03/debugging-my-adsl/</link>
		<comments>http://www.luckydonkey.com/2007/11/03/debugging-my-adsl/#comments</comments>
		<pubDate>Sat, 03 Nov 2007 19:13:14 +0000</pubDate>
		<dc:creator>dazza</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.luckydonkey.com/2007/11/03/debugging-my-adsl/</guid>
		<description><![CDATA[My ADSL hasn't been perfect at my home for a year or so now. Basically it looses the connection. Sometimes once a week, sometimes it's 4 or five times a day. I've been too lazy to sort it out because it just seemed easier to reboot the modem, wait 30 seconds and carry on with [...]]]></description>
			<content:encoded><![CDATA[<p>My ADSL hasn't been perfect at my home for a year or so now. Basically it looses the connection. Sometimes once a week, sometimes it's 4 or five times a day. I've been too lazy to sort it out because it just seemed easier to reboot the modem, wait 30 seconds and carry on with my life. I've had ADSL nightmares before where I spent hours on hold waiting to talk to a support serf and I haven't been keen to repeat this.</p>
<p>A friend of mine coincidentally asked me if I knew anything about a provider he was thinking of joining. He started to bemoan his provider and the ancient wiring in his london flat. So I replied and tried not to think about my problems. As often happens I couldn't stop thinking of my own problems! I stumbled upon <a href="http://vwlowen.co.uk/internet/files.htm">RouterStats</a>. It's a cool little win32 app that basically knows  how to read you routers stats page and display a little graph. I ran it on my mac using <a href="http://www.vmware.com/mac">VMWare Fusion</a> and sure enough it showed my modems 'noise ratio' getting lower and lower toward the magic 6db mark where most routers just give up and drop their ADSL connection.</p>
<p>A this point I decided that I couldn't be bothered to run this App (and a resident copy of windows JUST so I could look at my router stats. So I turned to python to scrape my router page</p>
<pre class="python">&nbsp;
<span style="color: #808080; font-style: italic;">#script to scrape the stats from a Netgear DG834GT</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib2</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
<span style="color: #ff7700;font-weight:bold;">from</span> BeautifulSoup <span style="color: #ff7700;font-weight:bold;">import</span> BeautifulSoup
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">time</span> <span style="color: #ff7700;font-weight:bold;">import</span> sleep
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">datetime</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">datetime</span>
&nbsp;
base_path=<span style="color: #483d8b;">&quot;http://192.168.1.1/&quot;</span>
monitor_page=<span style="color: #483d8b;">'stattbl.htm'</span>
username=<span style="color: #483d8b;">'admin'</span>
password = <span style="color: #483d8b;">'password'</span>
top_level_url = base_path
&nbsp;
<span style="color: #808080; font-style: italic;">#register an opener with urllib2 which knows how to respond to basic</span>
<span style="color: #808080; font-style: italic;">#authentication requests from a webserver</span>
password_mgr = <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">HTTPPasswordMgrWithDefaultRealm</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
password_mgr.<span style="color: black;">add_password</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span>, top_level_url, username, password<span style="color: black;">&#41;</span>
handler = <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">HTTPBasicAuthHandler</span><span style="color: black;">&#40;</span>password_mgr<span style="color: black;">&#41;</span>
opener = <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">build_opener</span><span style="color: black;">&#40;</span>handler<span style="color: black;">&#41;</span>
<span style="color: #dc143c;">urllib2</span>.<span style="color: black;">install_opener</span><span style="color: black;">&#40;</span>opener<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#re to extract the number section from a string in the form xxx.xx db</span>
dbre=<span style="color: #dc143c;">re</span>.<span style="color: #008000;">compile</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;(?P&lt;num&gt;[<span style="color: #000099; font-weight: bold;">\d</span><span style="color: #000099; font-weight: bold;">\.</span>]+)<span style="color: #000099; font-weight: bold;">\s</span>*db&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#for ever, ask for the stats page, extract the data and print it,</span>
<span style="color: #808080; font-style: italic;">#it's  not pretty code but I am scraping a bloody router stats</span>
<span style="color: #808080; font-style: italic;">#page so WHO CARES</span>
<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
    response = <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span>base_path+monitor_page<span style="color: black;">&#41;</span>
    html= response.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    soup = BeautifulSoup<span style="color: black;">&#40;</span>html<span style="color: black;">&#41;</span>
    tables= soup.<span style="color: black;">body</span>.<span style="color: black;">table</span>.<span style="color: black;">findAll</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'table'</span><span style="color: black;">&#41;</span>
    tds = tables<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">findAll</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'td'</span><span style="color: black;">&#41;</span>
&nbsp;
    tx = tds<span style="color: black;">&#91;</span><span style="color: #ff4500;">13</span><span style="color: black;">&#93;</span>.<span style="color: black;">span</span>.<span style="color: black;">contents</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
    rx = tds<span style="color: black;">&#91;</span><span style="color: #ff4500;">14</span><span style="color: black;">&#93;</span>.<span style="color: black;">span</span>.<span style="color: black;">contents</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> extract<span style="color: black;">&#40;</span>node<span style="color: black;">&#41;</span>:
        s  =dbre.<span style="color: black;">match</span><span style="color: black;">&#40;</span>node<span style="color: black;">&#41;</span>.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'num'</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">float</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>
&nbsp;
    tds = tables<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>.<span style="color: black;">findAll</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'td'</span><span style="color: black;">&#41;</span>
    att_down = extract<span style="color: black;">&#40;</span>tds<span style="color: black;">&#91;</span><span style="color: #ff4500;">7</span><span style="color: black;">&#93;</span>.<span style="color: black;">span</span>.<span style="color: black;">contents</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
    att_up = extract<span style="color: black;">&#40;</span>tds<span style="color: black;">&#91;</span><span style="color: #ff4500;">8</span><span style="color: black;">&#93;</span>.<span style="color: black;">span</span>.<span style="color: black;">contents</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
    nm_down = extract<span style="color: black;">&#40;</span>tds<span style="color: black;">&#91;</span><span style="color: #ff4500;">10</span><span style="color: black;">&#93;</span>.<span style="color: black;">span</span>.<span style="color: black;">contents</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
    nm_up = extract<span style="color: black;">&#40;</span>tds<span style="color: black;">&#91;</span><span style="color: #ff4500;">11</span><span style="color: black;">&#93;</span>.<span style="color: black;">span</span>.<span style="color: black;">contents</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
    now = <span style="color: #dc143c;">datetime</span>.<span style="color: black;">now</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> now.<span style="color: black;">strftime</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%H:%M:%S&quot;</span><span style="color: black;">&#41;</span>, <span style="color: #483d8b;">&quot;atd:&quot;</span>, att_down, <span style="color: #483d8b;">&quot;atu:&quot;</span>,\
        att_up, <span style="color: #483d8b;">&quot;nd:&quot;</span>, nm_down, <span style="color: #483d8b;">&quot;nu:&quot;</span>, nm_up, <span style="color: #483d8b;">&quot;rx:&quot;</span>, rx, <span style="color: #483d8b;">&quot;tx:&quot;</span>, tx
    sleep<span style="color: black;">&#40;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#41;</span>
&nbsp;</pre>
<p>Every five seconds this prints out the stats for my router</p>
<pre>
13:44:18 atd: 21.0 atu: 22.0 nd: 13.0 nu: 26.0 rx: 10138 tx: 4138
13:44:23 atd: 21.0 atu: 22.0 nd: 13.0 nu: 26.0 rx: 10138 tx: 4138
13:44:29 atd: 21.0 atu: 22.0 nd: 13.0 nu: 26.0 rx: 10137 tx: 4138
13:44:34 atd: 21.0 atu: 22.0 nd: 13.0 nu: 26.0 rx: 10136 tx: 4137
13:44:39 atd: 21.0 atu: 22.0 nd: 13.0 nu: 26.0 rx: 10135 tx: 4137
13:44:44 atd: 21.0 atu: 22.0 nd: 13.0 nu: 26.0 rx: 10135 tx: 4137
13:44:50 atd: 21.0 atu: 22.0 nd: 13.0 nu: 26.0 rx: 10134 tx: 4136
13:44:55 atd: 21.0 atu: 22.0 nd: 13.0 nu: 26.0 rx: 10133 tx: 4136
13:45:00 atd: 21.0 atu: 22.0 nd: 13.0 nu: 26.0 rx: 10132 tx: 4136
13:45:05 atd: 21.0 atu: 22.0 nd: 13.0 nu: 26.0 rx: 10131 tx: 4135
</pre>
<p>Well I left this running and guess what? When the phone rang my noise ratio dropped... and if it was already low my router dropped the connection. If I even picked up my phone the noise ratio dropped. After poking around with the wiring it turns out one of the phones in the house didn't have an ADSL filter so it was spewing noise on to the telephone line in the frequency range ADSL uses! Doh. Without the filter my best noise ratio was 9db, with the filter it never drops below 12db.</p>
<p><map name='google_ad_map_139_afea9fcd39d8b84a'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/139?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_139_afea9fcd39d8b84a' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=139&amp;url= http%3A%2F%2Fwww.luckydonkey.com%2F2007%2F11%2F03%2Fdebugging-my-adsl%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.luckydonkey.com/2007/11/03/debugging-my-adsl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DTrace: Google Tech Talk</title>
		<link>http://www.luckydonkey.com/2007/08/21/dtrace-google-tech-talk/</link>
		<comments>http://www.luckydonkey.com/2007/08/21/dtrace-google-tech-talk/#comments</comments>
		<pubDate>Tue, 21 Aug 2007 12:56:58 +0000</pubDate>
		<dc:creator>dazza</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://www.luckydonkey.com/2007/08/21/dtrace-google-tech-talk/</guid>
		<description><![CDATA[I've been hearing about DTrace for years now and I kind of knew what it was and that I would like to have it. In the back of my mind I've been waiting for it to appear in FreeBSD (although this seems to be faltering a little) so I could play with it. Well one [...]]]></description>
			<content:encoded><![CDATA[<p>I've been hearing about <a href="http://www.sun.com/bigadmin/content/dtrace/">DTrace</a> for years now and I kind of knew what it was and that I would like to have it. In the back of my mind I've been waiting for it to appear in FreeBSD <a href="http://dtrace.what-creek.com/">(although this seems to be faltering a little)</a> so I could play with it.</p>
<p>Well one of the engineers from <a href="http://www.sun.com/">Sun</a> that gave birth to DTrace has done a <a href="http://video.google.com/googleplex.html">google tech talk</a> about DTrace and it's very interesting indeed. Highlights for me were the amazing instrumentation of Python which I will definitely use. He also muses on the lack of support for DTrace on linux and tries to gather a posse of developers from google to kick it off, porting DTrace to Windows and how he can't find a good book on programming.</p>
<p><embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=-8002801113289007228&hl=en-GB" flashvars=""> </embed></p>
<p><map name='google_ad_map_127_afea9fcd39d8b84a'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/127?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_127_afea9fcd39d8b84a' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=127&amp;url= http%3A%2F%2Fwww.luckydonkey.com%2F2007%2F08%2F21%2Fdtrace-google-tech-talk%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.luckydonkey.com/2007/08/21/dtrace-google-tech-talk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More SQLAlchemy, this time explicit joins!</title>
		<link>http://www.luckydonkey.com/2007/05/16/more-sqlalchemy-this-time-explicit-joins/</link>
		<comments>http://www.luckydonkey.com/2007/05/16/more-sqlalchemy-this-time-explicit-joins/#comments</comments>
		<pubDate>Wed, 16 May 2007 00:17:29 +0000</pubDate>
		<dc:creator>dazza</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.luckydonkey.com/2007/05/16/more-sqlalchemy-this-time-explicit-joins/</guid>
		<description><![CDATA[In my previous post I wanted to count the number of gigs that have or will be staged at a venue. But if a venue has no gigs associated it didn't appear in the results. Well to fix this I need to join the Venues table making sure that every venue appears in the output [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-9998980871049158";
google_ad_slot = "6052810016";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br clear="all"><br />
In my <a href="http://www.luckydonkey.com/2007/05/08/sqlalchemy-counting-how-many-things-refere-to-another-thing/">previous post</a> I wanted to count the number of gigs that have or will be staged at a venue. But if a venue has no gigs associated it didn't appear in the results. Well to fix this I need to join the Venues table making sure that every venue appears in the output (even if there are no gigs there):</p>
<pre style="color:#996633;">SELECT venues.name, COUNT(gigs.venueid)
FROM venues LEFT OUTER JOIN gigs
ON gigs.venueid = venues.id
GROUP BY venues.name
ORDER BY venues.name
</pre>
<p>The JOIN joins venues and gigs where gigs.venueid equals venues.id but the LEFT OUTER statement makes sure that all rows in the left table (venues) appear in the output table. There is an excellent description of how joins work in <a href="http://en.wikipedia.org/wiki/Sql_join#Left_outer_join">wikipedia</a> of course. Any row in the left table (venues) that doesn't 'join' anything in the right tables (gigs) is added with NULL values for right table columns. We don't really care about this because we are only SELECTing the venue name and the count of gigs that use that venue (so we don't need any potentially NULL column entries)</p>
<p>Anyway, how do we get this in to SQLAlchemy:</p>
<pre style="color:#996633;">select([Venue.c.name, func.count(Gig.c.venueid)],
        from_obj=[venues_table.outerjoin(gig_table)],
        group_by=[Venue.c.name, Venue.c.id],
        order_by=[Venue.c.name]).execute().fetchall()
</pre>
<p>I learnt something pretty cool while working this out. You can ask SQLAlchemy to printout what query it is going to execute:</p>
<pre style="color:#996633;">print select([Venue.c.name, func.count(Gig.c.venueid)],
        from_obj=[venues_table.outerjoin(gig_table)],
        group_by=[Venue.c.name, Venue.c.id],
        order_by=[Venue.c.name])
</pre>
<p>and you get</p>
<pre style="color:#996633;">SELECT venues.name, count(gigs.venueid)
FROM venues LEFT OUTER JOIN gigs
ON venues.id = gigs.venueid
GROUP BY venues.name, venues.id
ORDER BY venues.name
</pre>
<p>which I think you can agree is basically identical to the required statement. Using this feature I could test out SQLAlchemy syntax and see if it was getting close to the raw SQL. This helped me a lot.</p>
<p>I think the SQLAlchemy syntax here is particularly intuitive. The keyword parameter from_obj is particularly pleasing as it really describes what I am doing in my head. I'm taking the venue name and it's count from the set 'venues joined with gigs'. SQLAlchemy can easily work out that venues are joined to gigs by the foreign key in each gig row which referes to a venue. So there is no need for me to specify HOW to join (the ON clause in SQL).</p>
<p><map name='google_ad_map_126_afea9fcd39d8b84a'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/126?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_126_afea9fcd39d8b84a' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=126&amp;url= http%3A%2F%2Fwww.luckydonkey.com%2F2007%2F05%2F16%2Fmore-sqlalchemy-this-time-explicit-joins%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.luckydonkey.com/2007/05/16/more-sqlalchemy-this-time-explicit-joins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unicode in Python</title>
		<link>http://www.luckydonkey.com/2007/05/13/unicode-in-python/</link>
		<comments>http://www.luckydonkey.com/2007/05/13/unicode-in-python/#comments</comments>
		<pubDate>Sun, 13 May 2007 09:40:09 +0000</pubDate>
		<dc:creator>dazza</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.luckydonkey.com/2007/05/13/unicode-in-python/</guid>
		<description><![CDATA[I stumbled across this excellent article on Unicode in Python today. Well worth reading if you stray from ASCII.]]></description>
			<content:encoded><![CDATA[<p>I stumbled across this <a href="http://boodebr.org/main/python/all-about-python-and-unicode">excellent</a> article on Unicode in Python today. Well worth reading if you stray from ASCII.</p>
<p><map name='google_ad_map_125_afea9fcd39d8b84a'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/125?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_125_afea9fcd39d8b84a' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=125&amp;url= http%3A%2F%2Fwww.luckydonkey.com%2F2007%2F05%2F13%2Funicode-in-python%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.luckydonkey.com/2007/05/13/unicode-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
