<?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>Life of Andrew &#187; Uncategorized</title>
	<atom:link href="http://sandfly.net.nz/blog/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://sandfly.net.nz/blog</link>
	<description>Life, technology</description>
	<lastBuildDate>Tue, 15 May 2012 10:48:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>The Scale of the Universe</title>
		<link>http://sandfly.net.nz/blog/2012/05/the-scale-of-the-universe/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-scale-of-the-universe</link>
		<comments>http://sandfly.net.nz/blog/2012/05/the-scale-of-the-universe/#comments</comments>
		<pubDate>Fri, 04 May 2012 23:58:21 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[science]]></category>

		<guid isPermaLink="false">http://sandfly.net.nz/blog/?p=1538</guid>
		<description><![CDATA[The Scale of the Universe 2 This is very cool &#8211; an interactive demonstration of the scale of the universe, from the smallest unit of quantum length to the total estimated size of the whole shebang. I&#8217;ve just about got my head around how big the universe is, but at the other end I had <a href='http://sandfly.net.nz/blog/2012/05/the-scale-of-the-universe/' class='excerpt-more'>[...]</a>
No related posts.]]></description>
			<content:encoded><![CDATA[<p><a href="http://htwins.net/scale2/" title="The Scale of the Universe 2" target="_blank"><br />
<img src="http://sandfly.net.nz/blog/wp-content/uploads/2012/05/scale_of_the_universe.jpg" alt="Screenshot of the Scale of the Universe 2 flash object" title="Scale of the Universe" width="500" height="257" class="aligncenter size-full wp-image-1539" /><center>The Scale of the Universe 2</center></a></p>
<p>This is very cool &#8211; an interactive demonstration of the scale of the universe, from the smallest unit of quantum length to the total estimated size of the whole shebang. </p>
<p>I&#8217;ve just about got my head around how big the universe is, but at the other end I had no idea that the Planck Length was so small. Now my brain hurts.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://sandfly.net.nz/blog/2012/05/the-scale-of-the-universe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>John Banks Election Scandal</title>
		<link>http://sandfly.net.nz/blog/2012/04/john-banks-election-scandal/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=john-banks-election-scandal</link>
		<comments>http://sandfly.net.nz/blog/2012/04/john-banks-election-scandal/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 11:00:35 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[New Zealand]]></category>
		<category><![CDATA[politics]]></category>

		<guid isPermaLink="false">http://sandfly.net.nz/blog/?p=1527</guid>
		<description><![CDATA[John Banks was given a very important job when government was formed after the November election, a position named Minister with Special Responsibility for Keeping His Month Shut for the Next 36 Months and Not Embarrassing the Government. Would all of you who picked 26 weeks in the nationwide pool please raise your hands to <a href='http://sandfly.net.nz/blog/2012/04/john-banks-election-scandal/' class='excerpt-more'>[...]</a>
Related posts:<ol>
<li><a href='http://sandfly.net.nz/blog/2008/11/election-time/' rel='bookmark' title='Election Time'>Election Time</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>John Banks was given a very important job when government was formed after the November election, a position named Minister with Special Responsibility for Keeping His Month Shut for the Next 36 Months and Not Embarrassing the Government. </p>
<p>Would all of you who picked <a href="http://www.stuff.co.nz/national/politics/6831670/Banks-denies-Dotcom-phone-call">26 weeks</a> in the nationwide pool please raise your hands to claim your prizes. Judges will be around shortly to check your tickets.<br />
<span id="more-1527"></span><br />
The fact the loveable scamp Kim Dotcom is involved is just icing on the cake. He should probably be lying low at the moment, preparing for his upcoming and no-doubt amusing trial, not poking his head into national affairs. But Dotcom doesn&#8217;t seem the type to fade into the background. </p>
<p>If your ticket reads 18 weeks since arrest before hitting the headlines again please raise your hands, etc, etc.</p>
<p>Now there is nothing wrong with donating money to a politician you support, but Donation lives just down the block from Bribery so the law is fairly strict about candidates revealing who gave them what to keep everyone honest. Money flows like water and a few buckets can do just as well as a single inconvenient barrel.</p>
<p>But anonymous donations are OK, right? You can&#8217;t influence someone if they don&#8217;t know if the money came from you. Perhaps in theory, but information flows even more quickly than water, particularly if you allegedly ring someone up to tell them. </p>
<p>I am genuinely not accusing Banks of accepting money in exchange for anything. He just appears to have fallen foul of the accounting rules meant to prevent that suspicion if the first place. If he did deliberately try to hide donations then losing his seat should be the least of his problems.</p>
<p>However, <a href="http://publicaddress.net/legalbeagle/the-law-may-be-that-stupid/">the law does not appear to be quite clear cut</a> (well worth a read) and it will be interesting to see if Banks campaign has indeed acted illegally. And if the law was broken, what will be done about it. And if the law was not broken, should it be changed?</p>
<p>Those amongst us hoping the National Government will fall are dreaming, a (currently hypothetical) bi-election will not bring down the government even if Labor wins &#8211; which it won&#8217;t. On the other hand, even if Banks successful defends himself the government loses a trickle of credibility. And trickles soon add up.</p>
<p>Related posts:<ol>
<li><a href='http://sandfly.net.nz/blog/2008/11/election-time/' rel='bookmark' title='Election Time'>Election Time</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://sandfly.net.nz/blog/2012/04/john-banks-election-scandal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Capturing Video at the Speed of Light</title>
		<link>http://sandfly.net.nz/blog/2011/12/capturing-video-at-the-speed-of-light/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=capturing-video-at-the-speed-of-light</link>
		<comments>http://sandfly.net.nz/blog/2011/12/capturing-video-at-the-speed-of-light/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 09:14:00 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://sandfly.net.nz/blog/?p=1334</guid>
		<description><![CDATA[When I was a child I used to amuse myself by imagining how things would look if light moved at a few meters per second. I thought it would be cool if you could walk into a dark room, turn on the light and watch as the light spread throughout the scene. Wielding a flashlight <a href='http://sandfly.net.nz/blog/2011/12/capturing-video-at-the-speed-of-light/' class='excerpt-more'>[...]</a>
Related posts:<ol>
<li><a href='http://sandfly.net.nz/blog/2009/05/the-html5-video-tags-fatal-flaw/' rel='bookmark' title='The HTML5 Video Tag&#8217;s Fatal Flaw'>The HTML5 Video Tag&#8217;s Fatal Flaw</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>When I was a child I used to amuse myself by imagining how things would look if light moved at a few meters per second. I thought it would be cool if you could walk into a dark room, turn on the light and watch as the light spread throughout the scene. Wielding a flashlight would be interesting &#8211; you could easily make curved beams.</p>
<p>Now these guys have built a camera fast enough to show the same effect:</p>
<p><iframe width="640" height="360" src="http://www.youtube.com/embed/EtsXgODHMWk" frameborder="0" allowfullscreen></iframe></p>
<p>Of course, they do cheat a bit by only taking a 1 dimensional slice at a time and relying on the fact that they can repeatably fire identical pulses of light to make their images. Still this is exactly what I imagined it would be like.</p>
<p>Now someone needs to build the high wattage laser targeting system capable of taking out houseflies without blinding humans that I invented when I was 9.</p>
<p>Related posts:<ol>
<li><a href='http://sandfly.net.nz/blog/2009/05/the-html5-video-tags-fatal-flaw/' rel='bookmark' title='The HTML5 Video Tag&#8217;s Fatal Flaw'>The HTML5 Video Tag&#8217;s Fatal Flaw</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://sandfly.net.nz/blog/2011/12/capturing-video-at-the-speed-of-light/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Don Brash and Act</title>
		<link>http://sandfly.net.nz/blog/2011/04/don-brash-and-act/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=don-brash-and-act</link>
		<comments>http://sandfly.net.nz/blog/2011/04/don-brash-and-act/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 01:52:55 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[politics]]></category>

		<guid isPermaLink="false">http://sandfly.net.nz/blog/?p=1085</guid>
		<description><![CDATA[While I don&#8217;t like Don Brash (or the Act party), I have to admire the concept of announcing your availability to be the leader of an organisation that you don&#8217;t currently belong to. I would also like to take this opportunity to say that I am interested in being captain of the All Blacks during <a href='http://sandfly.net.nz/blog/2011/04/don-brash-and-act/' class='excerpt-more'>[...]</a>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>While I don&#8217;t like Don Brash (or the Act party), I have to admire the concept of <a href="http://www.nzherald.co.nz/nz-government/news/article.cfm?c_id=144&#038;objectid=10721377">announcing your availability to be the leader of an organisation that you don&#8217;t currently belong to</a>.</p>
<p>I would also like to take this opportunity to say that I am interested in being captain of the All Blacks during this year&#8217;s world cup. I will be holding talks with the All Black management tomorrow, but if unsuccessful I will form my own rugby team and lead it to glorious  victory on the field. I have backers and financial support &#8211; so there!</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://sandfly.net.nz/blog/2011/04/don-brash-and-act/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TV Theme Quiz II : The Themes Strike Back</title>
		<link>http://sandfly.net.nz/blog/2010/05/tv-theme-quiz-ii-the-themes-stike-back/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tv-theme-quiz-ii-the-themes-stike-back</link>
		<comments>http://sandfly.net.nz/blog/2010/05/tv-theme-quiz-ii-the-themes-stike-back/#comments</comments>
		<pubDate>Tue, 25 May 2010 07:15:05 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Culture]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://sandfly.net.nz/blog/?p=827</guid>
		<description><![CDATA[It was bound to happen. People seemed to enjoy the first TV Theme Quiz so I fired up Audacity and created another 30 seconds of familiar ditties. Things were solved pretty quickly last time so I tried to make this one just a smidgeon harder &#8211; we will see if I succeeded. Start TV Theme <a href='http://sandfly.net.nz/blog/2010/05/tv-theme-quiz-ii-the-themes-stike-back/' class='excerpt-more'>[...]</a>
Related posts:<ol>
<li><a href='http://sandfly.net.nz/blog/2008/05/new-wordpress-theme/' rel='bookmark' title='New WordPress Theme'>New WordPress Theme</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>It was bound to happen. People seemed to enjoy the <a href="http://sandfly.net.nz/experiments/tvthemes">first TV Theme Quiz</a> so I fired up Audacity and created another 30 seconds of familiar ditties. Things were solved pretty quickly last time so I tried to make this one just a smidgeon harder &#8211; we will see if I succeeded.</p>
<p><center><strong><a href="http://sandfly.net.nz/experiments/tvthemes/tvthemes2.html">Start TV Theme Quiz II</a></strong></center></p>
<p>This quiz works in much the same way as the last one but I have tweaked the Javascript a little. I never thought that anyone would bother reversing the hash used to hide the answers on the first quiz but one of my friends admitted that they had done just that. A little salt should clear that problem right up.</p>
<p>This is the post you should comment on for hints and bragging. I only ask that you refrain from posting the actual answers, at least for the first few days. I think it is better to let people work things out for themselves.</p>
<p>Related posts:<ol>
<li><a href='http://sandfly.net.nz/blog/2008/05/new-wordpress-theme/' rel='bookmark' title='New WordPress Theme'>New WordPress Theme</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://sandfly.net.nz/blog/2010/05/tv-theme-quiz-ii-the-themes-stike-back/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Python and The Very Slow Server</title>
		<link>http://sandfly.net.nz/blog/2009/11/python-and-the-very-slow-server/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=python-and-the-very-slow-server</link>
		<comments>http://sandfly.net.nz/blog/2009/11/python-and-the-very-slow-server/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 02:23:00 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://sandfly.net.nz/blog/?p=670</guid>
		<description><![CDATA[I don&#8217;t usually do a lot of Python programming, but I always enjoy it when the opportunity arises. Python is in no way a &#8220;clean&#8221; language, it has all sorts of warts and limitations that mean that it tends to not get used for big projects. Despite this (or maybe because of it), Python remains <a href='http://sandfly.net.nz/blog/2009/11/python-and-the-very-slow-server/' class='excerpt-more'>[...]</a>
Related posts:<ol>
<li><a href='http://sandfly.net.nz/blog/2011/11/jumping-frogs-using-python-to-solve-puzzles/' rel='bookmark' title='Jumping Frogs &#8211; Using Python to Solve Puzzles'>Jumping Frogs &#8211; Using Python to Solve Puzzles</a></li>
<li><a href='http://sandfly.net.nz/blog/2011/07/arduino-pov-device-part-ii/' rel='bookmark' title='Arduino POV Device Part II'>Arduino POV Device Part II</a></li>
<li><a href='http://sandfly.net.nz/blog/2009/02/the-boost-c-libraries-part-4-boostdate_time/' rel='bookmark' title='The Boost C++ Libraries Part 4 &#8211; boost::date_time'>The Boost C++ Libraries Part 4 &#8211; boost::date_time</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t usually do a lot of Python programming, but I always enjoy it when the opportunity arises. Python is in no way a &#8220;clean&#8221; language, it has all sorts of warts and limitations that mean that it tends to not get used for big projects. Despite this (or maybe because of it), Python remains my go-to language for Getting Small Things Done Quickly. It is impossible to overstate the utility of just being able to start coding a function by bashing away at the python console &#8211; nothing else has given me the same sense of instant gratification since I started programming in BASIC back in the 80s.</p>
<p>The other big advantage of Python is the useful utility libraries that come with it as standard. Want to send twenty thousand emails? Just import <strong>smtplib</strong>. Want to generate code based on data from a spreadsheet? Import <strong>csv</strong> and away you go. Need a file that is exactly 32Mb is size? No problem. These are real examples from my job where Python has saved me many hours.</p>
<p>The most recent use I have put Python to is a slow server. For various murky and uninteresting reasons I need a rate-limiting HTTP server, one that I can easily control the speed at which it sends data. Enter Python&#8217;s very handy <strong>BaseHTTPServer</strong> module, which allows you to create custom HTTP servers with only a few lines of code by subclassing a request handler. Although the <strong>BaseHTTPServer</strong> is fairly useless for serving real files, it is perfect for this type of thing since it does all the boring work of parsing headers and returning status codes.</p>
<p>I don&#8217;t care about the contents of the data, just its size and how long it takes to serve. Since I will be varying these parameters a lot, I decided to make them part of each request so that each request could take a different amount of time &#8211; this means I don&#8217;t have to restart the server between each test run. Modifying the code to serve actual file data would be very simple.</p>
<p>I enjoyed writing this server so much that I regret that it didn&#8217;t take longer. Now I actually have to use it for its intended purpose, which I can assure you is not going to be as pleasant.</p>
<p>Here is the complete Python source:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># A very simple HTTP server designed to for testing situations where the data returned</span>
<span style="color: #808080; font-style: italic;"># is not important but the rate at which it comes down is. This server can be started</span>
<span style="color: #808080; font-style: italic;"># using the command: python delayserver.py</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Once started, it will listen for requests on port 8000</span>
<span style="color: #808080; font-style: italic;"># Requests should be of the form http://&lt;address&gt;:8000/size=&lt;bytes&gt;,duration=&lt;seconds&gt;</span>
<span style="color: #808080; font-style: italic;"># where: &lt;bytes&gt; is the size of the response data</span>
<span style="color: #808080; font-style: italic;"># and    &lt;seconds&gt; is how long you want it to take (at minimum, it may take longer)</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Notes:</span>
<span style="color: #808080; font-style: italic;"># * The timing is pretty inaccurate for small byte sizes, this isn't a problem for</span>
<span style="color: #808080; font-style: italic;">#   what I need it for</span>
<span style="color: #808080; font-style: italic;"># * Press ctrl-c to stop serving</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">time</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">BaseHTTPServer</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> MyHTTPRequestHandler<span style="color: black;">&#40;</span><span style="color: #dc143c;">BaseHTTPServer</span>.<span style="color: black;">BaseHTTPRequestHandler</span><span style="color: black;">&#41;</span>:
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">def</span> do_GET<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
		request = <span style="color: #008000;">self</span>.<span style="color: black;">path</span>.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/&quot;</span><span style="color: black;">&#41;</span>
		duration = <span style="color: #ff4500;">1</span>
		size = <span style="color: #ff4500;">1024</span>
&nbsp;
        	validRequest = <span style="color: #008000;">False</span>
		params = request.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;,&quot;</span><span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">for</span> p <span style="color: #ff7700;font-weight:bold;">in</span> params:
                    temp = p.<span style="color: black;">partition</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;=&quot;</span><span style="color: black;">&#41;</span>
                    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>temp<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;size&quot;</span><span style="color: black;">&#41;</span>:
                        size = <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>temp<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
                        validRequest = <span style="color: #008000;">True</span>
                    <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: black;">&#40;</span>temp<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">&quot;duration&quot;</span><span style="color: black;">&#41;</span>:
                        duration = <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>temp<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
                        validRequest = <span style="color: #008000;">True</span>
&nbsp;
                <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>validRequest == <span style="color: #008000;">False</span><span style="color: black;">&#41;</span>:
                   <span style="color: #008000;">self</span>.<span style="color: black;">send_error</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">404</span><span style="color: black;">&#41;</span>
                   <span style="color: #ff7700;font-weight:bold;">return</span>
&nbsp;
                <span style="color: #008000;">self</span>.<span style="color: black;">send_response</span><span style="color: black;">&#40;</span> <span style="color: #ff4500;">200</span> <span style="color: black;">&#41;</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">send_header</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;Content-Length&quot;</span>, <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>size<span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">send_header</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;Pragma&quot;</span>, <span style="color: #483d8b;">&quot;no-cache&quot;</span> <span style="color: black;">&#41;</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">end_headers</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">slowWrite</span><span style="color: black;">&#40;</span> <span style="color: #008000;">self</span>.<span style="color: black;">wfile</span>, size, duration <span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
        <span style="color: #ff7700;font-weight:bold;">def</span> slowWrite<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, output, size, duration<span style="color: black;">&#41;</span>:
                bytesWritten = <span style="color: #ff4500;">0</span>
                startTime = <span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: black;">&#40;</span> bytesWritten <span style="color: #66cc66;">&lt;</span> size <span style="color: black;">&#41;</span>:
                        now = <span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
                        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>duration <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>:
                                desiredBytes = <span style="color: black;">&#40;</span> <span style="color: black;">&#40;</span>now - startTime<span style="color: black;">&#41;</span> / duration <span style="color: black;">&#41;</span> <span style="color: #66cc66;">*</span> size
                        <span style="color: #ff7700;font-weight:bold;">else</span>:
                                desiredBytes = size
                        desiredBytes = <span style="color: #008000;">min</span><span style="color: black;">&#40;</span> size, desiredBytes <span style="color: black;">&#41;</span>
                        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>desiredBytes <span style="color: #66cc66;">&lt;</span> bytesWritten <span style="color: black;">&#41;</span>:
                                <span style="color: #dc143c;">time</span>.<span style="color: black;">sleep</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0.2</span><span style="color: black;">&#41;</span>
                        <span style="color: #ff7700;font-weight:bold;">else</span>:
                                <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: black;">&#40;</span>bytesWritten <span style="color: #66cc66;">&lt;</span> desiredBytes<span style="color: black;">&#41;</span>:
                                        output.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'A'</span><span style="color: black;">&#41;</span>
                                        bytesWritten = bytesWritten + <span style="color: #ff4500;">1</span>
                                output.<span style="color: black;">flush</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
                now = <span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
                <span style="color: #008000;">self</span>.<span style="color: black;">log_message</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;Request took %f seconds&quot;</span>,   now - startTime  <span style="color: black;">&#41;</span>	
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    http = <span style="color: #dc143c;">BaseHTTPServer</span>.<span style="color: black;">HTTPServer</span><span style="color: black;">&#40;</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span>, <span style="color: #ff4500;">8000</span><span style="color: black;">&#41;</span>, MyHTTPRequestHandler <span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Listening on 8000 - press ctrl-c to stop&quot;</span>
    http.<span style="color: black;">serve_forever</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>I should point out that I am by no means an expert at Python, so take this code with a pinch of salt.</p>
<p>Related posts:<ol>
<li><a href='http://sandfly.net.nz/blog/2011/11/jumping-frogs-using-python-to-solve-puzzles/' rel='bookmark' title='Jumping Frogs &#8211; Using Python to Solve Puzzles'>Jumping Frogs &#8211; Using Python to Solve Puzzles</a></li>
<li><a href='http://sandfly.net.nz/blog/2011/07/arduino-pov-device-part-ii/' rel='bookmark' title='Arduino POV Device Part II'>Arduino POV Device Part II</a></li>
<li><a href='http://sandfly.net.nz/blog/2009/02/the-boost-c-libraries-part-4-boostdate_time/' rel='bookmark' title='The Boost C++ Libraries Part 4 &#8211; boost::date_time'>The Boost C++ Libraries Part 4 &#8211; boost::date_time</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://sandfly.net.nz/blog/2009/11/python-and-the-very-slow-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>25 Random Songs</title>
		<link>http://sandfly.net.nz/blog/2009/06/25-random-songs/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=25-random-songs</link>
		<comments>http://sandfly.net.nz/blog/2009/06/25-random-songs/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 02:27:30 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sandfly.net.nz/blog/?p=558</guid>
		<description><![CDATA[I load up Facebook and what do I see? &#8220;Once you&#8217;ve been tagged&#8230; (1) Turn on your MP3 player. (2) Go to SHUFFLE songs mode. (3) Write down the first 25 songs that come up&#8211;song title and artist&#8211;NO editing/cheating, please. (4) Choose 25 people to be tagged. It is generally considered to be in good <a href='http://sandfly.net.nz/blog/2009/06/25-random-songs/' class='excerpt-more'>[...]</a>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I load up Facebook and what do I see?</p>
<blockquote><p>&#8220;Once you&#8217;ve been tagged&#8230; (1) Turn on your MP3 player. (2) Go to SHUFFLE songs mode. (3) Write down the first 25 songs that come up&#8211;song title and artist&#8211;NO editing/cheating, please. (4) Choose 25 people to be tagged. It is generally considered to be in good taste to tag the person who tagged you.</p>
<p>If I tagged you, it&#8217;s because I&#8217;m betting that your musical selection is entertaining, or at least amusing.</p>
<p>(To do this, go to &#8220;NOTES&#8221; under tabs on your profile page, paste these instructions in the body of the note, enter your 25 Shuffle Songs, Click &#8216;Preview&#8217; below to tag 25 people (in the right hand corner of the app) then click Publish, the little blue box at the bottom of your screen).&#8221;</p></blockquote>
<p>Damn! I&#8217;ve been tagged with the 25 Random Songs meme-virus. Oh well, here goes:</p>
<p><strong>Beauty Has Her Way by Mummy Calls (The Lost Boys Soundtrack)</strong><br />
I listened to The Lost Boys soundtrack religiously when I first got it, and while I still like it a lot there is no denying that it contains far too many sax solos. The whole CD could easily be the soundtrack to Saxophone:The Movie.</p>
<p><strong>Who Put the Bomp (In The Bomp Ba Bomp Ba Bomp) by Barry Mann</strong><br />
I grew up in a small town with only one radio station. Looking back they did a pretty good job of trying to satisfy everyone, but means that I know more about 50s and 60s music than I do about, say New York punk. Anyway, they used to play this song &#8211; basically a piss-take on DoWop bands. I still find it hilarious.</p>
<p><strong>E=mcHawking</strong><br />
<a href="http://www.mchawking.com/">I explode like a bomb. No one is spared;<br />
My power is my mass times the speed of light squared.</a><br />
I don&#8217;t know where Stephen Hawking finds the time to be both the Lucasian Professor of Mathematics at Cambridge and a hardcore gangster rapper simultaneously. </p>
<p><strong>Pulp Culture by Thomas Dolby</strong><br />
I got this from a Thomas Dolby Best Of, pretty good stuff, although this is not one of the standout songs.</p>
<p><strong>Como Sera by Edgar Joel</strong><br />
I bought an album of salsa music a while ago. It is pretty cheesy. </p>
<p><strong>Merry as a Grig by Van Philips (Ren and Stimpy Production Music)</strong><br />
Ren and Stimpy made a point of plundering recording archives for old-old-timey orchestral music. Lots of muted trumpets and xylophones.<br />
I have just realised I have no idea what a Grig is, nor why one should be merry.</p>
<p><strong>Jango&#8217;s Escape by John Williams (Star Wars Episode 2 Soundtrack)</strong><br />
The music was the best part about Star Wars, and this is one of the better pieces. </p>
<p><strong>Christmas is Interesting by Jonathan Coulton</strong><br />
From a CD I ordered online after I downloaded a couple of songs off <a href="http://www.jonathancoulton.com/">his website</a> after he was linked to the Wikipedia page on The Mandelbrot Set, of all things.</p>
<p><strong>A Thousand Miles by Vanessa Carlton</strong></p>
<p><strong>Grieg: Peer Gynt Suite #2, Op. 55 &#8211; 3. Peer Gynt&#8217;s Homecoming</strong><br />
I have a whole bunch of classic CDs in my library, mainly for when I am working and I need to concentrate. I was debating whether to exclude the classical stuff from this list, but it seemed like cheating.</p>
<p><strong>Gummi Bears Theme</strong><br />
For a while I was collecting TV theme tunes. I cannot recall how I got started, but I still have them. This one always makes me smile when it comes up on shuffle &#8211; The Gummi Bears was a pretty good show.</p>
<p><strong>The Sixth Sense Malcolm Is Dead &#8211; James Newton Howard (A History of Horror)</strong><br />
One fine day about 8 years ago I walked into Borders with too much money. I solved that problem by buying A History of Horror, a two CD set of horror movie themes going back to the 1920s. It has some great music on it, but also some tedious muck (this track lies somewhere in between.)<br />
I recall that I was torn between buying this or BatBoy:The Musical original cast recording. I am still not sure if I made the right decision.</p>
<p><strong>More Than A Feeling &#8211; Boston</strong><br />
Sometimes you just have to close your eyes and drift awaaaay&#8230; Ironically a song about reminiscing over an old song has turned into an old song that reminds me about my youth. God that makes me feel old, but I bet not as old as it makes the members of Boston feel.</p>
<p><strong>Swear It&#8217;s True &#8211; The Mockers (25 Years of Kiwi Rock)</strong><br />
I liked The Mockers, but Forever Tuesday Morning is a better song.</p>
<p><strong>Second Solution &#8211; The Living End</strong><br />
The Living End are still going, but rebellious punkesque bands really have a hard sell-by date (c.f. Green Day). This is them from their prime.</p>
<p><strong>Crepe Suzette &#8211; Cyril Watters (Ren and Stimpy Production Music)</strong><br />
More Ren and Stimpy</p>
<p><strong>Org Con in B flat, Op.4, No.2 &#8211; Halleluja</strong><br />
I once help win first place in a quiz by knowing that Handel&#8217;s Messuah was first performed in Dublin. I also know it makes for good background music.</p>
<p><strong>I Get a Kick Out of You &#8211; Felix Slatkin Ultra-Lounge Volume 3 &#8211; Space Capades</strong><br />
The Ultra-Lounge series mines much the same vein as the Ren and Stimpy Music, just from a couple of decades later &#8211; lots of 40s and 50s cheese. This is from Space Capades, so there is lots of vibraphone. </p>
<p><strong>Stravinsky: Pulcinella &#8211; Scherzino</strong></p>
<p><strong>Symphony No.1, Op.7 &#8216;Le PoÃ¨me de la forÃªt&#8217; in D minor. II. Renouveau</strong></p>
<p><strong>Leave A Tender Moment Alone &#8211; Billy Joel</strong><br />
Billy Joel is deeply, deeply uncool. I don&#8217;t care, I like it.</p>
<p><strong>Best That You Can Do &#8211; Christopher Cross</strong><br />
There is going to be hell to pay when I find out who broke in and planted this in my iTunes library.</p>
<p><strong>William, It Was Really Nothing &#8211; The Smiths</strong><br />
You know how I missed out on whole musical trends growing up? One of those trends was The Smiths, the only song I knew was How Soon is Now which I liked. A few years ago I bought a 2CD Best Of The Smiths collection to see what I had missed. And you know what? I hate The Smiths.<br />
How Soon in Now is still pretty cool though.</p>
<p><strong>I Could Be So Good For You &#8211; Dennis Waterman</strong><br />
Not sure where this comes from, maybe from my TV Theme collecting days.</p>
<p><strong>Ode To My Family &#8211; Cranberries</strong><br />
Everyone of a certain age has either this or Wonderwall by Oasis in their collection.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://sandfly.net.nz/blog/2009/06/25-random-songs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Spider House Rules</title>
		<link>http://sandfly.net.nz/blog/2008/12/the-spider-house-rules/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-spider-house-rules</link>
		<comments>http://sandfly.net.nz/blog/2008/12/the-spider-house-rules/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 12:57:02 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[photo]]></category>
		<category><![CDATA[spider]]></category>

		<guid isPermaLink="false">http://sandfly.net.nz/blog/?p=268</guid>
		<description><![CDATA[I consider myself a fan of spiders. I knew when I bought a wooden house that I would probably end up sharing it with some eigth-legged friends and I was perfectly OK with that. I do brush up their webs if they get too untidy but generally I leave them alone. This was wandering around <a href='http://sandfly.net.nz/blog/2008/12/the-spider-house-rules/' class='excerpt-more'>[...]</a>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I consider myself a fan of spiders. I knew when I bought a wooden house that I would probably end up sharing it with some eigth-legged friends and I was perfectly OK with that. I do brush up their webs if they get too untidy but generally I leave them alone.</p>
<p><center><img src="http://sandfly.net.nz/blog/wp-content/uploads/2008/12/spider.jpg" alt="" title="spider" width="400" height="194"/></center></p>
<p>This was wandering around next to my laptop tonight. I am pretty sure it was a <a href="http://en.wikipedia.org/wiki/White_tail_spider">white-tailed spider</a> for two reasons: 1: it was skulking around in the middle of the night with evil intent rather than just sitting in a corner like most of my spiders, and 2: it had a white tail.</p>
<p>The bite of the white-tail spider has a bad reputation for making bits of you drop off. I have always figured that this was an exaggeration and wikipedia backs me up. Still, I have been bitten by similarly sized spiders before and did not find the experience pleasant, so outside he goes. I can&#8217;t say I will be too upset if he gets eaten by a tui.</p>
<p>I have a new house rule: anything with more than 4 legs must be able to fit on a fifty cent piece.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://sandfly.net.nz/blog/2008/12/the-spider-house-rules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Movie Review : Taken</title>
		<link>http://sandfly.net.nz/blog/2008/09/movie-review-taken/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=movie-review-taken</link>
		<comments>http://sandfly.net.nz/blog/2008/09/movie-review-taken/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 09:38:43 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Culture]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[action]]></category>
		<category><![CDATA[movie]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://sandfly.net.nz/blog/?p=221</guid>
		<description><![CDATA[A man reluctantly lets his teenage daughter take a trip to Paris. As soon as she arrives she a kidnapped (or taken, if you will) by an evil white slavery ring. Luckily she was on the phone to her father at the time and manages to scream out a description of her attackers. Even more <a href='http://sandfly.net.nz/blog/2008/09/movie-review-taken/' class='excerpt-more'>[...]</a>
Related posts:<ol>
<li><a href='http://sandfly.net.nz/blog/2008/05/movie-review-iron-man/' rel='bookmark' title='Movie Review : Iron Man'>Movie Review : Iron Man</a></li>
<li><a href='http://sandfly.net.nz/blog/2009/03/movie-review-watchmen/' rel='bookmark' title='Movie Review : Watchmen'>Movie Review : Watchmen</a></li>
<li><a href='http://sandfly.net.nz/blog/2008/06/movie-review-black-book/' rel='bookmark' title='Movie Review : Black Book'>Movie Review : Black Book</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>A man reluctantly lets his teenage daughter take a trip to Paris. As soon as she arrives she a kidnapped (or taken, if you will) by an evil white slavery ring. Luckily she was on the phone to her father at the time and manages to scream out a description of her attackers. Even more lucky &#8211; her father is a retired &#8220;fixer&#8221; for the US government with the skills to take on a small army. He quickly flies to Paris and sets about finding his daughter using the time-honored shoot-everything-in-sight technique.</p>
<p>A bog standard revenge film, <a href="http://www.imdb.com/title/tt0936501/">Taken</a> does little to distinguish itself except by being a little more brutal than average. The hero kills and tortures dozens of nameless people to get his idiotic daughter back. Sure, &#8220;dey were all bad&#8221; (read the previous phrase in an Austrian accent) but half the people killed were only tangentially involved. Of course, the police are no help and are actively working against him &#8211; the city of Paris should sue the producers for defamation.</p>
<p>In short, not one of Stephen Seagals best films. </p>
<p>What did you say? </p>
<p>It&#8217;s a Liam Neeson movie? </p>
<p>No way!</p>
<p>Not recommended unless you really, really like this sort of thing.</p>
<p>Related posts:<ol>
<li><a href='http://sandfly.net.nz/blog/2008/05/movie-review-iron-man/' rel='bookmark' title='Movie Review : Iron Man'>Movie Review : Iron Man</a></li>
<li><a href='http://sandfly.net.nz/blog/2009/03/movie-review-watchmen/' rel='bookmark' title='Movie Review : Watchmen'>Movie Review : Watchmen</a></li>
<li><a href='http://sandfly.net.nz/blog/2008/06/movie-review-black-book/' rel='bookmark' title='Movie Review : Black Book'>Movie Review : Black Book</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://sandfly.net.nz/blog/2008/09/movie-review-taken/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Movie Review: Pan&#8217;s Labyrinth</title>
		<link>http://sandfly.net.nz/blog/2007/05/movie-review-pans-labyrinth/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=movie-review-pans-labyrinth</link>
		<comments>http://sandfly.net.nz/blog/2007/05/movie-review-pans-labyrinth/#comments</comments>
		<pubDate>Sun, 27 May 2007 02:48:00 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[fantasy]]></category>
		<category><![CDATA[film]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://sandfly.net.nz/blog/?p=82</guid>
		<description><![CDATA[A young girl travels with her mother to a remote military base in the Spanish countryside to live with her stepfather, an army captain. While there, she meets a magical faun who gives her three fantastic quests to carry out. This would be complicated enough, but in the meantime it is 1944 and the Spanish <a href='http://sandfly.net.nz/blog/2007/05/movie-review-pans-labyrinth/' class='excerpt-more'>[...]</a>
Related posts:<ol>
<li><a href='http://sandfly.net.nz/blog/2012/05/movie-review-the-avengers/' rel='bookmark' title='Movie Review : The Avengers'>Movie Review : The Avengers</a></li>
<li><a href='http://sandfly.net.nz/blog/2007/07/yet-another-movie-review/' rel='bookmark' title='Yet Another Movie Review'>Yet Another Movie Review</a></li>
<li><a href='http://sandfly.net.nz/blog/2007/05/movie-review-the-departed/' rel='bookmark' title='Movie Review: The Departed'>Movie Review: The Departed</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>A young girl travels with her mother to a remote military base in the Spanish countryside to live with her stepfather, an army captain. While there, she meets a magical faun who gives her three fantastic quests to carry out. This would be complicated enough, but in the meantime it is 1944 and the Spanish civil war rages on, the fort that they are staying at is full of intrigue, the girl&#8217;s mother pregnancy is not going well, and her new stepfather is a sadistic fascist. </p>
<p><a href="http://imdb.com/title/tt0457430/">Pan&#8217;s Labyrinth</a> is the type of magic realism that is not often seen in movies. I guess it resembles older films like <em>The Wizard of Oz</em> and <em>Labyrinth</em> in some ways, but Pan&#8217;s Labyrinth is a much darker tale despite featuring such a young protagonist. </p>
<p>
<center><img src='http://sandfly.net.nz/blog/wp-content/uploads/2007/05/panslabyrinthguy.jpg' alt='panslabyrinthguy.jpg' /><small>This guy has excellent hand-eye coordination</small></center>
</p>
<p>The film is also unusual in that the story focuses more on the events in the real world, while the fantasy elements exist more as a subplot. In fact, you could edit out the fantasy scenes altogether and still have a complete story. The deliberate contrast between the sinister creatures the girl must encounter in her quest with the more mundane human monsters she must live with is well done. This is not a story for young children &#8211; the film earns its R16 certification with several gory scenes.</p>
<p>Pan&#8217;s Labyrinth is one of the better films I have seen all year; highly recommended!</p>
<p>Related posts:<ol>
<li><a href='http://sandfly.net.nz/blog/2012/05/movie-review-the-avengers/' rel='bookmark' title='Movie Review : The Avengers'>Movie Review : The Avengers</a></li>
<li><a href='http://sandfly.net.nz/blog/2007/07/yet-another-movie-review/' rel='bookmark' title='Yet Another Movie Review'>Yet Another Movie Review</a></li>
<li><a href='http://sandfly.net.nz/blog/2007/05/movie-review-the-departed/' rel='bookmark' title='Movie Review: The Departed'>Movie Review: The Departed</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://sandfly.net.nz/blog/2007/05/movie-review-pans-labyrinth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

