<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Unmaintainable</title>
	<atom:link href="http://unmaintainable.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://unmaintainable.wordpress.com</link>
	<description>Scripting, Software Engineering and Stuff in Between</description>
	<lastBuildDate>Mon, 02 Nov 2009 19:13:34 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='unmaintainable.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/6f90ae5619dfc90140df401ac60575d2?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Unmaintainable</title>
		<link>http://unmaintainable.wordpress.com</link>
	</image>
			<item>
		<title>A Template for Python Unix Utilities</title>
		<link>http://unmaintainable.wordpress.com/2009/10/24/template-python-unix-utilities/</link>
		<comments>http://unmaintainable.wordpress.com/2009/10/24/template-python-unix-utilities/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 19:11:18 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=337</guid>
		<description><![CDATA[One of the most often read postings on this blog is the one about my getopts-enabled shell script template. So I figured, a similar template in Python would also be useful. Like the shell script, it&#8217;s quite trivial, but it might still save some time.

The template is an example for a typical unix utility. It [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=337&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>One of the most often read postings on this blog is the one about my getopts-enabled shell script template. So I figured, a similar template in Python would also be useful. Like the shell script, it&#8217;s quite trivial, but it might still save some time.</p>
<p><span id="more-337"></span></p>
<p>The template is an example for a typical unix utility. It connects two aspects: An <a href="http://docs.python.org/library/optparse.html">optparse</a>-based command line parser and iterating over multiple input sources using the <a href="http://docs.python.org/library/fileinput.html">fileinput module</a>.</p>
<p>I&#8217;ve used command line parsers in several programming languages, but from all of them, I liked Python&#8217;s <code>optparse</code> module best (for those who need it, the Python&#8217;s standard library still provides a classic <a href="http://docs.python.org/library/getopt.html">getopt</a>). The <code>fileinput</code> module is simple but useful. Beyond its main functionality, it supports more advanced features like transparent decompressing (not really Unix-like though) and in-place filtering of files, but I rarely ever use them.</p>
<p>Here&#8217;s <a href="http://dev.mafr.de/repos/hg/scripts/file/tip/bin/templates/unix-tool.py">the template</a> in my online Mercurial repository and here it is <a href="http://dev.mafr.de/repos/hg/scripts/raw-file/tip/bin/templates/unix-tool.py">for download</a>.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/337/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/337/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/337/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=337&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2009/10/24/template-python-unix-utilities/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>Quick Tip #3: Creating Histograms in Python</title>
		<link>http://unmaintainable.wordpress.com/2009/09/10/creating-histograms-in-python/</link>
		<comments>http://unmaintainable.wordpress.com/2009/09/10/creating-histograms-in-python/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 14:09:37 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[quick tips]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=326</guid>
		<description><![CDATA[Since Python 2.5, creating histograms has become easier. Instead of dict, we can now use defaultdict which is similar in behavior to awk&#8217;s associative arrays. Instead of raising a KeyError for undefined keys, defaultdict adds a user-defined item and returns it.

I&#8217;ll demonstrate this with a simple program that analyzes line length distribution in a file. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=326&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Since Python 2.5, creating histograms has become easier. Instead of <code>dict</code>, we can now use <code>defaultdict</code> which is similar in behavior to awk&#8217;s associative arrays. Instead of raising a <code>KeyError</code> for undefined keys, <code>defaultdict</code> adds a user-defined item and returns it.</p>
<p><span id="more-326"></span></p>
<p>I&#8217;ll demonstrate this with a simple program that analyzes line length distribution in a file. In older Python versions, you&#8217;d typically write code like this:</p>
<pre>
hist = { }
for line in open(filename):
    hist[len(line)] = hist.get(len(line), 0) + 1
</pre>
<p>The code using <code>defaultdict</code> is much clearer and more elegant (although an additional import is needed):</p>
<pre>
from collections import defaultdict

hist = defaultdict(int)
for line in open(filename):
    hist[len(line)] += 1
</pre>
<p>Note that <code>defaultdict</code>&#8217;s constructor expects a factory function that initializes unset items on request.</p>
<p>Unless you dump the contents of <code>hist</code> to gnuplot or similar, you might want to sort the <code>dict</code> by value. There are several ways to do this, but I learned from a <a href="http://blog.client9.com/2008/09/sorting-python-dictionary-by-value-take.html">related blog posting</a> that this is the most efficient way:</p>
<pre>
from operator import itemgetter
sorted(hist.iteritems(), key=itemgetter(1))
</pre>
<p>The <code>min</code> and <code>max</code> builtins support the <code>key</code> parameter, too, by the way.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/326/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=326&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2009/09/10/creating-histograms-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>An IMAP Configuration for Mutt</title>
		<link>http://unmaintainable.wordpress.com/2009/09/08/imap-configuration-for-mutt/</link>
		<comments>http://unmaintainable.wordpress.com/2009/09/08/imap-configuration-for-mutt/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 09:41:50 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=316</guid>
		<description><![CDATA[Usually, I download all my email via fetchmail, sort it into folders using procmail and read the mails with mutt. This works reasonably well and I&#8217;ve been using this mail setup without major changes for about 10 years. Since I recently bought a netbook, I also wanted to read mails with it, but without touching [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=316&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Usually, I download all my email via fetchmail, sort it into folders using procmail and read the mails with mutt. This works reasonably well and I&#8217;ve been using this mail setup without major changes for about 10 years. Since I recently bought a netbook, I also wanted to read mails with it, but without touching my existing mail setup. The netbook should only read mails directly on the server without downloading anything to local disk.</p>
<p><span id="more-316"></span></p>
<p>My mail service provider 1&amp;1 supports IMAP and a webmail client that I sometimes use, so I decided to follow the webmail client&#8217;s conventions regarding folder names. This way, I can use mutt on the netbook and the webmail client interchangeably.</p>
<p>Based on a <a href="http://shreevatsa.wordpress.com/2007/07/31/using-gmail-with-mutt-the-minimal-way/">mutt configuration for gmail</a>, I ended up with the following IMAP-related settings:</p>
<pre>
set from = &quot;your.address&#64;example.invalid&quot;
set realname = &quot;Your Real Name&quot;

set imap_user = &quot;matthias&#64;mafr.de&quot;
set imap_pass = &quot;*******&quot;

set smtp_url = &quot;smtp://$imap_user@smtp.1und1.de:587/&quot;
set smtp_pass = $imap_pass

set folder = &quot;{imap.1und1.de/ssl}&quot;
set spoolfile = &quot;+INBOX&quot;
set record = &quot;+Gesendete Objekte&quot;
set postponed = &quot;+Entwürfe&quot;
set trash = &quot;+Papierkorb&quot;

set move = no

mailboxes &quot;+INBOX&quot;

set header_cache = &quot;~/.cache/mutt/headers&quot;
</pre>
<p>The most important account settings are <cite>imap_user</cite>, <cite>imap_pass</cite> (optional, mutt will prompt for it), and <cite>folder</cite>. Folder names prefixed with a <cite>+</cite> sign are relative to <cite>folder</cite>. Note that I disabled moving read mails to the <cite>mbox</cite> folder; I want to keep everything in my inbox. Because of the <cite>record</cite> setting, all sent mails are recorded in a folder on the IMAP server.</p>
<p>To speed things up, I enabled the header cache. You could also cache entire messages, but since mutt doesn&#8217;t expire them yet, I don&#8217;t use this feature.</p>
<p>What doesn&#8217;t work: Neither fetchmail nor the 1&amp;1 server propagate the IMAP &quot;seen&quot; flag of the emails to a BSD mbox-style &quot;Status: RO&quot; header. Because of this, I have to mark all downloaded mails as read manually.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/316/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/316/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/316/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/316/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/316/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=316&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2009/09/08/imap-configuration-for-mutt/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>Ubuntu: Changes in Python 2.6</title>
		<link>http://unmaintainable.wordpress.com/2009/08/26/ubuntu-changes-python-2-6/</link>
		<comments>http://unmaintainable.wordpress.com/2009/08/26/ubuntu-changes-python-2-6/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 08:05:59 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=306</guid>
		<description><![CDATA[Once in a while, I install Python packages from source using distutils. The distutils-powered setup.py script found in many packages installs software in /usr/local/ &#8211; quite useful because it doesn&#8217;t interfere with packages managed by your distribution. Since Ubuntu Jaunty and Python 2.6, this doesn&#8217;t work anymore.

Previously, your usual command python setup.py install installed packages [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=306&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Once in a while, I install Python packages from source using distutils. The distutils-powered <code>setup.py</code> script found in many packages installs software in <code>/usr/local/</code> &#8211; quite useful because it doesn&#8217;t interfere with packages managed by your distribution. Since Ubuntu Jaunty and Python 2.6, this doesn&#8217;t work anymore.</p>
<p><span id="more-306"></span></p>
<p>Previously, your usual command <code>python setup.py install</code> installed packages in <code>/usr/local/lib/pythonX.Y/site-packages/</code>, depending on your Python version. As of Ubuntu Jaunty, Python 2.6 no longer has this directory in <code>sys.path</code>. Instead, it expects local packages in <code>/usr/local/lib/python2.6/dist-packages/</code>, so your locally installed packages are no longer found.</p>
<p>I learned from <a href="https://lists.ubuntu.com/archives/ubuntu-devel/2009-February/027439.html">this posting</a> that distutils now supports an <code>--install-layout=deb</code> switch that installs the package in <code>/usr/local/lib/python2.6/dist-packages</code>. The switch is accepted in distutils from Python 2.4 and 2.5, too, without having any effect, so you can always include it in your command line.</p>
<p>To sum things up, the new command line for installing python packages in <code>/usr/local/</code> is</p>
<pre>
  python setup.py install --install-layout=deb
</pre>
<p>This probably applies to Debian systems as well, judging from the name choice of <code>--install-layout</code>&#8217;s parameter. I updated my <a href="/2007/01/14/package-management-using-stow/">posting on stow</a> to reflect this change.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/306/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=306&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2009/08/26/ubuntu-changes-python-2-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>Quick Tip #2: Set Operations Using Shell Tools</title>
		<link>http://unmaintainable.wordpress.com/2009/08/19/set-operations-using-shell-tools/</link>
		<comments>http://unmaintainable.wordpress.com/2009/08/19/set-operations-using-shell-tools/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 08:33:23 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=300</guid>
		<description><![CDATA[Everybody knows that Unix shell utilities are powerful. Even though they&#8217;re text-based, you can build a lot of useful things outside of the text domain. Today I&#8217;ll show you how to implement set operations. All we need are sorted files as input, with each file representing a set.

Let&#8217;s create some input files A and B:

$ [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=300&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Everybody knows that Unix shell utilities are powerful. Even though they&#8217;re text-based, you can build a lot of useful things outside of the text domain. Today I&#8217;ll show you how to implement set operations. All we need are sorted files as input, with each file representing a set.</p>
<p><span id="more-300"></span></p>
<p>Let&#8217;s create some input files <cite>A</cite> and <cite>B</cite>:</p>
<pre>
$ echo a b d e | tr ' ' '\n' &gt; A
$ echo a c e f | tr ' ' '\n' &gt; B
</pre>
<p><strong>Note</strong>: It&#8217;s an important precondition is that all input files are sorted! To avoid ugly surprises, the files mustn&#8217;t contain duplicates, but you would expect that from a set.</p>
<p>Since the input files are sorted, <strong>equality</strong> is trivial:</p>
<pre>
$ cmp A B
</pre>
<p>For use in scripts, the <em>silent switch</em> <cite>-s</cite> is useful.</p>
<p><strong>Intersection</strong>:</p>
<pre>
$ comm -12 A B
</pre>
<p>The <cite>comm</cite> utility outputs three columns per default: The lines unique to the first file, the lines unique to the second file and the lines appearing in both files. We turn off the first two columns leaving just the intersection.</p>
<p><strong>Union</strong>:</p>
<pre>
$ sort -m A B | uniq
</pre>
<p>The <em>merge switch</em> <cite>-m</cite> isn&#8217;t necessary for correctness, but it improves runtime for large files quite a bit. Unfortunately, not all sort implementations have it.</p>
<p><strong>Difference</strong>:</p>
<pre>
$ comm -23 A B
</pre>
<p>This only displays the lines unique to A, leaving the result of A minus B.</p>
<p>You can use the difference to get the <strong>complement</strong>. This requires a universe U first that we create using our union construct. The we subtract A from U:</p>
<pre>
$ sort -m A B | uniq | comm -23 - A
</pre>
<p>With only two files, this is just an inefficient way of subtracting A from B.</p>
<p><strong>Contains</strong> can be implemented using <cite>grep</cite>, but we have to be careful about false positives:</p>
<pre>
$ grep -Fx e A
</pre>
<p>The <em>quiet switch</em> <cite>-q</cite> is useful in scripts and may also reduce runtime because it exits as soon as the entry is found. This is still far less efficient than it could be if we had fixed size records and used interval halving.</p>
<p>More advanced operations like testing if one set is a subset of another are possible, too. Often you will also have to compare line counts using <cite>wc -l</cite>, but I&#8217;ll leave that as an exercise to the reader :)</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/300/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/300/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/300/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=300&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2009/08/19/set-operations-using-shell-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Code: Migrating to Mercurial</title>
		<link>http://unmaintainable.wordpress.com/2009/07/31/migrating-to-mercurial/</link>
		<comments>http://unmaintainable.wordpress.com/2009/07/31/migrating-to-mercurial/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 08:03:49 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[tools]]></category>
		<category><![CDATA[rcs]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=294</guid>
		<description><![CDATA[Although one could have guessed otherwise, I&#8217;ve always been a happy Subversion user. Which former CVS user hasn&#8217;t? But now I&#8217;m ready to take the next step. For some of my personal stuff I&#8217;ve been using Mercurial for more than a year, so I thought it was time to take the plunge and switch my [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=294&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Although one could have <a href="/2009/07/25/subversion-1-5-merging-massacres/">guessed otherwise</a>, I&#8217;ve always been a happy Subversion user. Which former CVS user hasn&#8217;t? But now I&#8217;m ready to take the next step. For some of my personal stuff I&#8217;ve been using Mercurial for more than a year, so I thought it was time to take the plunge and switch my <a href="http://code.google.com/p/jsystest">JSysTest project</a> to Mercurial.</p>
<p><span id="more-294"></span></p>
<p>Google Code recently added Mercurial hosting, so I didn&#8217;t have to switch the hosting provider. The conversion process is quite simple: There are <a href="http://code.google.com/p/support/wiki/ConvertingSvnToHg">good instructions</a> available that worked without any problems. From what I&#8217;ve seen so far, all functionality I care about is available (basically everything I used Subversion for).</p>
<p>One thing surprised me though: Converting a two dozen revisions took roughly 20 minutes, so for larger repositories you will have to take a long coffee break.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/294/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=294&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2009/07/31/migrating-to-mercurial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>Subversion 1.5 Merging Massacres</title>
		<link>http://unmaintainable.wordpress.com/2009/07/25/subversion-1-5-merging-massacres/</link>
		<comments>http://unmaintainable.wordpress.com/2009/07/25/subversion-1-5-merging-massacres/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 08:24:09 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[tools]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[rcs]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=289</guid>
		<description><![CDATA[Recently, I had the opportunity to work with Subversion 1.5 on a medium sized project. Since there were more than 20 developers working on the project with some of them in a different country, there was no other way than to use feature branches extensively. We thought Subversion&#8217;s merge tracking would reduce typical merging errors [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=289&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Recently, I had the opportunity to work with Subversion 1.5 on a medium sized project. Since there were more than 20 developers working on the project with some of them in a different country, there was no other way than to use feature branches extensively. We thought Subversion&#8217;s merge tracking would reduce typical merging errors by simplifying the process. But, well, we were wrong.</p>
<p><span id="more-289"></span></p>
<p>The sad truth is that few developers know exactly what their revision control system does behind their backs when merging branches. With Subversion prior to 1.5, things were pretty simple and there&#8217;s little magic involved. You have to be careful to state the correct revisions and if you don&#8217;t, you can still roll back your changes.</p>
<p>With 1.5, as long as everyone plays by the rules and sticks to the basic use cases, everything is fine. But if things go wrong (and they will), you&#8217;re really screwed. In a large team, there will always be someone who uses a buggy Subversion client, or someone who accidentally deletes merge properties (there&#8217;s often a high stress level before releases). And as soon as this has happened, merges may leave out revisions (or merge revisions twice) and you need in-depth knowledge to repair the damage. In some cases, even rolling back changes on trunk wasn&#8217;t enough if someone created a feature branch at the wrong time.</p>
<p>In a project consisting mostly of source files in a compiled language like Java or C#, obvious mistakes typically show up early. If you have lots of HTML, CSS, and XML configuration, or you&#8217;re working with an interpreted language, you don&#8217;t have this safety net. Your QA department (if you&#8217;re lucky enough to have one) will be the first to discover the problems.</p>
<p>So, if you&#8217;re a mostly happy Subversion 1.4 user and you&#8217;re considering migration to 1.5 or later for merge tracking, then my advice is: Don&#8217;t bother. Maybe recent versions fixed some of the problems, but I wouldn&#8217;t take chances. You don&#8217;t want to spend your nights fixing your source repository.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/289/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=289&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2009/07/25/subversion-1-5-merging-massacres/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>A Case for Guard Clauses</title>
		<link>http://unmaintainable.wordpress.com/2009/06/12/a-case-for-guard-clauses/</link>
		<comments>http://unmaintainable.wordpress.com/2009/06/12/a-case-for-guard-clauses/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 13:20:32 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[best practices]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[quality]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=283</guid>
		<description><![CDATA[One of my pet peeves in programming is that few people use guard clauses. A guard clause is an almost trivial concept that greatly improves readability. Inside a method, handle your special cases right away and return immediately.

Have a look at the following example:

private int doSomething() {
    if (everythingIsGood()) {

   [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=283&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>One of my pet peeves in programming is that few people use guard clauses. A guard clause is an almost trivial concept that greatly improves readability. Inside a method, handle your special cases right away and return immediately.</p>
<p><span id="more-283"></span></p>
<p>Have a look at the following example:</p>
<pre>
private int doSomething() {
    if (everythingIsGood()) {

        /*
         * Lots and lots of code here, but that's a different story.
         */

        return SOME_VALUE;
    } else {
        return ANOTHER_VALUE;  // a special case
    }
}
</pre>
<p>You can easily rewrite it using the <a href="http://www.refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html">Replace Nested Conditional with Guard Clauses</a> refactoring from Martin Fowler&#8217;s <a href="http://martinfowler.com/books.html#refactoring">Refactoring</a>:</p>
<pre>
private int doSomething() {
    if (! everythingIsGood()) // &lt;-- this is your guard clause
        return ANOTHER_VALUE;

    /*
     * Lots and lots of code here, but that's a different story.
     */

    return SOME_VALUE;
}
</pre>
<p>Once you&#8217;ve read past the conditional(s) at the beginning of the method, you know that your world is in order and you don&#8217;t have to worry about special cases anymore.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/283/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=283&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2009/06/12/a-case-for-guard-clauses/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>New Project: JSysTest</title>
		<link>http://unmaintainable.wordpress.com/2009/05/23/jsystest/</link>
		<comments>http://unmaintainable.wordpress.com/2009/05/23/jsystest/#comments</comments>
		<pubDate>Sat, 23 May 2009 10:39:57 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[distributed systems]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[quality]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=271</guid>
		<description><![CDATA[I love unit tests and use them whenever possible. But in the end, there&#8217;s no substitute for a full scale system test. Only after system testing, you can be sure that everything works as intended. When I was looking for a way to test a REST-style JSON web service, I decided to create a small [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=271&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I love unit tests and use them whenever possible. But in the end, there&#8217;s no substitute for a full scale system test. Only after system testing, you can be sure that everything works as intended. When I was looking for a way to test a REST-style JSON web service, I decided to create a small testing framework to simplify the task.</p>
<p><span id="more-271"></span></p>
<p>The result is the <a href="http://code.google.com/p/jsystest">JSysTest</a> framework written in Java. Using JSysTest, you can create functional web service tests based on JUnit 4 and its Hamcrest-based assertion DSL. With the help of some custom matchers, a test can look as concise as this:</p>
<pre>
  assertThat(get("/some-resource"), has(status(404)));
</pre>
<p>Have a look at the <a href="http://code.google.com/p/jsystest/">Documentation</a> for a few more examples.</p>
<p>The framework is still in its early stages of development and is likely to change. I still don&#8217;t know how to make HTTP POST and PUT methods as elegant as the GET case, but I&#8217;m sure a pattern will emerge at some point.</p>
<p>I think the most important lesson to take away from this little experiment is that you can simplify your tests significantly if you invest a bit of time for building a highly specialized DSL.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/271/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=271&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2009/05/23/jsystest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Collections Reaching 1.0</title>
		<link>http://unmaintainable.wordpress.com/2009/04/13/google-collections-reaching-10/</link>
		<comments>http://unmaintainable.wordpress.com/2009/04/13/google-collections-reaching-10/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 20:53:04 +0000</pubDate>
		<dc:creator>mafr</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[libraries]]></category>

		<guid isPermaLink="false">http://unmaintainable.wordpress.com/?p=228</guid>
		<description><![CDATA[Exciting news for Java developers: The first 1.0 release candidate of Google Collections has been released. For almost a year I&#8217;ve been waiting for this, and now it seems the waiting will soon be over.

Basically, Google Collections is a better, more consistent version of commons-collections with generics and a few cool things that let you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=228&subd=unmaintainable&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Exciting news for Java developers: The first 1.0 release candidate of <a href="http://code.google.com/p/google-collections/">Google Collections</a> has been released. For almost a year I&#8217;ve been waiting for this, and now it seems the waiting will soon be over.</p>
<p><span id="more-228"></span></p>
<p>Basically, Google Collections is a better, more consistent version of <a href="http://commons.apache.org/collections/">commons-collections</a> with generics and a few cool things that let you almost use a functional style in Java (at least as far as this is possible). I think this library will quickly become a standard dependency in my Java projects.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/unmaintainable.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/unmaintainable.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/unmaintainable.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/unmaintainable.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/unmaintainable.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/unmaintainable.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/unmaintainable.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/unmaintainable.wordpress.com/228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/unmaintainable.wordpress.com/228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/unmaintainable.wordpress.com/228/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=unmaintainable.wordpress.com&blog=586265&post=228&subd=unmaintainable&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://unmaintainable.wordpress.com/2009/04/13/google-collections-reaching-10/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/59c9677a3b9569af44561adab6c2a980?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mafr</media:title>
		</media:content>
	</item>
	</channel>
</rss>