<?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>Cademuir</title>
	<atom:link href="http://www.cademuir.eu/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cademuir.eu/blog</link>
	<description></description>
	<lastBuildDate>Thu, 17 May 2012 23:23:49 +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>Light Pollution &#8211; Perhaps the SQM-LU isn&#8217;t the best choice for a mobile setup!</title>
		<link>http://www.cademuir.eu/blog/2012/05/16/light-pollution-perhaps-the-sqm-lu-isnt-the-best-choice-for-a-mobile-setup/</link>
		<comments>http://www.cademuir.eu/blog/2012/05/16/light-pollution-perhaps-the-sqm-lu-isnt-the-best-choice-for-a-mobile-setup/#comments</comments>
		<pubDate>Wed, 16 May 2012 21:37:54 +0000</pubDate>
		<dc:creator>albertw</dc:creator>
				<category><![CDATA[Astronomy]]></category>
		<category><![CDATA[lightpollution]]></category>
		<category><![CDATA[sqm]]></category>

		<guid isPermaLink="false">http://www.cademuir.eu/blog/?p=672</guid>
		<description><![CDATA[I was considering getting the SQM-LU, the USB lensed SQM meter, for using as a mobile dark sky setup. This would be very similar to my previous attempt where I used a GPS and the IYA lightmeter around Wicklow. There are a few issues with using the SQM-LU in this way. The sampling time of [...]]]></description>
			<content:encoded><![CDATA[<p>I was considering getting the <a href="http://unihedron.com/projects/sqm-lu/">SQM-LU</a>, the USB lensed SQM meter, for using as a mobile dark sky setup. This would be very similar to my previous attempt where I used a GPS and the IYA lightmeter around Wicklow.</p>
<p>There are a few issues with using the SQM-LU in this way.</p>
<p><span id="more-672"></span><a href="http://www.cademuir.eu/blog/wp-content/uploads/2012/05/sqm-l_front_regular.jpg"><img class="size-thumbnail wp-image-703 alignleft" style="margin-left: 5px; margin-right: 5px;" title="sqm-l_front_regular" src="http://www.cademuir.eu/blog/wp-content/uploads/2012/05/sqm-l_front_regular-150x150.jpg" alt="" width="150" height="150" /></a>The sampling time of the SQM-LU can be between 1 to 10 seconds depending on the darkness of the sky. Used on a mobile platform on a typical road (60 km/h speed limit) a single reading may take up to 170 meters. This poses 2 problems. Firstly where do we define the reading to have been taken from, the center of the range of GPS coordinates sampled over this time would seem to be the best option here. Secondly, we have the possibility of sky brightness varying over this distance due to terrestrial effects; by that I mean oncoming headlights, houses, trees etc., which would skew the result towards a brighter value.</p>
<p>When climbing or descending the meter will not be pointed directly at the zenith. Provided the gradient was constant that would not be a problem, but that’s unlikely to be the case in reality, so the entire sample will not be pointed at the same point of sky. Roads tend to not be that steep in wicklow so the variance should not be much, but it would be there given the possible sample time.</p>
<p>The guide for the previous units whereby the initial result is best discarded should not apply to the SQM-LU. Given the constraints above it would be possible to take single readings every 200m or so. Stopping in lay bys etc. at best tends to give a resolution of 1km, the benefit being that you can pick good locations to sample.</p>
<p>Best practice for using the SQM is to take a set of readings and average them. Taking say, 4 readings, in the mobile set up could take approximately 700m. Interference from cars, trees etc. may pollute some results but these could be determined and disregarded. Determining the location is a bigger problem, as we would need to find the center of the used sample range, which will give us a point with a radius of 350m.</p>
<p>Thinking about these issues it seems that just stopping every kilometer or so and taking proper readings makes more sense, and does not involve spending €200 on a new device that while it seems like a good way to map large areas may not deliver adequate results in practice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cademuir.eu/blog/2012/05/16/light-pollution-perhaps-the-sqm-lu-isnt-the-best-choice-for-a-mobile-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting files for ipad with ffmpeg</title>
		<link>http://www.cademuir.eu/blog/2012/03/17/converting-files-for-ipad-with-ffmpeg/</link>
		<comments>http://www.cademuir.eu/blog/2012/03/17/converting-files-for-ipad-with-ffmpeg/#comments</comments>
		<pubDate>Sat, 17 Mar 2012 00:29:26 +0000</pubDate>
		<dc:creator>albertw</dc:creator>
				<category><![CDATA[computing]]></category>

		<guid isPermaLink="false">http://www.cademuir.eu/blog/?p=666</guid>
		<description><![CDATA[Works for me: ffmpeg -i INPUT -acodec aac -ac 2 -ab 160k  -vcodec libx264 -vpre iPod640 -f mp4 -strict experimental -threads 0 OUTPUT For other recipies, well, starting points anyway, see https://develop.participatoryculture.org/index.php/ConversionMatrix]]></description>
			<content:encoded><![CDATA[<p>Works for me:</p>
<p>ffmpeg -i INPUT -acodec aac -ac 2 -ab 160k  -vcodec libx264 -vpre iPod640 -f mp4 -strict experimental -threads 0 OUTPUT</p>
<p>For other recipies, well, starting points anyway, see <a title="https://develop.participatoryculture.org/index.php/ConversionMatrix" href="https://develop.participatoryculture.org/index.php/ConversionMatrix">https://develop.participatoryculture.org/index.php/ConversionMatrix</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cademuir.eu/blog/2012/03/17/converting-files-for-ipad-with-ffmpeg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hacking a webcam for long exposure astrophotography</title>
		<link>http://www.cademuir.eu/blog/2011/12/30/hacking-a-webcam-for-long-exposure-astrophotography/</link>
		<comments>http://www.cademuir.eu/blog/2011/12/30/hacking-a-webcam-for-long-exposure-astrophotography/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 19:56:41 +0000</pubDate>
		<dc:creator>albertw</dc:creator>
				<category><![CDATA[Astronomy]]></category>
		<category><![CDATA[Photography]]></category>
		<category><![CDATA[astrophotography]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[webcam]]></category>

		<guid isPermaLink="false">http://www.cademuir.eu/blog/?p=651</guid>
		<description><![CDATA[I finally got around to hacking a Philips SPC 900 to enable it to take long exposure images suitable for astrophotography. The modifications are fairly well known. The approach I took is a mixture of the http://www.boltonastro.org.uk/Members%5FArea/Projects/spc880conversion.pdf and http://www.yesyes.info/index.php/diy/philips-spc900-webcam-lx-and-ampoff-mod/ . The circuit between both approaches is roughly the same, I followed the circuit in the [...]]]></description>
			<content:encoded><![CDATA[<p>I finally got around to hacking a Philips SPC 900 to enable it to take long exposure images suitable for astrophotography. The modifications are fairly well known. The approach I took is a mixture of the <a href="http://www.boltonastro.org.uk/Members%5FArea/Projects/spc880conversion.pdf">http://www.boltonastro.org.uk/Members%5FArea/Projects/spc880conversion.pdf</a> and <a href="http://www.yesyes.info/index.php/diy/philips-spc900-webcam-lx-and-ampoff-mod/">http://www.yesyes.info/index.php/diy/philips-spc900-webcam-lx-and-ampoff-mod/</a> .</p>
<p>The circuit between both approaches is roughly the same, I followed the circuit in the former. The modification allows the camera to be switched to a long exposure mode via a switch. The switch can be triggered over a serial port, so I added a USB to serial adaptor and a USB hub (both from ebay) to the unit to allow control from a computer and have just one cable coming from the unit.<span id="more-651"></span></p>
<p>As soon as you have some new astronomy kit to try out it inevitably becomes overcast, so no test images just yet however I&#8217;ve included some images of the construction.</p>
<p>
<a href='http://www.cademuir.eu/blog/2011/12/30/hacking-a-webcam-for-long-exposure-astrophotography/img_20111230_184159/' title='IMG_20111230_184159'><img width="150" height="150" src="http://www.cademuir.eu/blog/wp-content/uploads/2011/12/IMG_20111230_184159-150x150.jpg" class="attachment-thumbnail" alt="IMG_20111230_184159" title="IMG_20111230_184159" /></a>
<a href='http://www.cademuir.eu/blog/2011/12/30/hacking-a-webcam-for-long-exposure-astrophotography/img_20111230_182128/' title='IMG_20111230_182128'><img width="150" height="150" src="http://www.cademuir.eu/blog/wp-content/uploads/2011/12/IMG_20111230_182128-150x150.jpg" class="attachment-thumbnail" alt="IMG_20111230_182128" title="IMG_20111230_182128" /></a>
<a href='http://www.cademuir.eu/blog/2011/12/30/hacking-a-webcam-for-long-exposure-astrophotography/img_20111230_174725/' title='IMG_20111230_174725'><img width="150" height="150" src="http://www.cademuir.eu/blog/wp-content/uploads/2011/12/IMG_20111230_174725-150x150.jpg" class="attachment-thumbnail" alt="IMG_20111230_174725" title="IMG_20111230_174725" /></a>
<a href='http://www.cademuir.eu/blog/2011/12/30/hacking-a-webcam-for-long-exposure-astrophotography/img_20111230_154302/' title='IMG_20111230_154302'><img width="150" height="150" src="http://www.cademuir.eu/blog/wp-content/uploads/2011/12/IMG_20111230_154302-150x150.jpg" class="attachment-thumbnail" alt="IMG_20111230_154302" title="IMG_20111230_154302" /></a>
<a href='http://www.cademuir.eu/blog/2011/12/30/hacking-a-webcam-for-long-exposure-astrophotography/img_20111230_153820/' title='IMG_20111230_153820'><img width="150" height="150" src="http://www.cademuir.eu/blog/wp-content/uploads/2011/12/IMG_20111230_153820-150x150.jpg" class="attachment-thumbnail" alt="IMG_20111230_153820" title="IMG_20111230_153820" /></a>
<a href='http://www.cademuir.eu/blog/2011/12/30/hacking-a-webcam-for-long-exposure-astrophotography/img_20111230_153808/' title='IMG_20111230_153808'><img width="150" height="150" src="http://www.cademuir.eu/blog/wp-content/uploads/2011/12/IMG_20111230_153808-150x150.jpg" class="attachment-thumbnail" alt="IMG_20111230_153808" title="IMG_20111230_153808" /></a>
<a href='http://www.cademuir.eu/blog/2011/12/30/hacking-a-webcam-for-long-exposure-astrophotography/img_20111229_181130/' title='IMG_20111229_181130'><img width="150" height="150" src="http://www.cademuir.eu/blog/wp-content/uploads/2011/12/IMG_20111229_181130-150x150.jpg" class="attachment-thumbnail" alt="IMG_20111229_181130" title="IMG_20111229_181130" /></a>
<a href='http://www.cademuir.eu/blog/2011/12/30/hacking-a-webcam-for-long-exposure-astrophotography/img_20111229_181111/' title='IMG_20111229_181111'><img width="150" height="150" src="http://www.cademuir.eu/blog/wp-content/uploads/2011/12/IMG_20111229_181111-150x150.jpg" class="attachment-thumbnail" alt="IMG_20111229_181111" title="IMG_20111229_181111" /></a>
<a href='http://www.cademuir.eu/blog/2011/12/30/hacking-a-webcam-for-long-exposure-astrophotography/img_20111229_181033/' title='IMG_20111229_181033'><img width="150" height="150" src="http://www.cademuir.eu/blog/wp-content/uploads/2011/12/IMG_20111229_181033-150x150.jpg" class="attachment-thumbnail" alt="IMG_20111229_181033" title="IMG_20111229_181033" /></a>
<a href='http://www.cademuir.eu/blog/2011/12/30/hacking-a-webcam-for-long-exposure-astrophotography/img_20111229_180312/' title='IMG_20111229_180312'><img width="150" height="150" src="http://www.cademuir.eu/blog/wp-content/uploads/2011/12/IMG_20111229_180312-150x150.jpg" class="attachment-thumbnail" alt="IMG_20111229_180312" title="IMG_20111229_180312" /></a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cademuir.eu/blog/2011/12/30/hacking-a-webcam-for-long-exposure-astrophotography/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Old computer magazines free to a good home</title>
		<link>http://www.cademuir.eu/blog/2011/12/29/old-computer-magazines-free-to-a-good-home/</link>
		<comments>http://www.cademuir.eu/blog/2011/12/29/old-computer-magazines-free-to-a-good-home/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 19:45:15 +0000</pubDate>
		<dc:creator>albertw</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[amiga]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[magazines]]></category>

		<guid isPermaLink="false">http://www.cademuir.eu/blog/?p=640</guid>
		<description><![CDATA[I&#8217;m clearing out the attic and have some old computer magazines that some of you might be interested in. Free to a good home if you can collect from me, otherwise they go to recycling. The first batch contains titles like Personal Computer News and Your Computer from around 1981-1983. The second batch are mainly [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m clearing out the attic and have some old computer magazines that some of you might be interested in. Free to a good home if you can collect from me, otherwise they go to recycling.</p>
<p>The first batch contains titles like Personal Computer News and Your Computer from around 1981-1983. The second batch are mainly Amiga Shopper (and the odd CU Amiga and Amiga Format) from around 1994.</p>
<p>UPDATE: All gone!<span id="more-640"></span></p>
<p>Drop me an email if you are interested in them.</p>
<p>
<a href='http://www.cademuir.eu/blog/2011/12/29/old-computer-magazines-free-to-a-good-home/img_20111227_202659/' title='IMG_20111227_202659'><img width="150" height="150" src="http://www.cademuir.eu/blog/wp-content/uploads/2011/12/IMG_20111227_202659-150x150.jpg" class="attachment-thumbnail" alt="IMG_20111227_202659" title="IMG_20111227_202659" /></a>
<a href='http://www.cademuir.eu/blog/2011/12/29/old-computer-magazines-free-to-a-good-home/img_20111227_202537/' title='IMG_20111227_202537'><img width="150" height="150" src="http://www.cademuir.eu/blog/wp-content/uploads/2011/12/IMG_20111227_202537-150x150.jpg" class="attachment-thumbnail" alt="IMG_20111227_202537" title="IMG_20111227_202537" /></a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cademuir.eu/blog/2011/12/29/old-computer-magazines-free-to-a-good-home/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First Solar Haplha image in years</title>
		<link>http://www.cademuir.eu/blog/2011/11/27/first-solar-haplha-image-in-years/</link>
		<comments>http://www.cademuir.eu/blog/2011/11/27/first-solar-haplha-image-in-years/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 12:27:35 +0000</pubDate>
		<dc:creator>albertw</dc:creator>
				<category><![CDATA[Astronomy]]></category>
		<category><![CDATA[astronomy]]></category>
		<category><![CDATA[astrophotography]]></category>
		<category><![CDATA[solar]]></category>

		<guid isPermaLink="false">http://www.cademuir.eu/blog/?p=621</guid>
		<description><![CDATA[I got the PST out again recently. As we approach Solar Maximum it would be a shame not to have a look every now and then. This was taken by attaching my Canon 400D to the scope. 1s exposure. Green channel extracted, a few tweaks, then coloured orange. The diagonal lines are from Nebulosity, which [...]]]></description>
			<content:encoded><![CDATA[<p>I got the PST out again recently. As we approach Solar Maximum it would be a shame not to have a look every now and then.<span id="more-621"></span></p>
<p style="text-align: center;"><a href="http://www.cademuir.eu/blog/wp-content/uploads/2011/11/ha1.jpg"><img class="aligncenter size-full wp-image-622" title="ha1" src="http://www.cademuir.eu/blog/wp-content/uploads/2011/11/ha1.jpg" alt="" width="800" height="774" /></a></p>
<p>This was taken by attaching my Canon 400D to the scope. 1s exposure. Green channel extracted, a few tweaks, then coloured orange. The diagonal lines are from <a href="http://www.stark-labs.com/nebulosity.html">Nebulosity</a>, which is image aquisition software that I&#8217;m trying out. The free to try version puts diagonal lines in the images.</p>
<p>It needs better focusing, and the red channel with the flares needs to be merged in, but I&#8217;m happy with it given its the first image of the Sun I&#8217;ve tried with this setup since 2006.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cademuir.eu/blog/2011/11/27/first-solar-haplha-image-in-years/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why I won&#8217;t be buing an indesit in future. Appliances should be servicable.</title>
		<link>http://www.cademuir.eu/blog/2011/11/26/why-i-wont-be-buing-an-indesit-in-future-appliances-should-be-servicable/</link>
		<comments>http://www.cademuir.eu/blog/2011/11/26/why-i-wont-be-buing-an-indesit-in-future-appliances-should-be-servicable/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 23:44:11 +0000</pubDate>
		<dc:creator>albertw</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.cademuir.eu/blog/?p=616</guid>
		<description><![CDATA[Recently a small piece of the door seal on our washer dryer came out in the wash. It was small but enough to mean water on the kitchen floor so it needed replacing. The solution seemed simple. Order a replacement seal. Fitting it however was a problem. Indesit decided to make this model un-servicable. It&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Recently a small piece of the door seal on our washer dryer came out in the wash. It was small but enough to mean water on the kitchen floor so it needed replacing.</p>
<p>The solution seemed simple. Order a replacement seal. Fitting it however was a problem.<span id="more-616"></span></p>
<p>Indesit decided to make this model un-servicable. It&#8217;s not possible to get enough access to the drum to fit the seal without, well removing the drum. So what should be a 30 minute job took 4 hours. The case is welded together, and apparently the drum was lowered in in the factory.</p>
<p><a href="http://www.cademuir.eu/blog/wp-content/uploads/2011/11/IMG_20111116_135301.jpg"><img class="aligncenter size-full wp-image-617" title="IMG_20111116_135301" src="http://www.cademuir.eu/blog/wp-content/uploads/2011/11/IMG_20111116_135301.jpg" alt="" width="640" height="480" /></a>Now I&#8217;m sure this makes sense for indesits sales and operations management. I assume it simplifies manufacturing, and makes it cheaper, by easily allowing the factory to assemble different machines on the same line by just changing the pre-made cases and drums. What it also does it creates a unit that for most people is un-serviceable, leading most likely to the machine being trashed and a new one being bought. Not great for the environment, not great for the consumer, but good for indesit.</p>
<p>So when this machine finally does pack it in an need replacing. I&#8217;ll be replacing it one that I can do basic maintenance on. Probably not an indesit if our current machine is typical of them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cademuir.eu/blog/2011/11/26/why-i-wont-be-buing-an-indesit-in-future-appliances-should-be-servicable/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Philips SPC900 Mods</title>
		<link>http://www.cademuir.eu/blog/2011/11/25/philips-spc900-mods/</link>
		<comments>http://www.cademuir.eu/blog/2011/11/25/philips-spc900-mods/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 22:50:31 +0000</pubDate>
		<dc:creator>albertw</dc:creator>
				<category><![CDATA[Astronomy]]></category>

		<guid isPermaLink="false">http://www.cademuir.eu/blog/?p=611</guid>
		<description><![CDATA[A collection of some of the main pages describing the long exposure and amp mods for the SPC900 webcam. http://home.zonnet.nl/m.m.j.meijer/D_I_Y/spc900nc.htm http://www.yesyes.info/index.php/diy/philips-spc900-webcam-lx-and-ampoff-mod/ http://stargazerslounge.com/astro-lounge/114129-pictures-taken-during-some-lx-mono-mods.html http://www.boltonastro.org.uk/Members%5FArea/Projects/spc880conversion.pdf Now just to read through them all, order the bits I need, and do the mod. Simples. &#160;]]></description>
			<content:encoded><![CDATA[<p>A collection of some of the main pages describing the long exposure and amp mods for the SPC900 webcam.</p>
<ul>
<li><a href="http://home.zonnet.nl/m.m.j.meijer/D_I_Y/spc900nc.htm">http://home.zonnet.nl/m.m.j.meijer/D_I_Y/spc900nc.htm</a></li>
<li><a href="http://www.yesyes.info/index.php/diy/philips-spc900-webcam-lx-and-ampoff-mod/">http://www.yesyes.info/index.php/diy/philips-spc900-webcam-lx-and-ampoff-mod/</a></li>
<li><a href="http://stargazerslounge.com/astro-lounge/114129-pictures-taken-during-some-lx-mono-mods.html">http://stargazerslounge.com/astro-lounge/114129-pictures-taken-during-some-lx-mono-mods.html</a></li>
<li><a href="http://www.boltonastro.org.uk/Members%5FArea/Projects/spc880conversion.pdf">http://www.boltonastro.org.uk/Members%5FArea/Projects/spc880conversion.pdf</a></li>
</ul>
<p>Now just to read through them all, order the bits I need, and do the mod. Simples.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cademuir.eu/blog/2011/11/25/philips-spc900-mods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python : generating unittests on the fly</title>
		<link>http://www.cademuir.eu/blog/2011/10/23/python-generating-unittests-on-the-fly/</link>
		<comments>http://www.cademuir.eu/blog/2011/10/23/python-generating-unittests-on-the-fly/#comments</comments>
		<pubDate>Sun, 23 Oct 2011 01:09:39 +0000</pubDate>
		<dc:creator>albertw</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.cademuir.eu/blog/?p=523</guid>
		<description><![CDATA[When creating python unit tests you need to create a method in a unittest class. The problem however is when you don&#8217;t know until the code is running what these tests will be. In my particular case I need to run a series of tests against a number of Solaris packages. But I won&#8217;t know [...]]]></description>
			<content:encoded><![CDATA[<p>When creating python unit tests you need to create a method in a unittest class. The problem however is when you don&#8217;t know until the code is running what these tests will be. In my particular case I need to run a series of tests against a number of Solaris packages. But I won&#8217;t know what the packages will be in advance.<span id="more-523"></span></p>
<p>Thankfully python allows to to add a method to a class on the fly:</p>
<pre class="brush: python; title: ; notranslate">
&gt;&gt;&gt; class test:
...     pass
...
&gt;&gt;&gt; def foo(self):
...     print &quot;hello, world&quot;
...
&gt;&gt;&gt; dir(test)
['__doc__', '__module__']
&gt;&gt;&gt; test.foo=foo
&gt;&gt;&gt; dir(test)
['__doc__', '__module__', 'foo']
&gt;&gt;&gt; bar=test()
&gt;&gt;&gt; bar.foo()
hello, world
&gt;&gt;&gt;
</pre>
<p>Here we initially create an empty class &#8216;test&#8217; and a function &#8216;foo&#8217;. Then add the function &#8216;foo&#8217; to the class &#8216;test&#8217;, so that when we create a &#8216;test&#8217; object, we can call the &#8216;foo&#8217; method in it.</p>
<p>We use the same trick to add a unittest test to a unittest class:</p>
<pre class="brush: python; title: ; notranslate">

&gt;&gt;&gt; import unittest
&gt;&gt;&gt; class mytest(unittest.TestCase):
...     pass
...
&gt;&gt;&gt; def test_testcase(self):
...     self.assertEqual(&quot;hello&quot;,&quot;hello&quot;)
...
&gt;&gt;&gt; suite = unittest.TestLoader().loadTestsFromTestCase(mytest)
&gt;&gt;&gt; unittest.TextTestRunner(verbosity=2).run(suite)

----------------------------------------------------------------------
Ran 0 tests in 0.015s

OK
&lt;unittest.runner.TextTestResult run=0 errors=0 failures=0&gt;
&gt;&gt;&gt; mytest.test_testcase=test_testcase
&gt;&gt;&gt; unittest.TextTestRunner(verbosity=2).run(suite)

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
&lt;unittest.runner.TextTestResult run=0 errors=0 failures=0&gt;
&gt;&gt;&gt; suite = unittest.TestLoader().loadTestsFromTestCase(mytest)
&gt;&gt;&gt; unittest.TextTestRunner(verbosity=2).run(suite)
test_testcase (__main__.mytest) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
&lt;unittest.runner.TextTestResult run=1 errors=0 failures=0&gt;
&gt;&gt;&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cademuir.eu/blog/2011/10/23/python-generating-unittests-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python: Searching for a string within a list &#8211; List comprehension</title>
		<link>http://www.cademuir.eu/blog/2011/10/20/python-searching-for-a-string-within-a-list-list-comprehension/</link>
		<comments>http://www.cademuir.eu/blog/2011/10/20/python-searching-for-a-string-within-a-list-list-comprehension/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 23:38:39 +0000</pubDate>
		<dc:creator>albertw</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.cademuir.eu/blog/?p=509</guid>
		<description><![CDATA[The simple way to search for a string in a list is just to use &#8216;if string in list&#8217;. eg: But what if you need to search for just &#8216;cat&#8217; or some other regular expression and return a list of the list items that match, or a list of selected parts of list items that [...]]]></description>
			<content:encoded><![CDATA[<p>The simple way to search for a string in a list is just to use &#8216;if string in list&#8217;. eg:</p>
<pre class="brush: python; title: ; notranslate">
&gt;&gt;&gt; list=['a cat','a dog','a yacht']
&gt;&gt;&gt; string='a cat'
&gt;&gt;&gt; if string in list:
...     print 'found a cat!'
...
found a cat!
&gt;&gt;&gt;
</pre>
<p><span id="more-509"></span></p>
<pre></pre>
<p>But what if you need to search for just &#8216;cat&#8217; or some other regular expression and return a list of the list items that match, or a list of selected parts of list items that match.<br />
Then you need list comprehension.</p>
<pre class="brush: python; title: ; notranslate">
&gt;&gt;&gt; import re
&gt;&gt;&gt; list=['a cat','a dog','a yacht','cats']
&gt;&gt;&gt; regex=re.compile(&quot;.*(cat).*&quot;)
&gt;&gt;&gt; [m.group(0) for l in list for m in [regex.search(l)] if m]
['a cat', 'cats']
&gt;&gt;&gt; [m.group(1) for l in list for m in [regex.search(l)] if m]
['cat', 'cat']
&gt;&gt;&gt;
</pre>
<p>Lets work through that. Firstly we&#8217;re going to use the <a href="http://docs.python.org/library/re.html">regular expression library so</a> we import that. <a href="http://docs.python.org/library/re.html#re.compile">re.compile</a> lets us create a regular expression that we can later use for search and matching.</p>
<p>Now lets look at a simpler comprehension line:</p>
<pre class="brush: python; title: ; notranslate">
&gt;&gt;&gt; [m for l in list for m in [regex.search(l)]]
[&lt;_sre.SRE_Match object at 0x10cfbb0a8&gt;, None, None, &lt;_sre.SRE_Match object at 0x10cfbb6c0&gt;]
</pre>
<p>This is creating a list of the results of running regex.search() on each item in l.</p>
<p>Next we want to exclude the None values. So we use an if statement to only include the not None values:</p>
<pre class="brush: python; title: ; notranslate">
&gt;&gt;&gt; [m for l in list for m in [regex.search(l)] if m ]
[&lt;_sre.SRE_Match object at 0x10cfbb6c0&gt;, &lt;_sre.SRE_Match object at 0x10cfd0be8&gt;]
&gt;&gt;&gt;
</pre>
<p>Lastly rather than returning just a list of the m&#8217;s, which are RE match objects, we get the information we want from them.</p>
<pre class="brush: python; title: ; notranslate">
&gt;&gt;&gt; [m.group(0) for l in list for m in [regex.search(l)] if m]
['a cat', 'cats']
&gt;&gt;&gt; [m.group(1) for l in list for m in [regex.search(l)] if m]
['cat', 'cat']
&gt;&gt;&gt;
</pre>
<p>Very useful if you have say a list of Solaris 11 package fmri&#8217;s and want to extract a set of package names based on a regular expression of their version number for instance <img src='http://www.cademuir.eu/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.cademuir.eu/blog/2011/10/20/python-searching-for-a-string-within-a-list-list-comprehension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UK Windows Keyboard on a Mac Book Pro</title>
		<link>http://www.cademuir.eu/blog/2011/10/20/uk-windows-keyboard-on-a-mac-book-pro/</link>
		<comments>http://www.cademuir.eu/blog/2011/10/20/uk-windows-keyboard-on-a-mac-book-pro/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 23:08:46 +0000</pubDate>
		<dc:creator>albertw</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.cademuir.eu/blog/?p=507</guid>
		<description><![CDATA[It started well. I just plugged in the keyboard and it appeared to work. Until I tried typing an email and the &#8216;to&#8217; line came out with a &#8221; instead of an @. Aha! Simple &#8211; just change the keyboard layout. That&#8217;s a lot easier said than done in OSX Lion. For a start there [...]]]></description>
			<content:encoded><![CDATA[<p>It started well. I just plugged in the keyboard and it appeared to work. Until I tried typing an email and the &#8216;to&#8217; line came out with a &#8221; instead of an @. Aha! Simple &#8211; just change the keyboard layout.</p>
<p>That&#8217;s a lot easier said than done in OSX Lion. For a start there does not appear to be a set of keyboard layouts to choose from.</p>
<p>Enter <a href="http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&#038;id=ukelele">Ukelele</a>. This tool lets you create custom keyboard layouts. All I actually needed to do was take the Logitech UK International keyboard and remap the | key as everything else was as I needed. </p>
<p>Now I can finally use my old Microsoft Wireless Keyboard 6000 with my Mac.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cademuir.eu/blog/2011/10/20/uk-windows-keyboard-on-a-mac-book-pro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

