<?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>12:50, press Return</title>
	<atom:link href="http://sainthuck.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://sainthuck.de</link>
	<description>a blog driven by coffee and cigarettes</description>
	<lastBuildDate>Thu, 22 Mar 2012 21:20:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Efficiently calculating Hamming neighbourhoods in Haskell</title>
		<link>http://sainthuck.de/2011/08/efficiently-calculating-hamming-neighbourhoods-in-haskell/</link>
		<comments>http://sainthuck.de/2011/08/efficiently-calculating-hamming-neighbourhoods-in-haskell/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 12:29:45 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sainthuck.de/?p=387</guid>
		<description><![CDATA[How can we compute the -neighbourhood of a point ? Mathematically it&#8217;s no problem, we can just write The first idea would be to exploit Haskell&#8217;s math friendly syntactic feature calld list comprehension which would yield neigh :: Int -&#62; Searchpoint -&#62; &#91;Searchpoint&#93; neigh d x = &#91;y &#124; y Searchpoint -&#62; &#91;Searchpoint&#93; neigh d [...]]]></description>
			<content:encoded><![CDATA[<p>How can we compute the <img src='http://sainthuck.de/wp-content/latex/827/8277e0910d750195b448797616e091ad-T-dcdccc-0.png' style='border-style: none;' alt='d' title='d' class='latex' />-neighbourhood of a point <img src='http://sainthuck.de/wp-content/latex/9dd/9dd4e461268c8034f5c8564e155c67a6-T-dcdccc-0.png' style='border-style: none;' alt='x' title='x' class='latex' />? Mathematically it&#8217;s no problem, we can just write</p>
<p style="text-align: center;"><img src='http://sainthuck.de/wp-content/latex/966/966fdd32b36d835b32babe36a67888b6-T-dcdccc-0.png' style='border-style: none;' alt='N_d(x) = \{y\in\{0,1\}^n\,|\,0 &lt; d(x,y)\leq d\}' title='N_d(x) = \{y\in\{0,1\}^n\,|\,0 &lt; d(x,y)\leq d\}' class='latex' /></p>
<p style="text-align: left;">The first idea would be to exploit Haskell&#8217;s math friendly syntactic feature calld list comprehension which would yield</p>

<div class="wp_syntax"><div class="code"><pre class="haskell">neigh <span class="sy0">::</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"><span class="kw4">Int</span></a> <span class="sy0">-&gt;</span> Searchpoint <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>Searchpoint<span class="br0">&#93;</span>
neigh d x <span class="sy0">=</span> <span class="br0">&#91;</span>y <span class="sy0">|</span> y Searchpoint <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>Searchpoint<span class="br0">&#93;</span>
neigh d x tabu <span class="sy0">=</span> <span class="br0">&#40;</span>f <span class="sy0">$</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:iterate"><span class="kw3">iterate</span></a> <span class="br0">&#40;</span>g <span class="br0">&#41;</span> <span class="br0">&#91;</span>x<span class="br0">&#93;</span><span class="br0">&#41;</span> \\ <span class="br0">&#91;</span>x<span class="br0">&#93;</span>
<span class="kw1">where</span> f <span class="sy0">=</span> nub' <span class="sy0">.</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:concat"><span class="kw3">concat</span></a> <span class="sy0">.</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:take"><span class="kw3">take</span></a> d <span class="sy0">.</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:tail"><span class="kw3">tail</span></a>
g <span class="sy0">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> flipAt <span class="br0">&#91;</span><span class="nu0">1</span> <span class="sy0">..</span> n<span class="br0">&#93;</span></pre></div></div>

<p>What&#8217;s iterate (g) [x]? Formally it is</p>
<pre>iterate (g) [x] == [[x], g[x], g(g[x]), ...]</pre>
<p>Since we&#8217;re not ineterested in the first element, we only consider the tail of that iterated list. What are the elements? Let&#8217;s see the first three results for the search point <img src='http://sainthuck.de/wp-content/latex/42a/42a7ea1f78f922f28ddb852d67616f88-T-dcdccc-0.png' style='border-style: none;' alt='x=0^5' title='x=0^5' class='latex' />.</p>
<pre>g [x] ==
 [[1, , , , ],[ ,1, , , ],[ , ,1, , ],[ , , ,1, ],[ , , , ,1]]</pre>
<p>Since g is a list of functions, every element of g is applied to every element of [x] which is just x, so we get exactly the neighbourhood of distance 1 of <img src='http://sainthuck.de/wp-content/latex/9dd/9dd4e461268c8034f5c8564e155c67a6-T-dcdccc-0.png' style='border-style: none;' alt='x' title='x' class='latex' />.</p>
<pre>g (g [x])) ==
 [[ , , , , ],[1,1, , , ],[1, ,1, , ],[1, , ,1, ],[1, , , ,1]
 ,[1,1, , , ],[ , , , , ],[ ,1,1, , ],[ ,1, ,1, ],[ ,1, , ,1]
 ,[1, ,1, , ],[ ,1,1, , ],[ , , , , ],[ , ,1,1, ],[ , ,1, ,1]
 ,[1, , ,1, ],[ ,1, ,1, ],[ , ,1,1, ],[ , , , , ],[ , , ,1,1]
 ,[1, , , ,1],[ ,1, , ,1],[ , ,1, ,1],[ , , ,1,1],[ , , , , ]]</pre>
<p>Now every flipping function is applied to the first result. We already see that there are several duplicate elements. In fact there are 25 total results whereas there are only 11 unique results.</p>
<pre>g (g (g [x])) ==
 [[1, , , , ],[ ,1, , , ],[ , ,1, , ],[ , , ,1, ],[ , , , ,1]
 ,[ ,1, , , ],[1, , , , ],[1,1,1, , ],[1,1, ,1, ],[1,1, , ,1]
 ,[ , ,1, , ],[1,1,1, , ],[1, , , , ],[1, ,1,1, ],[1, ,1, ,1]
 ,[ , , ,1, ],[1,1, ,1, ],[1, ,1,1, ],[1, , , , ],[1, , ,1,1]
 ,[ , , , ,1],[1,1, , ,1],[1, ,1, ,1],[1, , ,1,1],[1, , , , ]
 ,[ ,1, , , ],[1, , , , ],[1,1,1, , ],[1,1, ,1, ],[1,1, , ,1]
 ,[1, , , , ],[ ,1, , , ],[ , ,1, , ],[ , , ,1, ],[ , , , ,1]
 ,[1,1,1, , ],[ , ,1, , ],[ ,1, , , ],[ ,1,1,1, ],[ ,1,1, ,1]
 ,[1,1, ,1, ],[ , , ,1, ],[ ,1,1,1, ],[ ,1, , , ],[ ,1, ,1,1]
 ,[1,1, , ,1],[ , , , ,1],[ ,1,1, ,1],[ ,1, ,1,1],[ ,1, , , ]
 ,[ , ,1, , ],[1,1,1, , ],[1, , , , ],[1, ,1,1, ],[1, ,1, ,1]
 ,[1,1,1, , ],[ , ,1, , ],[ ,1, , , ],[ ,1,1,1, ],[ ,1,1, ,1]
 ,[1, , , , ],[ ,1, , , ],[ , ,1, , ],[ , , ,1, ],[ , , , ,1]
 ,[1, ,1,1, ],[ ,1,1,1, ],[ , , ,1, ],[ , ,1, , ],[ , ,1,1,1]
 ,[1, ,1, ,1],[ ,1,1, ,1],[ , , , ,1],[ , ,1,1,1],[ , ,1, , ]
 ,[ , , ,1, ],[1,1, ,1, ],[1, ,1,1, ],[1, , , , ],[1, , ,1,1]
 ,[1,1, ,1, ],[ , , ,1, ],[ ,1,1,1, ],[ ,1, , , ],[ ,1, ,1,1]
 ,[1, ,1,1, ],[ ,1,1,1, ],[ , , ,1, ],[ , ,1, , ],[ , ,1,1,1]
 ,[1, , , , ],[ ,1, , , ],[ , ,1, , ],[ , , ,1, ],[ , , , ,1]
 ,[1, , ,1,1],[ ,1, ,1,1],[ , ,1,1,1],[ , , , ,1],[ , , ,1, ]
 ,[ , , , ,1],[1,1, , ,1],[1, ,1, ,1],[1, , ,1,1],[1, , , , ]
 ,[1,1, , ,1],[ , , , ,1],[ ,1,1, ,1],[ ,1, ,1,1],[ ,1, , , ]
 ,[1, ,1, ,1],[ ,1,1, ,1],[ , , , ,1],[ , ,1,1,1],[ , ,1, , ]
 ,[1, , ,1,1],[ ,1, ,1,1],[ , ,1,1,1],[ , , , ,1],[ , , ,1, ]
 ,[1, , , , ],[ ,1, , , ],[ , ,1, , ],[ , , ,1, ],[ , , , ,1]]</pre>
<p>In this case there are even 125 total results, but only 15 of those are unique. We can comb out duplicate elements with Haskell&#8217;s nub function, and since the order of the elements doesn&#8217;t matter in our case we can even use a faster version, namely nub&#8217; = toList . fromList. The functions toList and fromList have to be imported from Data.Set, they are implementations of set/list conversions respectivley. As we&#8217;ve seen above a huge effort is being made just to remove duplicate elements. We see that this method has complexity <img src='http://sainthuck.de/wp-content/latex/ac9/ac9ccd0abf9456dd6444960f0c0fa2ef-T-dcdccc-0.png' style='border-style: none;' alt='\mathcal{O}(n^d)' title='\mathcal{O}(n^d)' class='latex' /> which is polynomial in <img src='http://sainthuck.de/wp-content/latex/7b8/7b8b965ad4bca0e41ab51de7b31363a1-T-dcdccc-0.png' style='border-style: none;' alt='n' title='n' class='latex' /> for constant <img src='http://sainthuck.de/wp-content/latex/827/8277e0910d750195b448797616e091ad-T-dcdccc-0.png' style='border-style: none;' alt='d' title='d' class='latex' /> but exponential in <img src='http://sainthuck.de/wp-content/latex/827/8277e0910d750195b448797616e091ad-T-dcdccc-0.png' style='border-style: none;' alt='d' title='d' class='latex' />. Since we&#8217;re interested in implementing neighbourhoods efficiently right now we have to come up with something better, preferably a solution that doesn&#8217;t even create duplicate elements.</p>
<p>Suppose we need a <img src='http://sainthuck.de/wp-content/latex/827/8277e0910d750195b448797616e091ad-T-dcdccc-0.png' style='border-style: none;' alt='d' title='d' class='latex' />-neighbourhood. The search points of Hamming distance <img src='http://sainthuck.de/wp-content/latex/827/8277e0910d750195b448797616e091ad-T-dcdccc-0.png' style='border-style: none;' alt='d' title='d' class='latex' /> of a specific search point are those points that have exactly three bits flipped. There are exactly <img src='http://sainthuck.de/wp-content/latex/b8b/b8bec58337a36d66981c3c2c8bd52ee8-T-dcdccc-0.png' style='border-style: none;' alt='\binom{n}{d}' title='\binom{n}{d}' class='latex' /> of those. The indices of these points can be described by <img src='http://sainthuck.de/wp-content/latex/6eb/6eb4d24a3c6779b88a9df65e54c2b02c-T-dcdccc-0.png' style='border-style: none;' alt='\binom{\haken{n}}{d}' title='\binom{\haken{n}}{d}' class='latex' />. We can calculate these indices efficiently like this:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell">subsets <span class="sy0">::</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"><span class="kw4">Int</span></a> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>a<span class="br0">&#93;</span><span class="br0">&#93;</span>
subsets <span class="nu0">0</span> <span class="sy0">_</span> <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><span class="br0">&#93;</span><span class="br0">&#93;</span>
subsets <span class="sy0">_</span> <span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#93;</span>
subsets k <span class="br0">&#40;</span>x:xs<span class="br0">&#41;</span> <span class="sy0">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> <span class="br0">&#40;</span>x:<span class="br0">&#41;</span> <span class="br0">&#40;</span>subsets <span class="br0">&#40;</span>k <span class="sy0">-</span> <span class="nu0">1</span><span class="br0">&#41;</span> xs<span class="br0">&#41;</span> <span class="sy0">++</span> subsets k xs</pre></div></div>

<p>Now we have to augment our flipping function flipAt to be able to cope with lists of indices to flip at.</p>

<div class="wp_syntax"><div class="code"><pre class="haskell">flipAt' <span class="sy0">::</span> <span class="br0">&#91;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"><span class="kw4">Int</span></a><span class="br0">&#93;</span> <span class="sy0">-&gt;</span> Searchpoint <span class="sy0">-&gt;</span> Searchpoint
flipAt' l x <span class="sy0">=</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:foldr"><span class="kw3">foldr</span></a> <span class="br0">&#40;</span><span class="sy0">.</span><span class="br0">&#41;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:id"><span class="kw3">id</span></a> <span class="sy0">$</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> flipAt l<span class="br0">&#41;</span> x</pre></div></div>

<p>The function flipAt&#8217; gets a list of indices and a searchpoint and returns the searchpoint flipped at those indices.</p>
<p>Now we can implement our new neighbourhood function expplouting our stripped down flipAt&#8217; function:</p>

<div class="wp_syntax"><div class="code"><pre class="haskell">neigh' <span class="sy0">::</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"><span class="kw4">Int</span></a> <span class="sy0">-&gt;</span> Searchpoint <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>Searchpoint<span class="br0">&#93;</span>
neigh' k x <span class="sy0">=</span> <span class="br0">&#91;</span>flipAt'<span class="br0">&#93;</span> <span class="sy0">&lt;*&gt;</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:concat"><span class="kw3">concat</span></a> <span class="sy0">$</span> <span class="br0">&#91;</span><span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:flip"><span class="kw3">flip</span></a> subsets <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">..</span>n<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#93;</span> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">..</span>k<span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="sy0">&lt;*&gt;</span> <span class="br0">&#91;</span>x<span class="br0">&#93;</span></pre></div></div>

<p>Not only is this implementation a lot shorter, it is also more efficient since duplicate elements aren&#8217;t produced.</p>
<p>I didn&#8217;t perform any profiling to see some actual results, but the improvement is noticable although I had expected it to be more drastic.</p>
]]></content:encoded>
			<wfw:commentRss>http://sainthuck.de/2011/08/efficiently-calculating-hamming-neighbourhoods-in-haskell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>USB Microscope</title>
		<link>http://sainthuck.de/2011/07/usb-microscope/</link>
		<comments>http://sainthuck.de/2011/07/usb-microscope/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 13:01:25 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sainthuck.de/?p=378</guid>
		<description><![CDATA[This week, the discounter Lidl sold Bresser USB microscopes for only 29,99EUR, so i got myself one, knowing that the quality would be rather poor. Provided I&#8217;ll have 10h of fun with it, that makes 3EUR/h, which is a good deal. As expected, Linux supports the microscope via the UCV drivers, so it&#8217;s literally plug [...]]]></description>
			<content:encoded><![CDATA[<p>This week, the discounter Lidl sold Bresser USB microscopes for only 29,99EUR, so i got myself one, knowing that the quality would be rather poor. Provided I&#8217;ll have 10h of fun with it, that makes 3EUR/h, which is a good deal.</p>
<p>As expected, Linux supports the microscope via the UCV drivers, so it&#8217;s literally plug and play.</p>
<pre>&gt; uvcvideo: Found UVC 1.00 device USB2.0 Camera (1871:0101)</pre>
<p>While you can use any tool like <em>ucview</em> or <em>cheese</em>, I prefer using mplayer.</p>
<pre>&gt; mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video1</pre>
<p>But let&#8217;s skip the details, here are two shots of a <a title="dark winged fungus gnat" href="http://en.wikipedia.org/wiki/Sciaridae" target="_blank">dark winged fungus gnat</a>:</p>
<p style="text-align: center;">
<p style="text-align: left;">20x magnification<a href="http://sainthuck.de/wp-content/uploads/2011/07/shot0007.png"><img class="aligncenter size-full wp-image-379" title="shot0007" src="http://sainthuck.de/wp-content/uploads/2011/07/shot0007.png" alt="" width="384" height="288" /></a></p>
<p style="text-align: center;">
<p style="text-align: left;">350x magnification</p>
<p style="text-align: center;"><a href="http://sainthuck.de/wp-content/uploads/2011/07/shot0005.png"><img class="aligncenter size-full wp-image-381" title="shot0005" src="http://sainthuck.de/wp-content/uploads/2011/07/shot0005.png" alt="" width="384" height="288" /></a></p>
<p style="text-align: left;">20x magification with a 1c-coin</p>
<p style="text-align: center;"><a href="http://sainthuck.de/wp-content/uploads/2011/07/shot0008.png"><img class="aligncenter size-full wp-image-382" title="shot0008" src="http://sainthuck.de/wp-content/uploads/2011/07/shot0008.png" alt="" width="384" height="288" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://sainthuck.de/2011/07/usb-microscope/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>DVBTheremin</title>
		<link>http://sainthuck.de/2011/02/dvbtheremin/</link>
		<comments>http://sainthuck.de/2011/02/dvbtheremin/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 16:45:03 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://sainthuck.de/?p=366</guid>
		<description><![CDATA[Everyone with a DVB-T receiver knows that the tuner signal can get corrupted by the weather or in my case the bus which stops in front of the house I live in. Some DVB-T receivers display the tuner signal in an OSD of your TV. Since I&#8217;m using a DVB-T card in my PC with [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone with a DVB-T receiver knows that the tuner signal can get corrupted by the weather or in my case the bus which stops in front of the house I live in. Some DVB-T receivers display the tuner signal in an OSD of your TV. Since I&#8217;m using a DVB-T card in my PC with mplayer to watch TV I don&#8217;t see anything like that, so I found out that if you&#8217;ve tuned to some channel you can use the debugging and analyzing tool <a href="http://dvbsnoop.sourceforge.net/">dvbsnoop</a> to check the signal which looks like this in my case:</p>
<pre>[cgie@talia:~] dvbsnoop -s signal -pd 1 -n 10
dvbsnoop V1.4.50 -- http://dvbsnoop.sourceforge.net/
Sig: 10537
Sig: 10537
Sig: 10537
Sig: 10537
Sig: 10537
Sig: 10537
Sig: 10537
Sig: 10537
Sig: 10537
Sig: 10537</pre>
<p>I don&#8217;t know what these numbers actually represent. 10537 corresponds with a good signal in my case. 10537 is the product of the two primes 41 and 257&#8230; but I guess that&#8217;s irrelevant. One might think that the numbers have certain range and that the higher numbers correspond with a better signal. In fact it&#8217;s the other way around and there are discrete values which represent several states of signal quality. However, the only interesting fact is that the numbers change if the signal does.</p>
<h2>Step 1</h2>
<p>Tune your DVB card to some channel, for example:</p>
<pre>tzap -c .mplayer/channels.conf -r "Das Erste(NDR)"</pre>
<h2>Step 2</h2>
<p>The next step is to convert these numbers to an audio signal, a perfect job for <a href="http://puredata.info/">Pure Data</a> which is <em>&#8220;is a visual programming language developed by Miller Puckette in the 1990s for the creation of interactive computer music and multimedia works&#8221;</em> (<a href="http://en.wikipedia.org/wiki/Pure_Data">Wikipedia</a>). The problem is to pipe the terminal output of dvbsnoop into Pure Data. I solved this by sending the outputs via UDP to my Pure Data patch, bash makes socket programming very easy. I used this simple script:</p>
<pre>SERVER="127.0.0.1"
PORT=3333

exec 0&lt;&gt;/dev/udp/${SERVER}/${PORT} || exit # SDTIN
exec 1&gt;&amp;0                                  # STDOUT

while true; do
  dvbsnoop -s signal -pd 1 -n 1 | sed -ne 's/Sig: //p' | tail -1
done</pre>
<p>This script does more than you actually need, you can also pipe the output directly to /dev/udp/${SERVER}/${PORT}. STDIN is only used with TCP connections and the script doesn&#8217;t receive anything. Anyway, if you run this script the signal values are constantly sent to port 3333 on your localhost.</p>
<h2>Step 3</h2>
<p>This the Pure Data patch I&#8217;m using.<br />
<a href="http://sainthuck.de/wp-content/uploads/2011/02/puredatatheremin.png"><img class="aligncenter size-full wp-image-367" title="PD patch for the DVB theremin" src="http://sainthuck.de/wp-content/uploads/2011/02/puredatatheremin.png" alt="PD patch for the DVB theremin" width="383" height="564" /></a><br />
Basically the patch receives the output with the netreceive object and feeds an oscillator with it. I put some objects into the patch to adjust the volume and the pitch of the sound. The interesting thing to really make it sound like a theremin are the arithmetic operations on the upper left, some frequencies get interpolated between two outputs of dvbsnoop to create the typical sweeping sounds of a theremin, yeah I know, it&#8217;s kind of phony.</p>
<p>Here&#8217;s the result:</p>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="350" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/kA07956NSj0" /><embed type="application/x-shockwave-flash" width="425" height="350" src="http://www.youtube.com/v/kA07956NSj0"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://sainthuck.de/2011/02/dvbtheremin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SciFi Queue</title>
		<link>http://sainthuck.de/2011/01/scifi-queue/</link>
		<comments>http://sainthuck.de/2011/01/scifi-queue/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 11:59:12 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://sainthuck.de/?p=356</guid>
		<description><![CDATA[I&#8217;ve gathered a lot of sci-fi books in 2010, mostly from flea markets for around about 50c each. The publisher Heyne has its own science fiction series and makes it easy for scifi-nerds to find by printing white &#8220;SF&#8221; letters onto the black back of the book. If you happen to pile up a certain [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve gathered a lot of sci-fi books in 2010, mostly from flea markets for around about 50c each. The publisher Heyne has its own science fiction series and makes it easy for scifi-nerds to find by printing white &#8220;SF&#8221; letters onto the black back of the book. If you happen to pile up a certain amount of something you almost feel like a collector.  Recently I&#8217;ve obained almost the whole original Dune cycle by Frank Herbert on a book sale at uni for little money, Heyne SF of course.</p>
<p>The following picture shows the books I&#8217;ve read so far, I rated them as if I had to rate a movie on IMDB, this is of course highly subjective.</p>
<p><a href="http://sainthuck.de/wp-content/uploads/2011/01/review1.jpg"><img class="aligncenter size-medium wp-image-358" title="review" src="http://sainthuck.de/wp-content/uploads/2011/01/review1-320x117.jpg" alt="" width="320" height="117" /></a></p>
<p>The next picture is a more sophisticated way of rating: I rated some characteristics of the books independently. These numbers don&#8217;t correspond with the ones above at all, but they aren&#8217;t comparable anyway since my IMDB-ratings reflect my final judgement while the numbers below don&#8217;t really render my general impression.</p>
<p>Also: star diagrams look cool.</p>
<p style="text-align: center;"><a href="http://sainthuck.de/wp-content/uploads/2011/01/review.png"><img class="size-full wp-image-360 aligncenter" style="border-style: none;" title="review" src="http://sainthuck.de/wp-content/uploads/2011/01/review.png" alt="" width="600" height="400" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://sainthuck.de/2011/01/scifi-queue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My DIY Stethophone</title>
		<link>http://sainthuck.de/2011/01/my-diy-stethophone/</link>
		<comments>http://sainthuck.de/2011/01/my-diy-stethophone/#comments</comments>
		<pubDate>Sat, 15 Jan 2011 13:36:02 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sainthuck.de/?p=340</guid>
		<description><![CDATA[Actually I wanted to build a hydrophone, but making a stethophone is just too easy. Besides: I gave my niece a stethoscope for Christmas, because we happen to play doctor fairly often and she has two &#8220;fake&#8221; stehoscopes for children that actually serve no purpose but being an ugly dummy. I got myself one, too, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sainthuck.de/wp-content/uploads/2011/01/DSCI0122.jpg"><img class="size-thumbnail wp-image-341 alignleft" title="DIY Stethophone" src="http://sainthuck.de/wp-content/uploads/2011/01/DSCI0122-150x112.jpg" alt="My DIY Stethophone" width="150" height="112" /></a><br />
Actually I wanted to build a hydrophone, but making a stethophone is just too easy. Besides: I gave my niece a stethoscope for Christmas, because we happen to play doctor fairly often and she has two &#8220;fake&#8221; stehoscopes for children that actually serve no purpose but being an ugly dummy. I got myself one, too, the price is 15EUR,  not really cheap, but at least it works. First, I removed the rubber earplugs, they&#8217;re not fixed with glue or anything else, you can just unplug them, then I attached an old pair of diy microphones at the ends with hot melt adhesive. The microphones are cheap mic capsules each soldered to an old earplug wire. The capsules are actually quite good, I used electret mic capsules for 1EUR each, they record ferquencies from 20HZ to 20kHz. I then just plugged the mics to my Edirol R09HR (actually i plugged them into my altoids battery box because the power supply of my R09HR seems to be broken).</p>
<p style="text-align: center;"><a href="http://sainthuck.de/wp-content/uploads/2011/01/heart1.png"><img class="aligncenter size-full wp-image-345" style="border-style: none;" title="heart" src="http://sainthuck.de/wp-content/uploads/2011/01/heart1.png" alt="" width="600" height="400" /></a></p>
<p>My recorded samples are somewhat disappointing, I expected some kind of super effective James Bond like gadget, but the sounds you get are very very quiet, and the background noise after normalization/amplification is very dominant. Nonetheless the mic capsules prove to be extremely precise. Here&#8217;s a sample of my heartbeat when i put the bell on my cervical artery. It&#8217;s the exact up and down movement of the skin induced by the rush of blood.</p>
<p><a href="http://sainthuck.de/wp-content/uploads/2011/01/DSCI0101.jpg"><img class="size-thumbnail wp-image-343 alignright" title="Come on, purr! PURR HARDER!" src="http://sainthuck.de/wp-content/uploads/2011/01/DSCI0101-150x112.jpg" alt="Come on, purr! PURR HARDER!" width="150" height="112" /></a>I experimented with recording the purring sound of my cat, but i only got garbage. The noise of the fur swishing against the bell&#8217;s membrane was very dominant and my cat wasn&#8217;t really cooperating.</p>
]]></content:encoded>
			<wfw:commentRss>http://sainthuck.de/2011/01/my-diy-stethophone/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bash Autocompletion for DVB channels</title>
		<link>http://sainthuck.de/2011/01/bash-autocompletion-for-dvb-channels/</link>
		<comments>http://sainthuck.de/2011/01/bash-autocompletion-for-dvb-channels/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 17:09:21 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://sainthuck.de/?p=336</guid>
		<description><![CDATA[I finally added autocompletion for my TV channels for mplayer which is far superior to my previous method of looking up the exact channel&#8217;s name in my channels.conf and typing mplayer dvb://&#8221;channel&#8217;s name&#8221; in a terminal. I just added this very simple script to /etc/bash-completion.d/ _channel&#40;&#41; &#123; local cur COMPREPLY=&#40;&#41; cur=&#34;${COMP_WORDS[COMP_CWORD]}&#34; local chans=$&#40;cat .mplayer/channels.conf &#124;sed [...]]]></description>
			<content:encoded><![CDATA[<p>I finally added autocompletion for my TV channels for mplayer which is far superior to my previous method of looking up the exact channel&#8217;s name in my channels.conf and typing mplayer dvb://&#8221;channel&#8217;s name&#8221; in a terminal.</p>
<p>I just added this very simple script to /etc/bash-completion.d/</p>

<div class="wp_syntax"><div class="code"><pre class="bash">_channel<span class="br0">&#40;</span><span class="br0">&#41;</span>
<span class="br0">&#123;</span>
<span class="kw3">local</span> cur
<span class="re2">COMPREPLY</span>=<span class="br0">&#40;</span><span class="br0">&#41;</span>
<span class="re2">cur</span>=<span class="st0">&quot;<span class="es3">${COMP_WORDS[COMP_CWORD]}</span>&quot;</span>
<span class="kw3">local</span> <span class="re2">chans</span>=$<span class="br0">&#40;</span><span class="kw2">cat</span> .mplayer<span class="sy0">/</span>channels.conf <span class="sy0">|</span><span class="kw2">sed</span> <span class="re5">-ne</span> <span class="st_h">'s/^\([^:]*\).*/&quot;\1&quot;/p'</span><span class="br0">&#41;</span>
<span class="re2">oifs</span>=<span class="st0">&quot;<span class="es2">$IFS</span>&quot;</span>
<span class="re2">IFS</span>=$<span class="st_h">'\n'</span> <span class="re2">COMPREPLY</span>=<span class="br0">&#40;</span>$<span class="br0">&#40;</span><span class="kw3">compgen</span> <span class="re5">-W</span> <span class="st0">&quot;<span class="es3">${chans}</span>&quot;</span> <span class="re1">$cur</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
<span class="re2">IFS</span>=<span class="st0">&quot;<span class="es2">$oifs</span>&quot;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="kw3">complete</span> <span class="re5">-F</span> _channel channel</pre></div></div>

<p>Then I added the following to my .bashrc:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="kw1">function</span> channel <span class="br0">&#123;</span>
    <span class="kw2">mplayer</span> dvb:<span class="sy0">//</span><span class="st0">&quot;$1&quot;</span>
<span class="br0">&#125;</span></pre></div></div>

<p>So it&#8217;s channel &#8220;&lt;TAB&gt;  for me now.</p>
<p>Done.</p>
]]></content:encoded>
			<wfw:commentRss>http://sainthuck.de/2011/01/bash-autocompletion-for-dvb-channels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My favorite onomatopoeia &#8211; Mau!</title>
		<link>http://sainthuck.de/2010/11/my-favorite-onomatopoeia-mau/</link>
		<comments>http://sainthuck.de/2010/11/my-favorite-onomatopoeia-mau/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 19:52:39 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://sainthuck.de/?p=323</guid>
		<description><![CDATA[Every time i listen to this it gets scarier&#8230; Mau!]]></description>
			<content:encoded><![CDATA[<p>Every time i listen to this it gets scarier&#8230;</p>
<p><a href="http://sainthuck.de/wp-content/uploads/2010/11/emmamau.mp3" class="wpaudio">Mau!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://sainthuck.de/2010/11/my-favorite-onomatopoeia-mau/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://sainthuck.de/wp-content/uploads/2010/11/emmamau.mp3" length="99473" type="audio/mpeg" />
		</item>
		<item>
		<title>Quantifying God</title>
		<link>http://sainthuck.de/2010/10/quantifying-god/</link>
		<comments>http://sainthuck.de/2010/10/quantifying-god/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 19:08:55 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://sainthuck.de/?p=310</guid>
		<description><![CDATA[Okay, this is pure nonsense, but anyway, I&#8217;d like to share some thoughts in order to quantify and in some way &#8220;locate&#8221; god. The whole idea is to work with distances, everyone can measure his or her felt distance to some objects, things or even thoughts. While it&#8217;s hard to actually give numbers to those [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, this is pure nonsense, but anyway, I&#8217;d like to share some thoughts in order to quantify and in some way &#8220;locate&#8221; god.</p>
<p>The whole idea is to work with distances, everyone can measure his or her felt distance to some objects, things or even thoughts. While it&#8217;s hard to actually give numbers to those felt distances we can always compare them to each other. My distance to the wall is around about one metre right now. My distance to Barack Obama is rather big (physically) and although the physical distance to, let&#8217;s say, Geert Wilders is rather small, my felt distance to him is larger than that to Barack Obama. The distance to the thought of becoming president of the United States is large, and there&#8217;s some kind of imaginary part to that particular thought because I&#8217;d have to be born there. So it makes sense to see all these objects combined by a real and an imaginary part&#8230; which motivates considering all of these things in a way complex numbers are considered, so let&#8217;s assign every object an imaginary and a real part: <img src='http://sainthuck.de/wp-content/latex/18d/18d69f05fabc782b7a7a467508907aa4-T-dcdccc-0.png' style='border-style: none;' alt='x = Re(x)+ i Im(x)' title='x = Re(x)+ i Im(x)' class='latex' />. Since I feel pretty real <img src='http://sainthuck.de/wp-content/latex/dc8/dc8aa8faf07f69b63f1a7e9273a02b49-T-dcdccc-0.png' style='border-style: none;' alt='Im(\text{myself})=0' title='Im(\text{myself})=0' class='latex' /> and <img src='http://sainthuck.de/wp-content/latex/081/081f14e1941788ce0d64426515924f97-T-dcdccc-0.png' style='border-style: none;' alt='Re(\text{myself})=\text{myself}' title='Re(\text{myself})=\text{myself}' class='latex' /> for example.<br />
Let&#8217;s try to phrase it mathematically: let <img src='http://sainthuck.de/wp-content/latex/d4f/d4f0fd823bbfd86af1596e745abd7790-T-dcdccc-0.png' style='border-style: none;' alt='d(x,y)' title='d(x,y)' class='latex' /> be the &#8220;felt distance&#8221; of two objects <img src='http://sainthuck.de/wp-content/latex/f10/f10bc3c94b77e1d6b9f98106daf335c1-T-dcdccc-0.png' style='border-style: none;' alt='x,y' title='x,y' class='latex' />. We certainly have <img src='http://sainthuck.de/wp-content/latex/4c6/4c6db4a55aa298a1bdc2fbbf48c8147d-T-dcdccc-0.png' style='border-style: none;' alt='d(x,x)=0' title='d(x,x)=0' class='latex' />, the triangle inequality holds trivially and for the sake of simplicity let&#8217;s assume symmetry. Of course the felt distance of two people does <em>not</em> need to be the same, but quasimetrics can simply be transformed into metrics and <img src='http://sainthuck.de/wp-content/latex/05c/05c05b66a4520bd78fde9d2d6f7c78ac-T-dcdccc-0.png' style='border-style: none;' alt='d(d(x,y),d(y,x))' title='d(d(x,y),d(y,x))' class='latex' /> is rarely <em>very</em> large, so the felt distance is a metric.</p>
<p>Let <img src='http://sainthuck.de/wp-content/latex/b2f/b2f5ff47436671b6e533d8dc3614845d-T-dcdccc-0.png' style='border-style: none;' alt='g' title='g' class='latex' /> denote God and <img src='http://sainthuck.de/wp-content/latex/4a8/4a8a08f09d37b73795649038408b5f33-T-dcdccc-0.png' style='border-style: none;' alt='c' title='c' class='latex' /> myself. What&#8217;s <img src='http://sainthuck.de/wp-content/latex/3f8/3f835f59c526b90c6f1bdb6c00c30673-T-dcdccc-0.png' style='border-style: none;' alt='d(c,g)' title='d(c,g)' class='latex' /> then? In the Lord&#8217;s Prayer we find the first line to be &#8220;Our Father who art in heaven&#8221; which implies two bounds: <img src='http://sainthuck.de/wp-content/latex/c2f/c2fd52ec807cb41398be227db63941ac-T-dcdccc-0.png' style='border-style: none;' alt='d(c,g) &lt; r_\text{heaven}' title='d(c,g) &lt; r_\text{heaven}' class='latex' /> and <img src='http://sainthuck.de/wp-content/latex/5b4/5b4a600f3790494cc1116d3360b62359-T-dcdccc-0.png' style='border-style: none;' alt='d(c,g) &gt; r_\text{family}' title='d(c,g) &gt; r_\text{family}' class='latex' />, where <img src='http://sainthuck.de/wp-content/latex/a2e/a2e83694ce396e47329cf03fed8b2f4f-T-dcdccc-0.png' style='border-style: none;' alt='r_\text{heaven}' title='r_\text{heaven}' class='latex' /> is my distance to heaven and <img src='http://sainthuck.de/wp-content/latex/99f/99fb189e5002221399df65795fc4d475-T-dcdccc-0.png' style='border-style: none;' alt='r_\text{family}' title='r_\text{family}' class='latex' /> is the distance i have to anything or anyone family-related. The <img src='http://sainthuck.de/wp-content/latex/a2e/a2e83694ce396e47329cf03fed8b2f4f-T-dcdccc-0.png' style='border-style: none;' alt='r_\text{heaven}' title='r_\text{heaven}' class='latex' />-sphere around me as its center intersects with the reals in exactly two points which would symbolize the real part of heaven which would probably be paradise and paradise is, hands down, very distant, so for all people <img src='http://sainthuck.de/wp-content/latex/838/83878c91171338902e0fe0fb97a8c47a-T-dcdccc-0.png' style='border-style: none;' alt='p' title='p' class='latex' />, family or not, no matter if they&#8217;re alive or not <img src='http://sainthuck.de/wp-content/latex/0f8/0f81c9705d37976067e798c449d04c8f-T-dcdccc-0.png' style='border-style: none;' alt='r_\text{family} \leq d(c,p) &lt; r_\text{heaven}' title='r_\text{family} \leq d(c,p) &lt; r_\text{heaven}' class='latex' /></p>
<p>Let <img src='http://sainthuck.de/wp-content/latex/363/363b122c528f54df4a0446b6bab05515-T-dcdccc-0.png' style='border-style: none;' alt='j' title='j' class='latex' /> denote Jesus. Since only few historians doubt Jesus&#8217; existence as a person, let&#8217;s assume <img src='http://sainthuck.de/wp-content/latex/aad/aad93fbb49fa077192d115461abad23c-T-dcdccc-0.png' style='border-style: none;' alt='Im(j) = 0' title='Im(j) = 0' class='latex' />. Due to trinity there exists some argument <img src='http://sainthuck.de/wp-content/latex/731/731c1d971c9acfc805bc88d1f9da6e8c-T-dcdccc-0.png' style='border-style: none;' alt='\varphi &gt; 0' title='\varphi &gt; 0' class='latex' /> such that <img src='http://sainthuck.de/wp-content/latex/364/364893f1c0e82d717342ce44b0f25d87-T-dcdccc-0.png' style='border-style: none;' alt='g = j\cdot e^{i\varphi}' title='g = j\cdot e^{i\varphi}' class='latex' />. This equality would symbolize Jesus&#8217; resurrection then. From a physical perspective my distance to Jesus is huge, but due to my argumentation above: <img src='http://sainthuck.de/wp-content/latex/6d8/6d8a683203cbd3c11784c6ecc425e04a-T-dcdccc-0.png' style='border-style: none;' alt='r_\text{family} &lt; d(c,j) &lt; r_\text{heaven}' title='r_\text{family} &lt; d(c,j) &lt; r_\text{heaven}' class='latex' />.<br />
All these considerations boil down to this image:</p>
<p><a href="http://sainthuck.de/wp-content/uploads/2010/10/god.png"><img class="aligncenter size-full wp-image-313" title="god" src="http://sainthuck.de/wp-content/uploads/2010/10/god.png" alt="" width="512" height="514" /></a></p>
<p>There are some nice conclusions which I won&#8217;t interpret any further:</p>
<ol>
<li>If God doesn&#8217;t exist, then <img src='http://sainthuck.de/wp-content/latex/70f/70f113d26d5271edab6d79c7c679bca1-T-dcdccc-0.png' style='border-style: none;' alt='Re(g) = c' title='Re(g) = c' class='latex' />.</li>
<li><img src='http://sainthuck.de/wp-content/latex/327/327f814644f84946d1db743effb97aee-T-dcdccc-0.png' style='border-style: none;' alt='d(c,g) \leq d(c,j) + d(j,g)' title='d(c,g) \leq d(c,j) + d(j,g)' class='latex' />, so according to the church the only way to god, which is Jesus, is longer than the direct path.</li>
<li>No matter if God exists: <img src='http://sainthuck.de/wp-content/latex/4ee/4eeb9b6a5a56e453e2f7e5023c572d32-T-dcdccc-0.png' style='border-style: none;' alt='Re(g) = Re(\bar{g})' title='Re(g) = Re(\bar{g})' class='latex' /> which is scary, think about it.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://sainthuck.de/2010/10/quantifying-god/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>De Morgan&#8217;s laws in procmail recipes</title>
		<link>http://sainthuck.de/2010/09/de-morgans-laws-in-procmail-recipes/</link>
		<comments>http://sainthuck.de/2010/09/de-morgans-laws-in-procmail-recipes/#comments</comments>
		<pubDate>Sun, 26 Sep 2010 17:57:51 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[procmail]]></category>
		<category><![CDATA[tips & tricks]]></category>

		<guid isPermaLink="false">http://sainthuck.de/?p=307</guid>
		<description><![CDATA[I have an account at dimeadozen, a torrent tracker &#8220;for audio and video recordings of independent origin (ROIO) which have not been officially released&#8220;. If you know me you&#8217;re aware of my hobby of recording concerts. Dime is by far the best resource to share those recordings although I appreciate archive.org&#8216;s approach, too. I don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I have an account at <a href="http://dimeadozen.org">dimeadozen</a>, a torrent tracker &#8220;for audio and video recordings of independent origin (ROIO) <strong> which have not been officially released</strong>&#8220;. If you know me you&#8217;re aware of my hobby of recording concerts. Dime is by far the best resource to share those recordings although I appreciate <a href="http://archive.org">archive.org</a>&#8216;s approach, too.</p>
<p>I don&#8217;t want to check the site every day to see if there&#8217;s something I&#8217;m interested in, so I&#8217;m subscribed to their bot mailing list that sends out an email for every new, removed, deleted and banned torrent on the tracker. I like that approach, in times of RSS/ATOM feeds or twitter this seems a bit old-fashioned, but emails are around for some decades now, i guess that makes them a pretty robust data to handle.</p>
<p>Anyway: There are around 100-200 torrent actions a day, each of them is announced by an email. The subject line look like this:</p>
<pre>Subject: [bot-dimeadozen-org] NEW on DIME: Grinderman HMVRelentless Garage 23 Sept 2010
Subject: [bot-dimeadozen-org] Removed from DIME: PJ Harvey &amp; John Parish - The Ritz, Manchester, England - 24th April 2009
Subject: [bot-dimeadozen-org] BANNED from DIME: PJ Harvey 1995 Peel &amp; BBC (Foxtrotter)</pre>
<p>My filter rule would look like this in pseudocode:</p>
<pre>if the list-id is bot-dimeadozen-org then
  if the subject contains "banned" OR contains "removed" etc then
    delete the email
  else if the subject contains artist name 1 OR contains artist name 2 etc then
    save the email in a specific mailbox
  else
    delete the email</pre>
<p>Checking the list ID is a one-liner, but all the other conditions are rather lengthy and though easily done would result in awkwardly long regular expressions. As you can see the second condition checks if some keywords occur in the subject line. Each would be represented like this in procmail:</p>
<pre>* ^Subject:.*BANNED.from.DIME.*
* ^Subject:.*Removed.from.DIME.*
* ^Subject:.*DIME.BAN.LIFTED.*
* ^Subject:.*Deleted from DIME.*</pre>
<p>Subsequent condition lines are logically combined via conjunction (AND that is) so this is not what I need, but using de Morgan&#8217;s laws I can simply negate each condition and switch the &#8220;then&#8221; and &#8220;else&#8221; parts, so the modified filter rule looks like this:</p>
<pre>if the list-id is bot-dimeadozen-org then
  if the subject does NOT contain "banned" AND does not contain "removed" etc then
    if the subject does NOT contain artist name 1 AND does NOT contain artist name 2 etc then
      delete the email
    else
      save to a specific mailbox
  else
    delete the email</pre>
<p>This is great because this directly transforms into the following procmail recipe:</p>
<pre>:0
* ^List-Id:.*bot-dimeadozen-org\.yahoogroups\.com
{
  :0
  * ! ^Subject:.*BANNED.from.DIME.*
  * ! ^Subject:.*Removed.from.DIME.*
  * ! ^Subject:.*DIME.BAN.LIFTED.*
  * ! ^Subject:.*Deleted from DIME.*
  {
    :0
    * ! ^Subject:.*(pj|polly.jean|dalek|d.lek).*
    * ! ^Subject:.*(hugo.race|dirt.music|dirtmusic|hr.tts|sepiatone|merola.matrix).*
    * ! ^Subject:.*(nick.cave|nicholas.*cave|grinderman|bad.seeds|birthday.party|boys.next.door).*
    * ! ^Subject:.*(f.nt.mas|patton|lovage|tomahawk|bungle|peeping.tom|mondo.cane).*
    * ! ^Subject:.*(mastodon|melt.banana|mono|neurosis|isis|jesu|earth|pelican|red.sparowes).*
    * ! ^Subject:.*(sigur|gun.club|lizaveta|rowland|sunn|goldfrapp|neubauten|cult.of.luna|bohren|blixa).*
    * ! ^Subject:.*(meshuggah).*
    $MAILDIR/.dimebot-all/
    :0 E
    $MAILDIR/.dimebot-wanted/
  }
  :0 E
  $MAILDIR/.dimebot-all/
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://sainthuck.de/2010/09/de-morgans-laws-in-procmail-recipes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keeping /etc under control</title>
		<link>http://sainthuck.de/2010/09/keeping-etc-under-contro/</link>
		<comments>http://sainthuck.de/2010/09/keeping-etc-under-contro/#comments</comments>
		<pubDate>Sat, 25 Sep 2010 21:47:33 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sainthuck.de/?p=296</guid>
		<description><![CDATA[I like tweaking my config files in a lot so keeping /etc under revision control makes sense. My weapon of choice is git without any special reason. I&#8217;m actually used to svn but I don&#8217;t see the point in a central repository which leaves git and mercurial and this site nails it. So what&#8217;s actually [...]]]></description>
			<content:encoded><![CDATA[<p>I like tweaking my config files in a lot so keeping /etc under revision control makes sense. My weapon of choice is git without any special reason. I&#8217;m actually used to svn but I don&#8217;t see the point in a central repository which leaves git and mercurial and <a href="http://gitvsmercurial.com/">this site</a> nails it.</p>
<p>So what&#8217;s actually the problem? Basically I want every change automatically revisioned. This won&#8217;t work very well with manual changes, but I can live with that, but I want to autoamtically commit changes every time I install or upgrade a package. There are tools like etckeeper that do the trick, but I don&#8217;t want an extra daemon for that purpose, besides: pacman doesn&#8217;t have post installation hooks implemented like apt does, I&#8217;d have to switch to pacman-g2, but I don&#8217;t want that either.</p>
<p>This is how I do it: I mostly use yaourt which is basically a wrapper for pacman package manager and instead of hacking a wrapper for yaourt I just use a wrapper script for pacman which executes pacman and commits any changes in /etc. Then point yaourt to it.</p>
<p>First create your git repo, as root perform:</p>
<pre>$ cd /etc
$ git init
$ git commit -m "Initial commit"</pre>
</p>
<p>Now that your repo is ready, paste this into /usr/local/sbin/etcpacman</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="co0">#!/bin/sh</span>
<span class="co0"># ---------------------------------------------------------------------</span>
<span class="co0"># file:     /usr/local/sbin/etcpacman</span>
<span class="co0"># author:   Christian Gießen  http://sainthuck.de</span>
<span class="co0"># modified: September 2010</span>
<span class="co0"># ---------------------------------------------------------------------</span>
&nbsp;
<span class="co0"># The script uses fancy colors</span>
. <span class="sy0">/</span>etc<span class="sy0">/</span>bash.colors
<span class="co0"># First execute pacman-color with any originally passed parameters</span>
<span class="sy0">/</span>usr<span class="sy0">/</span>bin<span class="sy0">/</span>pacman-color <span class="st0">&quot;<span class="es3">${@}</span>&quot;</span>
<span class="co0"># Then git-commit any changes to the git repo and add an informative</span>
<span class="co0"># commit message.</span>
<span class="kw3">echo</span> <span class="st0">&quot;[<span class="es3">${yellow}</span><span class="es3">${0}</span><span class="es3">${NC}</span>] <span class="es3">${yellow}</span>Updating git repository /etc<span class="es3">${NC}</span>&quot;</span>
<span class="kw3">cd</span> <span class="sy0">/</span>etc
<span class="kw2">git</span> add .
<span class="kw3">echo</span> <span class="st0">&quot;[<span class="es3">${yellow}</span><span class="es3">${0}</span><span class="es3">${NC}</span>] <span class="es3">${red}</span>git commit -a -m<span class="es1">\&quot;</span>Snapshot after: pacman-color <span class="es3">${*}</span><span class="es1">\&quot;</span><span class="es3">${NC}</span>&quot;</span>
<span class="kw2">git</span> commit <span class="re5">-a</span> <span class="re5">-m</span><span class="st0">&quot;Snapshot after: pacman-color <span class="es3">${*}</span>&quot;</span>
<span class="kw3">echo</span> <span class="st0">&quot;[<span class="es3">${yellow}</span><span class="es3">${0}</span><span class="es3">${NC}</span>] <span class="es3">${yellow}</span>Done.<span class="es3">${NC}</span>&quot;</span></pre></div></div>

</p>
<p>Then make sure that PACMANBIN=&#8221;/usr/local/sbin/etcpacman&#8221; in your /etc/yaourtrc and you&#8217;re done.</p>
<p>
And before anyone asks, this is the color file I&#8217;m sourcing in my script, very handy for sexy scripts:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span class="re2">red</span>=$<span class="st_h">'\e[0;31m'</span>
<span class="re2">RED</span>=$<span class="st_h">'\e[1;31m'</span>
<span class="re2">blue</span>=$<span class="st_h">'\e[0;34m'</span>
<span class="re2">BLUE</span>=$<span class="st_h">'\e[1;34m'</span>
<span class="re2">cyan</span>=$<span class="st_h">'\e[0;36m'</span>
<span class="re2">CYAN</span>=$<span class="st_h">'\e[1;36m'</span>
<span class="re2">NC</span>=$<span class="st_h">'\033[0m'</span> <span class="co0"># no color</span>
<span class="re2">black</span>=$<span class="st_h">'\e[0;30m'</span>
<span class="re2">BLACK</span>=$<span class="st_h">'\e[1;30m'</span>
<span class="re2">green</span>=$<span class="st_h">'\e[0;32m'</span>
<span class="re2">GREEN</span>=$<span class="st_h">'\e[1;32m'</span>
<span class="re2">yellow</span>=$<span class="st_h">'\e[0;33m'</span>
<span class="re2">YELLOW</span>=$<span class="st_h">'\e[1;33m'</span>
<span class="re2">magenta</span>=$<span class="st_h">'\e[0;35m'</span>
<span class="re2">MAGENTA</span>=$<span class="st_h">'\e[1;35m'</span>
<span class="re2">white</span>=$<span class="st_h">'\e[0;37m'</span>
<span class="re2">WHITE</span>=$<span class="st_h">'\e[1;37m'</span></pre></div></div>
</p>
]]></content:encoded>
			<wfw:commentRss>http://sainthuck.de/2010/09/keeping-etc-under-contro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

