<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>numerodix blog</title>
	
	<link>http://www.matusiak.eu/numerodix/blog</link>
	<description>A blog about nothing</description>
	<lastBuildDate>Thu, 05 Nov 2009 19:11:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/numerodix" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>a filter for life</title>
		<link>http://feedproxy.google.com/~r/numerodix/~3/rvx_PRZZo2g/</link>
		<comments>http://www.matusiak.eu/numerodix/blog/index.php/2009/11/05/a-filter-for-life/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 19:11:48 +0000</pubDate>
		<dc:creator>numerodix</dc:creator>
				<category><![CDATA[issues]]></category>

		<guid isPermaLink="false">http://www.matusiak.eu/numerodix/blog/?p=2429</guid>
		<description><![CDATA[There was a movement within the Norwegian education system at one point to emphasize the goal that kids in school should be critical. More than that, it should be the goal of the education system to teach us to be read critically. Don&#8217;t take everything you hear as gospel. This was back when I was [...]]]></description>
			<content:encoded><![CDATA[<p>There was a movement within the Norwegian education system at one point to emphasize the goal that kids in school should be critical. More than that, it should be the goal of the education system to teach us to be read critically. Don&#8217;t take everything you hear as gospel. This was back when I was still in junior high, so a good 15 years back. I don&#8217;t know if this theme is still current today, but at the very least it made a good pass through the common consciousness at one point.</p>
<p>So why did this come about? Well, in the early 90s television was privatized. There had been cable tv for a number of years already, but in 1992 the channel TV2, the first commercial tv station to broadcast nationally, alongside the state broadcaster NRK, was launched. Effectively, television was let go from under the control of the rather insular NRK and freed to be driven by commercial profit. Naturally, TV2 in short order proceeded to import all of the popular culture, chiefly American, that has informed our lives. Another characteristic of TV2, quite unlike NRK &#8212; the absolute sterility of any form of even mild intellectualism. (Aside from NRK which may have as much as 2-3 weekly hours of programming suited to the more discerning viewer, provided the topic is up your street.)</p>
<p>Another big development in the mid and late 90s, of course &#8212; wide access to the internet. Here again is a brand new medium with immense amounts of information and culture &#8220;beamed&#8221; right into our homes.</p>
<p>I feel it was these two developments that formed the impetus behind this fashion within the education system. All of a sudden students would be writing essays using web pages for sources that, believe it or not, were just <em>incorrect</em>. <img src='http://www.matusiak.eu/numerodix/blog/wp-includes/images/smilies/eek.png' alt=':eek:' class='wp-smiley' />  Oh noes, something has to be done! And so it began. The internet is not trustworthy. You can&#8217;t believe everything you read. The deeper reasoning behind this is the question of <strong>motive</strong>. More important than what they are saying; why are they saying it? Back in my junior high days we received the dumbed down version (as, actually, with everything in junior high). The question was framed in terms of <em>sources</em>. This source is reliable, because it&#8217;s Encyclopedia Britannica. This source is not, because it&#8217;s a web page, or I heard it on tv. Never mind who gets to decide what is reliable and why.</p>
<p>Of course, the truth, as your astute self would have figured out by now, is that nothing is in and of itself trustworthy. It&#8217;s not just when you go online that you find garbage. There&#8217;s just as much garbage in books, in what your teachers tell you, in what your parents tell you, and above all in what your peers tell you. You need to be critical of all this stuff, not just of those crazy people on the internet.</p>
<p><em>I&#8217;m inadvertently rehashing <a href="http://the-gay-bar.com/index.php?/archives/341-On-sources/">Jürgen&#8217;s argument</a> here. I read his entry and didn&#8217;t give it any more thought, but perhaps my subconsciousness has been chewing on it ever since? Thanks, Jürgen.</em></p>
<p>Naturally, some people are just malicious, but that is not the main problem. Even if you do have a piece of insight that you honestly believe is beneficial to someone, there are still a lot of things that can go wrong:</p>
<ol>
<li>You&#8217;re plain mistaken.</li>
<li>It works for you, but it doesn&#8217;t work for everyone.</li>
<li>Even though you have the right idea, you fail to communicate it effectively.</li>
</ol>
<p>The last one is particularly unfortunate. How many times has someone told you that they&#8217;ve just this discovered this new thing and it&#8217;s everything they needed, and then you say &#8220;but I told you that already a long time ago!&#8221;. Well, I guess you didn&#8217;t tell me in the words that I needed to hear in order to absorb the information, or in order to be convinced.</p>
<p>Parental advice, of course, is susceptible to the same flaw as those self help books. I&#8217;m sure you&#8217;ve seen some of those around, the basic premise is always the same &#8212; some person has figured out how to do something and wants to tell everyone. The problem is that just because it worked for him, doesn&#8217;t mean it will work for you. Especially when you hear it from a secondary source (a relative comes up and says &#8220;I read this amazing book, it changed my life, all you have to do is..&#8221;). But it&#8217;s not science. At best it &#8220;sorta works a lot of the time, kind of&#8221;.</p>
<p>So over time you develop a filter. &#8220;This person is not worth listening to on <em>these</em> topics, <em>this</em> book is written by someone who has no idea what he&#8217;s talking about, this website is usually reliable on <em>these</em> issues&#8221;. Now everything depends on that filter of yours. You may find one day that you bought into some utter nonsense, or that you discarded good insight.</p>
<img src="http://feeds.feedburner.com/~r/numerodix/~4/rvx_PRZZo2g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.matusiak.eu/numerodix/blog/index.php/2009/11/05/a-filter-for-life/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.matusiak.eu/numerodix/blog/index.php/2009/11/05/a-filter-for-life/</feedburner:origLink></item>
		<item>
		<title>how much time you got?</title>
		<link>http://feedproxy.google.com/~r/numerodix/~3/44HDvR3ie4Q/</link>
		<comments>http://www.matusiak.eu/numerodix/blog/index.php/2009/10/23/how-much-time-you-got/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 13:25:18 +0000</pubDate>
		<dc:creator>numerodix</dc:creator>
				<category><![CDATA[observations]]></category>

		<guid isPermaLink="false">http://www.matusiak.eu/numerodix/blog/?p=2426</guid>
		<description><![CDATA[One of the most important currencies of today is time. Of course, people have always been trading in time, paying people to do things for them that they were either too lazy, or &#8220;too important&#8221;, to do. But in today&#8217;s world time has gone as far as to replace money in the daily rhetoric of [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most important currencies of today is time. Of course, people have always been trading in time, paying people to do things for them that they were either too lazy, or &#8220;too important&#8221;, to do. But in today&#8217;s world time has gone as far as to replace money in the daily rhetoric of many people. I wonder if people in the past spent as much time complaining about not having enough time as it&#8217;s common to do today. We have more freedoms and opportunities than ever, there&#8217;s just no time to enjoy them all.</p>
<p>The biggest complaint among people today, once they stop complaining about lack of money, is lack of time. There is a strange kind of contempt for people who have time.<br />
- Look at this cool thing these guys did.<br />
- Yeah they really have a lot of time on their hands (those rich bastards!)</p>
<p>Strangely enough, there are also those who have a sense of pride about *not* having time. They just love fake-complaining to you about how busy they are. Well who decided you have to be so busy? Oh, I know, *you* did. Here, I have the solution for you. Ditch _everything_ that you&#8217;re doing right now and you&#8217;ll have more time than you ever dreamed of.</p>
<p>Being busy is also the standard way to lie to yourself when rejecting people. &#8220;Oh dear, I&#8217;d love to come to your whatever, but I&#8217;m just so darn busy&#8221;. No, you just decided that you&#8217;d rather do something else. *I* know what it means, and you might as well just have told me that you weren&#8217;t interested instead of telling yourself that you&#8217;re a caring person who never lets anyone down. Because that&#8217;s just plain obnoxious.</p>
<p>Now, what people seem to forget is that unlike money, time is very much your own choice. You don&#8217;t choose to be born into a wealthy family, but you can easily choose to be rich on time. Here&#8217;s a simple test: do you have a tv? Unplug it. You just won hours upon hours of time and it didn&#8217;t cost you a dime! (Unless of course tv is what you most want to use your time for, but then you shouldn&#8217;t complain about lack of time, you should revel in all the tv time you have!)</p>
<img src="http://feeds.feedburner.com/~r/numerodix/~4/44HDvR3ie4Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.matusiak.eu/numerodix/blog/index.php/2009/10/23/how-much-time-you-got/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.matusiak.eu/numerodix/blog/index.php/2009/10/23/how-much-time-you-got/</feedburner:origLink></item>
		<item>
		<title>findpkgs: Find packages for application</title>
		<link>http://feedproxy.google.com/~r/numerodix/~3/pV4iauIZ3oY/</link>
		<comments>http://www.matusiak.eu/numerodix/blog/index.php/2009/10/14/findpkgs-find-packages-for-application/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 12:09:44 +0000</pubDate>
		<dc:creator>numerodix</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.matusiak.eu/numerodix/blog/?p=2413</guid>
		<description><![CDATA[Every distribution has a package manager and a whole lot of work goes into maintaining packages and correctly resolving their dependencies. This is a descriptive kind of dependency tracking.
The other day I had the idea of using a more &#8220;evidence based&#8221; method. Given a linked binary, you can find out what libraries it uses with [...]]]></description>
			<content:encoded><![CDATA[<p>Every distribution has a package manager and a whole lot of work goes into maintaining packages and correctly resolving their dependencies. This is a descriptive kind of dependency tracking.</p>
<p>The other day I had the idea of using a more &#8220;evidence based&#8221; method. Given a linked binary, you can find out what libraries it uses with <code>ldd</code>. (This, however, will not account for any dynamic linking that happens during runtime.) More interestingly, perhaps, given a running process, you can figure out which files it using to run. There is <code>lsof</code>, and if not, <code>/proc/pid/maps</code> has that information too.</p>
<p>Such a list of files can then be fed to the package manager to find the packages which own them.</p>
<p>For instance, which package owns <code>init</code> (on an Ubuntu system)?</p>
<p style="padding-left: 30px;">$ findpkgs 1<br />
upstart</p>
<p>What&#8217;s needed to run <code>ls</code> (on a Gentoo system)?
</p>
<p style="padding-left: 30px;">$ findpkgs ls<br />
sys-apps/acl<br />
sys-apps/attr<br />
sys-apps/coreutils<br />
sys-libs/glibc</p>
<p>What about a Python application like <code>iotop</code>?
</p>
<p style="padding-left: 30px;">$ findpkgs `pgrep iotop`<br />
dev-lang/python<br />
dev-libs/openssl<br />
sys-libs/glibc<br />
sys-libs/ncurses<br />
sys-libs/zlib</p>
<p>The query-package-manager-for-owner-of-file tries to figure out which package manager is used on the system in this order:</p>
<ol>
<li>paludis</li>
<li>qfile</li>
<li>equery</li>
<li>dpkg</li>
<li>rpm</li>
</ol>
<p>To be honest I&#8217;m not really sure how useful this is, I just put it together since I figured out it could be done. It *can* answer the question: <em>which packages are required to run this application?</em> (Or to be more precise: to achieve this specific runtime state of the application.) So if you write an app, send it to a friend and he can&#8217;t make it run, you could use <code>findpkgs</code> to get a list of them he needs to install (provided he&#8217;s on the same distro and all that).</p>
<pre class="bash"><span style="color: #808080; font-style: italic;"># Author: Martin Matusiak &lt;numerodix@gmail.com&gt;</span>
<span style="color: #808080; font-style: italic;"># Licensed under the GNU Public License, version 3</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># &lt;desc&gt; Find packages by binary or process pid &lt;/desc&gt;</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># &lt;usage&gt;</span>
<span style="color: #808080; font-style: italic;"># source this file in bash, then run `findpkgs`</span>
<span style="color: #808080; font-style: italic;"># &lt;/usage&gt;</span>
&nbsp;
&nbsp;
<span style="color: #b1b100;">function</span> _findpkgfor<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000066;">local</span> <span style="color: #0000ff;">file=</span><span style="color: #ff0000;">"$1"</span>;shift;
&nbsp;
	<span style="color: #b1b100;">if</span> which paludis &amp;&gt;/dev/null; <span style="color: #b1b100;">then</span>
		paludis -o <span style="color: #ff0000;">"$file"</span> <span style="color: #cc66cc;">2</span>&gt;/dev/null | grep <span style="color: #ff0000;">'::installed'</span> \\
			| sed <span style="color: #ff0000;">"s/::installed//g"</span> | tr -d <span style="color: #ff0000;">' '</span>
	<span style="color: #b1b100;">elif</span> which qfile &amp;&gt;/dev/null; <span style="color: #b1b100;">then</span>
		qfile <span style="color: #ff0000;">"$file"</span> <span style="color: #cc66cc;">2</span>&gt;/dev/null | awk <span style="color: #ff0000;">'{print $1}'</span>
	<span style="color: #b1b100;">elif</span> which equery &amp;&gt;/dev/null; <span style="color: #b1b100;">then</span>
		equery belongs <span style="color: #ff0000;">"$file"</span> <span style="color: #cc66cc;">2</span>&gt;/dev/null | awk <span style="color: #ff0000;">'{print $1}'</span>
	<span style="color: #b1b100;">elif</span> which dpkg &amp;&gt;/dev/null; <span style="color: #b1b100;">then</span>
		dpkg -S <span style="color: #ff0000;">"$file"</span> <span style="color: #cc66cc;">2</span>&gt;/dev/null | awk <span style="color: #ff0000;">'{print $1}'</span> | tr -d <span style="color: #ff0000;">':'</span>
	<span style="color: #b1b100;">elif</span> which rpm &amp;&gt;/dev/null; <span style="color: #b1b100;">then</span>
		rpm -qf <span style="color: #ff0000;">"$file"</span> <span style="color: #cc66cc;">2</span>&gt;/dev/null | grep -v <span style="color: #ff0000;">"not owned"</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #000066;">echo</span> <span style="color: #ff0000;">"No known package manager found"</span>
	<span style="color: #b1b100;">fi</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">function</span> findpkgs<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000066;">local</span> <span style="color: #0000ff;">arg=</span><span style="color: #ff0000;">"$1"</span>;shift;
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#91;</span> ! <span style="color: #ff0000;">"$arg"</span> <span style="color: #66cc66;">&#93;</span>; <span style="color: #b1b100;">then</span>
		<span style="color: #000066;">echo</span> <span style="color: #ff0000;">"Usage:  findpkgs [ pid | /path/to/binary ]"</span>
		<span style="color: #000066;">return</span>
	<span style="color: #b1b100;">fi</span>
&nbsp;
	<span style="color: #000066;">local</span> <span style="color: #0000ff;">pid=</span>
	<span style="color: #000066;">local</span> <span style="color: #0000ff;">arg_new=</span>
	<span style="color: #000066;">local</span> <span style="color: #0000ff;">bin=</span>
	<span style="color: #b1b100;">if</span> <span style="color: #000066;">echo</span> <span style="color: #ff0000;">"$arg"</span> | grep <span style="color: #ff0000;">"^[0-9]*$"</span> &amp;&gt;/dev/null; <span style="color: #b1b100;">then</span>
		<span style="color: #0000ff;">pid=</span><span style="color: #ff0000;">"$arg"</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #0000ff;">arg_new=</span>$<span style="color: #66cc66;">&#40;</span>which <span style="color: #ff0000;">"$arg"</span> <span style="color: #cc66cc;">2</span>&gt;/dev/null<span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#91;</span> <span style="color: #ff0000;">"$arg_new"</span> <span style="color: #66cc66;">&#93;</span> &amp;&amp; <span style="color: #0000ff;">arg=</span><span style="color: #ff0000;">"$arg_new"</span>
		<span style="color: #b1b100;">if</span> ! <span style="color: #000066;">echo</span> <span style="color: #ff0000;">"$arg"</span> | grep <span style="color: #ff0000;">'^/'</span> &amp;&gt;/dev/null; <span style="color: #b1b100;">then</span>
			<span style="color: #000066;">echo</span> <span style="color: #ff0000;">"Can't find absolute path (or not a binary) for: $arg"</span> &gt;&amp;<span style="color: #cc66cc;">2</span>
			<span style="color: #000066;">return</span>
		<span style="color: #b1b100;">fi</span>
		<span style="color: #0000ff;">arg=</span>$<span style="color: #66cc66;">&#40;</span>readlink -f <span style="color: #ff0000;">"$arg"</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #b1b100;">if</span> ! file <span style="color: #ff0000;">"$arg"</span> | grep <span style="color: #ff0000;">'ELF'</span> &amp;&gt;/dev/null; <span style="color: #b1b100;">then</span>
			<span style="color: #000066;">echo</span> <span style="color: #ff0000;">"Not a binary: $arg"</span> &gt;&amp;<span style="color: #cc66cc;">2</span>
			<span style="color: #000066;">return</span>
		<span style="color: #b1b100;">fi</span>
		<span style="color: #0000ff;">bin=</span><span style="color: #ff0000;">"$arg"</span>
	<span style="color: #b1b100;">fi</span>
&nbsp;
&nbsp;
	<span style="color: #000066;">local</span> <span style="color: #0000ff;">fst=</span>
	<span style="color: #000066;">local</span> <span style="color: #0000ff;">fst_new=</span>
	<span style="color: #000066;">local</span> <span style="color: #0000ff;">files=</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#91;</span> <span style="color: #ff0000;">"$pid"</span> <span style="color: #66cc66;">&#93;</span>; <span style="color: #b1b100;">then</span>
		<span style="color: #0000ff;">fst=</span>$<span style="color: #66cc66;">&#40;</span>ps aux \\
					| sed <span style="color: #ff0000;">"s/^[^ ]* *//g"</span> \\
					| grep <span style="color: #ff0000;">"^$pid "</span> \\
					| awk <span style="color: #ff0000;">'{print $10}'</span> \\
					| tr -d <span style="color: #ff0000;">':'</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #0000ff;">fst_new=</span>$<span style="color: #66cc66;">&#40;</span>which <span style="color: #ff0000;">"$fst"</span> <span style="color: #cc66cc;">2</span>&gt;/dev/null<span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#91;</span> <span style="color: #ff0000;">"$fst_new"</span> <span style="color: #66cc66;">&#93;</span> &amp;&amp; <span style="color: #0000ff;">fst=</span><span style="color: #ff0000;">"$fst_new"</span>
		<span style="color: #b1b100;">if</span> ! <span style="color: #000066;">echo</span> <span style="color: #ff0000;">"$fst"</span> | grep <span style="color: #ff0000;">'^/'</span> &amp;&gt;/dev/null; <span style="color: #b1b100;">then</span>
			<span style="color: #000066;">echo</span> <span style="color: #ff0000;">"Can't find absolute path for: $fst"</span> &gt;&amp;<span style="color: #cc66cc;">2</span>
			<span style="color: #000066;">unset</span> fst
		<span style="color: #b1b100;">fi</span>
&nbsp;
		<span style="color: #b1b100;">if</span> $<span style="color: #66cc66;">&#40;</span>which lsof &amp;&gt;/dev/null<span style="color: #66cc66;">&#41;</span>; <span style="color: #b1b100;">then</span>
			<span style="color: #0000ff;">files=</span>$<span style="color: #66cc66;">&#40;</span>lsof \\
						| sed <span style="color: #ff0000;">"s/^[^ ]* *//g"</span> \\
						| grep <span style="color: #ff0000;">"^$pid "</span> \\
						| awk <span style="color: #ff0000;">'{print $8}'</span> \\
						| grep <span style="color: #ff0000;">'^/'</span> \\
						| sort \\
						| uniq<span style="color: #66cc66;">&#41;</span>
		<span style="color: #b1b100;">else</span>
			<span style="color: #0000ff;">files=</span>$<span style="color: #66cc66;">&#40;</span>cat <span style="color: #ff0000;">"/proc/$pid/maps"</span> \\
						| awk <span style="color: #ff0000;">'{print $6}'</span> \\
						| grep <span style="color: #ff0000;">'^/'</span> \\
						| sort \\
						| uniq<span style="color: #66cc66;">&#41;</span>
		<span style="color: #b1b100;">fi</span>
&nbsp;
		<span style="color: #0000ff;">files=</span><span style="color: #ff0000;">"$fst $files"</span>
		<span style="color: #b1b100;">for</span> file <span style="color: #b1b100;">in</span> `<span style="color: #000066;">echo</span> <span style="color: #0000ff;">$files</span>`; <span style="color: #b1b100;">do</span>
			_findpkgfor <span style="color: #ff0000;">"$file"</span>
		<span style="color: #b1b100;">done</span> | sort | uniq
&nbsp;
	<span style="color: #b1b100;">elif</span> <span style="color: #66cc66;">&#91;</span> <span style="color: #ff0000;">"$bin"</span> <span style="color: #66cc66;">&#93;</span>; <span style="color: #b1b100;">then</span>
		<span style="color: #0000ff;">files=</span>$<span style="color: #66cc66;">&#40;</span>ldd <span style="color: #ff0000;">"$bin"</span> \\
					| awk <span style="color: #ff0000;">'{print $3}'</span> \\
					| grep <span style="color: #ff0000;">'^/'</span> \\
					| sort \\
					| uniq<span style="color: #66cc66;">&#41;</span>
		<span style="color: #0000ff;">files=</span><span style="color: #ff0000;">"$bin $files"</span>
		<span style="color: #b1b100;">for</span> file <span style="color: #b1b100;">in</span> `<span style="color: #000066;">echo</span> <span style="color: #0000ff;">$files</span>`; <span style="color: #b1b100;">do</span>
			_findpkgfor <span style="color: #ff0000;">"$file"</span>
		<span style="color: #b1b100;">done</span> | sort | uniq
	<span style="color: #b1b100;">fi</span>
<span style="color: #66cc66;">&#125;</span></pre>
<p><i>Download this code: </i><a href="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/findpkgs.sh">findpkgs.sh</a></p></p>
<img src="http://feeds.feedburner.com/~r/numerodix/~4/pV4iauIZ3oY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.matusiak.eu/numerodix/blog/index.php/2009/10/14/findpkgs-find-packages-for-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.matusiak.eu/numerodix/blog/index.php/2009/10/14/findpkgs-find-packages-for-application/</feedburner:origLink></item>
		<item>
		<title>Starbucks? Not all that it’s cracked up to be</title>
		<link>http://feedproxy.google.com/~r/numerodix/~3/zRVG4TJRCBs/</link>
		<comments>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/19/starbucks-not-all-that-its-cracked-up-to-be/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 07:53:07 +0000</pubDate>
		<dc:creator>numerodix</dc:creator>
				<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://www.matusiak.eu/numerodix/blog/?p=2408</guid>
		<description><![CDATA[So I went by Starbucks today. The line wasn&#8217;t quite as long as I had seen it on previous occasions. I went in. What struck me right away was how noisy it was inside. Mind you they&#8217;re located inside a busy train terminal, with nothing but a delimiting glass panel wall, so it&#8217;s not going [...]]]></description>
			<content:encoded><![CDATA[<p>So I went by Starbucks today. The line wasn&#8217;t quite as long as I had seen it on previous occasions. I went in. What struck me right away was how noisy it was inside. Mind you they&#8217;re located inside a busy train terminal, with nothing but a delimiting glass panel wall, so it&#8217;s not going to be a quiet, cozy café. But they clearly had done nothing to insulate from the noise. Which is just as well, because most of it was coming from inside the Starbucks. There was music blasting, and five staffers yelling orders over the music. It was literally as noisy as MacDonalds on a busy day. So much for ambience, none of it. Those stories about people hanging out in a Starbucks &#8211; those places must be categorically different from this one.</p>
<p>As I was pondering this, the line advanced and soon I found myself making my order. And that&#8217;s when I noticed how poorly organized the staffers were. First I made my order to the girl leaning over the cake counter. She proceeded to yell it down the line to the production division. Then I approached the cash register and had to repeat my order to another girl. &#8220;A large caffè latte.&#8221; &#8220;Was it a venti?&#8221; &#8220;I have no idea, I said large.&#8221; I refuse to speak their pretend language.  The girl who had taken the order chimed in to clarify. I forked over cash and, strangely enough, did not receive a receipt. Are they saving on paper?</p>
<p>That&#8217;s when I got in line behind the six previous customers who were still waiting to get theirs. Clearly, they were backed up with orders.  My coffee was ready before all of theirs was. But the girl in production had no idea whom it was for, because there were no receipts to work from. The orders were filled, but how to match them with customers? So she asks every person in turn &#8220;what are you waiting for?&#8221; That was the third time I had to say my order.</p>
<p>All of this somehow distracted me from noticing the beating I took on the coffee. €3.95 for a large caffè latte? That&#8217;s hilarious. At MacDonalds you can get a meal for a little over 5 bucks. Maybe they could justify the price if the café was a great place to hang out. Or if the coffee were especially good. Or if they were especially well organized and efficient.</p>
<img src="http://feeds.feedburner.com/~r/numerodix/~4/zRVG4TJRCBs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/19/starbucks-not-all-that-its-cracked-up-to-be/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/19/starbucks-not-all-that-its-cracked-up-to-be/</feedburner:origLink></item>
		<item>
		<title>koffie where coffee is arriving late</title>
		<link>http://feedproxy.google.com/~r/numerodix/~3/GUZ_jzqIxPA/</link>
		<comments>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/16/koffie-where-coffee-is-arriving-late/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 17:04:40 +0000</pubDate>
		<dc:creator>numerodix</dc:creator>
				<category><![CDATA[dutchness]]></category>

		<guid isPermaLink="false">http://www.matusiak.eu/numerodix/blog/?p=2399</guid>
		<description><![CDATA[Last week Starbucks opened a branch here in Utrecht, which didn&#8217;t go unnoticed. I&#8217;m not one of those people who are completely nuts about coffee, but I am quite fond of it.   I went by Central Station, but the line was much too long. I like coffee, but I&#8217;m not going to stand [...]]]></description>
			<content:encoded><![CDATA[<p>Last week Starbucks opened a branch here in Utrecht, which didn&#8217;t go unnoticed. I&#8217;m not one of those people who are completely nuts about coffee, but I am quite fond of it. <img src='http://www.matusiak.eu/numerodix/blog/wp-includes/images/smilies/lick.png' alt=':lick:' class='wp-smiley' />  I went by Central Station, but the line was much too long. I like coffee, but I&#8217;m not going to stand in line like it&#8217;s Michael Jackson tickets.</p>
<p>Meanwhile, <a href="http://theshot.coffeeratings.com/2009/08/chain-coffee-consistency-myth/">Greg</a> debunks the idea that chains actually have a consistent product and asks why would people flock to Starbucks when they could be having better coffee at a local outlet? The obvious answer is: preconception. Much could probably be attributed to MacDonalds, who have forever maintained that they serve you the same food no matter where you are. Starbucks doesn&#8217;t really have to do anything to push that idea, it&#8217;s already been implanted.</p>
<p>But the deeper reason is that this country doesn&#8217;t really have a coffee culture. Yet. When I moved here I was pleased to find out that <em>koffie</em> is part of the fabric of this society. It isn&#8217;t a &#8220;new&#8221; thing like it is in, say, Poland, where tea has always been the dominant beverage. But the Dutch koffie predates the cawfee of today. In countries like Poland and Norway, without a strong existing coffee culture, the yuppie caffè latte gimmick has been a big hit in recent years. (Although in Norway, to &#8220;our&#8221; credit, most of the coffee places are local entrepreneurs, not foreign chains, and provide considerably better ambiance than sitting in a Starbucks.)  Not so here. With an existing &#8220;coffee infrastructure&#8221;, Holland has not been quite the fertile ground, and the coffee revolution that has placed a coffee place on every corner hasn&#8217;t happened. Coffee is still, by and large, the traditional sit down experience, and an unremarkable, humble one at that.</p>
<p>You won&#8217;t find a lot of cafés that serve a caffè latte, or even a solid espresso. Around these parts coffee is still, much of the time, &#8220;just coffee&#8221;. Not the fast food inspired, to-go in a paper cup with a selection of 30 different drinks.</p>
<img src="http://feeds.feedburner.com/~r/numerodix/~4/GUZ_jzqIxPA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/16/koffie-where-coffee-is-arriving-late/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/16/koffie-where-coffee-is-arriving-late/</feedburner:origLink></item>
		<item>
		<title>is your town rainy?</title>
		<link>http://feedproxy.google.com/~r/numerodix/~3/wZb4aeE9KMk/</link>
		<comments>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/13/is-your-town-rainy/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 20:57:50 +0000</pubDate>
		<dc:creator>numerodix</dc:creator>
				<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://www.matusiak.eu/numerodix/blog/?p=2375</guid>
		<description><![CDATA[Complaining about rain seems to be some kind of ingrained human reflex. But if (almost) everyone is doing it then surely not everyone has a case? Before I moved to the Netherlands I heard  people say it rained here all the time. That doesn&#8217;t agree at all with my observations. But what&#8217;s a lot? [...]]]></description>
			<content:encoded><![CDATA[<p>Complaining about rain seems to be some kind of ingrained human reflex. But if (almost) everyone is doing it then surely not everyone has a case? Before I moved to the Netherlands I heard  people say it rained here all the time. That doesn&#8217;t agree at all with my observations. But what&#8217;s a lot? Compared to what?</p>
<h3>I know, facts!</h3>
<p>The <a href="http://worldweather.wmo.int/">World Weather Information Service</a> has climate information on 1000+ cities around the world. I decided to do a little data mining. All conclusions to follow are based on that data. Just for kicks, I should mention there are very serious methodological problems with this exercise. First of all, they say countries don&#8217;t necessarily use the same definitions for what&#8217;s a rainy day or measure precipitation the same way. So you&#8217;re not really supposed to compare cities. Secondly, when placing cities on a world scale, sampling is everything. And nothing is known about the criteria by which cities are included in the list. We&#8217;re not gonna let petty details like that stop us, though.</p>
<p>I should also mention that &#8220;rain&#8221; as used here also includes snow where applicable.</p>
<h3>Is it rainy here or what!</h3>
<p>So is it rainy here? Let&#8217;s compare it to the control point: Trondheim. And let&#8217;s throw in some other data points too, for good measure.</p>
<ul>
<li>Cities with a reputation for rain: Bergen, London, Seattle, some town on the Spanish north coast (found A Coruna on the list).</li>
<li>Cities known to be dry: Los Angeles, Zaragoza (turns out to be the driest city in Europe)</li>
<li>Other cities: Berlin, Dublin, Milan, Paris, Stockholm</li>
</ul>
<p>The first number is the total annual precipitation. The second is the number of rainy days.</p>
<pre class="bash">city            mm/y   days
Bergen          <span style="color: #cc66cc;">2250</span>   <span style="color: #cc66cc;">235</span>
A Coruna        <span style="color: #cc66cc;">1008</span>   <span style="color: #cc66cc;">171</span>
Seattle          <span style="color: #cc66cc;">945</span>   <span style="color: #cc66cc;">122</span>
Milan            <span style="color: #cc66cc;">943</span>    <span style="color: #cc66cc;">86</span>
Trondheim        <span style="color: #cc66cc;">892</span>   <span style="color: #cc66cc;">216</span>
Amsterdam        <span style="color: #cc66cc;">780</span>   <span style="color: #cc66cc;">185</span>
Dublin           <span style="color: #cc66cc;">733</span>   <span style="color: #cc66cc;">129</span>
Paris            <span style="color: #cc66cc;">650</span>   <span style="color: #cc66cc;">112</span>
London           <span style="color: #cc66cc;">611</span>   <span style="color: #cc66cc;">145</span>
Berlin           <span style="color: #cc66cc;">571</span>   <span style="color: #cc66cc;">106</span>
Stockholm        <span style="color: #cc66cc;">539</span>   <span style="color: #cc66cc;">173</span>
Zaragoza         <span style="color: #cc66cc;">317</span>    <span style="color: #cc66cc;">79</span>
Los Angeles      <span style="color: #cc66cc;">305</span>    <span style="color: #cc66cc;">27</span></pre>
<p><i>Download this code: </i><a href="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/rainy_cities">rainy_cities</a></p>
<p>Bergen&#8217;s reputation is well justified, it turns out to be the rainiest city in Europe. Rainy London, on the other hand, is a complete myth.</p>
<h3>No, not like that, use *all* the facts!</h3>
<p>But what do random cities tell us about the big picture? Not much. Let&#8217;s see how countries place on the overall ranking. Here we see the span they occupy in the list, from the rainiest city on the left to the driest on the right. (Spain refers to mainland Spain.)</p>
<p><img class="alignnone size-full wp-image-2388" title="rainplot" src="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/rainplot.png" alt="rainplot" width="500" height="209" /></p>
<p>The Netherlands place smack in the middle. So to say it&#8217;s a rainy country is an obvious exaggeration, it&#8217;s pretty much average. The very narrow span is probably due to the small and uniform geography. Norway, on the other hand, is definitely rainy, occupying the space in the rainy portion of the list. Bergen is most rainy, Oslo is least. As for London, it&#8217;s actually the lower end of the UK span, further diffusing its rainy reputation.</p>
<p>If you like staying dry the very best place to be is Luxor in Egypt, where precipitation is a minuscule 3mm annually. At the other end is <a href="http://worldweather.wmo.int/057/c00883.htm">Quibdo</a> in Colombia, with an incredible 8m of rainfall and 305 days of rain.</p>
<h3>But you didn&#8217;t&#8230;</h3>
<p>I know, but this isn&#8217;t supposed to be comprehensive. If you want to do further work on this data you can get the list I generated:</p>
<ul>
<li><a href="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/climate_raindata.gz">climate_raindata.gz</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/numerodix/~4/wZb4aeE9KMk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/13/is-your-town-rainy/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/13/is-your-town-rainy/</feedburner:origLink></item>
		<item>
		<title>sms is a garbage protocol</title>
		<link>http://feedproxy.google.com/~r/numerodix/~3/fLcqHsYSRdU/</link>
		<comments>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/08/sms-is-a-garbage-protocol/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 18:38:12 +0000</pubDate>
		<dc:creator>numerodix</dc:creator>
				<category><![CDATA[reviews]]></category>

		<guid isPermaLink="false">http://www.matusiak.eu/numerodix/blog/?p=2368</guid>
		<description><![CDATA[
no error on transmission failure
no failure on invalid recipient
no assurance of delivery to temporarily disconnected recipient

All of which amounts to the result that when you do send a text you have no idea if the number is correct, if the message went through, and in the event the person&#8217;s phone is turned off if he&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>no error on transmission failure</li>
<li>no failure on invalid recipient</li>
<li>no assurance of delivery to temporarily disconnected recipient</li>
</ul>
<p>All of which amounts to the result that when you do send a text you have no idea if the number is correct, if the message went through, and in the event the person&#8217;s phone is turned off if he&#8217;ll ever see it.</p>
<p>Now, I really don&#8217;t care if the flaws are in the protocol, the phones or the services we pay for; what I do know is that it all makes for an appalling technology whose reliability imitates Microsoft&#8217;s infamous msn messenger where messages constantly go missing without notice. I hear all the time about messages I never saw and apparently when my phone is off for a few days there is zero chance of getting messages sent in that interval.</p>
<p>Compare it to email, which doesn&#8217;t have any of these flaws, and it seems incredible that we are actually paying to use this.</p>
<p>And that&#8217;s to say nothing of the horrendous user interface for typing messages on a phone to begin with.</p>
<p><i>This entry belongs in a comprehensive tome I have been writing in my head for a decade, detailing just how much cell phones suck. But the field is so vast that it overwhelms my ability to articulate it.</i></p>
<img src="http://feeds.feedburner.com/~r/numerodix/~4/fLcqHsYSRdU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/08/sms-is-a-garbage-protocol/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/08/sms-is-a-garbage-protocol/</feedburner:origLink></item>
		<item>
		<title>The timeless Riviera</title>
		<link>http://feedproxy.google.com/~r/numerodix/~3/pcc7Cpk01Rg/</link>
		<comments>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/06/the-timeless-riviera/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 21:32:55 +0000</pubDate>
		<dc:creator>numerodix</dc:creator>
				<category><![CDATA[travel]]></category>

		<guid isPermaLink="false">http://www.matusiak.eu/numerodix/blog/?p=2346</guid>
		<description><![CDATA[
The beauty of the camping vacation is the enduring feeling of being on site. Air travel is very insular that way, I feel like I&#8217;m in the same place right up until I get off the plane, but when you&#8217;re on the road it&#8217;s a whole different feeling and more authentic in a sense. It&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-2348" title="summer_vacation_2009_flags" src="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/summer_vacation_2009_flags.png" alt="summer_vacation_2009_flags" width="388" height="60" /></p>
<p>The beauty of the camping vacation is the enduring feeling of being on site. Air travel is very insular that way, I feel like I&#8217;m in the same place right up until I get off the plane, but when you&#8217;re on the road it&#8217;s a whole different feeling and more authentic in a sense. It&#8217;s tiresome if you have to go far to get there, but once you cross the border into where you&#8217;re going there is a real sense of expectation that gradually bears out. And you can stop anywhere you want along the way.</p>
<p><a href="http://maps.google.com/maps/ms?ie=UTF8&amp;msa=0&amp;msid=103874864395451078623.0004707ce230862ef66b2&amp;ll=47.989922,15.820313&amp;spn=12.240133,39.155273&amp;z=5"><img class="alignnone size-full wp-image-2345" title="summer_vacation_route_2009" src="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/summer_vacation_route_2009.jpg" alt="summer_vacation_route_2009" width="437" height="367" /></a></p>
<p>Locations of interest:</p>
<ul>
<li>Wien (classical concert)</li>
<li>Verona (late night outdoor opera)<br />
Camping right near Lago di Garda &#8211; a summer camping hotspot</li>
<li>La Spezia (all day visit to the pictoresque villages in Cinque Terre national park)</li>
<li>Genova (city walk and a visit to Europe&#8217;s largest aquarium/oceanography museum)</li>
<li>San Remo (walk along the promenade and swimming at the beach)</li>
<li>Monaco (city walk, swimming at the beach)</li>
<li>Nice (walk along the promenade, swimming)</li>
<li>Cannes (walk along the promenade)</li>
<li>Ramatuelle by St. Tropez<br />
Camping at the unbeatable Les Tournels</li>
<li>St. Tropez (city walk)</li>
<li>Marseille (city walk)<br />
Camping in Aix-en-Provence &#8211; a nice town in itself</li>
<li>Les Baux-de-Provence (a splendid ancient castle)</li>
<li>Orange (the best preserved Roman theater in Europe)</li>
<li>Geneve (CERN museum, city walk)</li>
<li>Lausanne (city walk)</li>
<li>Bern (Einestein museum)</li>
<li>Zurich (natural earth museum and a robotics museum)</li>
<li>Munich (Deutches museum &#8211; world&#8217;s largest museum of science and technology)</li>
</ul>
<p>And that&#8217;s a way to spend three weeks.</p>
<img src="http://feeds.feedburner.com/~r/numerodix/~4/pcc7Cpk01Rg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/06/the-timeless-riviera/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.matusiak.eu/numerodix/blog/index.php/2009/08/06/the-timeless-riviera/</feedburner:origLink></item>
		<item>
		<title>networktest: improved network detection</title>
		<link>http://feedproxy.google.com/~r/numerodix/~3/Sfahtx6uirA/</link>
		<comments>http://www.matusiak.eu/numerodix/blog/index.php/2009/06/14/networktest-improved-network-detection/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 22:22:03 +0000</pubDate>
		<dc:creator>numerodix</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.matusiak.eu/numerodix/blog/?p=2327</guid>
		<description><![CDATA[As a follow up to the network perimeter test I have expanded the code a bit. It now shows also the interface names to help explain what&#8217;s what, and it also tries to match the gateway to the ip addresses found. The strategy, however, has changed somewhat. At first the goal was to find all [...]]]></description>
			<content:encoded><![CDATA[<p>As a follow up to the <a href="http://www.matusiak.eu/numerodix/blog/index.php/2008/11/17/havenet-network-perimeter-test/">network perimeter test</a> I have expanded the code a bit. It now shows also the interface names to help explain what&#8217;s what, and it also tries to match the gateway to the ip addresses found. The strategy, however, has changed somewhat. At first the goal was to find all the networks and proceed from there. I decided this was not really the best approach, given that a misconfigured network connection could possibly contain, say, a gateway not on any network. It therefore seems more sensible to display the information read from <code>route</code> and <code>ifconfig</code> as is than try to infer too much from it.</p>
<p>Here for instance the loopback ip is on a network that is not known, but still a working ip nonetheless.</p>
<p>The probing strategy also includes <code>nmap</code> (if available) probes to have some redundancy in the process (say for instance outbound icmp is blocked by the firewall). And the code has been made more portable, so on platforms other than linux (where linux networking tools aren&#8217;t present) there is a graceful degradation of features.</p>
<p><img class="aligncenter size-full wp-image-2326" title="havenet1" src="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/havenet1.png" alt="havenet1" width="474" height="275" /></p>
<p>Naturally, much networking happens over wireless these days, so there&#8217;s also a <code>wifi</code> command that displays the status of all the wireless interfaces. This is again nothing more than is revealed by <code>iwconfig</code>, but in a considerably more human readable form I would argue.</p>
<p><img class="aligncenter size-full wp-image-2332" title="wifi" src="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/wifi.png" alt="wifi" width="491" height="96" /></p>
<p>Then there is <code>wifiscan</code>, which not surprisingly scans for access points. The output is a considerably more space efficient and usable counterpart to what <code>iwlist</code> prints.</p>
<p><img class="aligncenter size-full wp-image-2333" title="wifiscan" src="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/wifiscan.png" alt="wifiscan" width="498" height="174" /></p>
<p>One thing to keep in mind about these detection commands is that many of the system tools being used offer less (or none) information to unprivileged users, so running these commands as root may produce fuller output.</p>
<ul>
<li><a href="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/networktest-0.2.tar.gz">networktest-0.2.tar.gz</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/numerodix/~4/Sfahtx6uirA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.matusiak.eu/numerodix/blog/index.php/2009/06/14/networktest-improved-network-detection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.matusiak.eu/numerodix/blog/index.php/2009/06/14/networktest-improved-network-detection/</feedburner:origLink></item>
		<item>
		<title>classes of functions</title>
		<link>http://feedproxy.google.com/~r/numerodix/~3/VJtlRt6yYvY/</link>
		<comments>http://www.matusiak.eu/numerodix/blog/index.php/2009/05/24/classes-of-functions/#comments</comments>
		<pubDate>Sun, 24 May 2009 00:17:46 +0000</pubDate>
		<dc:creator>numerodix</dc:creator>
				<category><![CDATA[math]]></category>

		<guid isPermaLink="false">http://www.matusiak.eu/numerodix/blog/?p=2269</guid>
		<description><![CDATA[I decided to finally blog this since I can never frickin remember which is which. Maybe if I write this and draw the diagram it&#8217;ll finally stick. If not, I&#8217;ll have something to come back to. To make it more accessible I&#8217;ll be using a running example: the bike allocation problem. Given a group of [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to finally blog this since I can never frickin remember which is which. Maybe if I write this and draw the diagram it&#8217;ll finally stick. If not, I&#8217;ll have something to come back to. To make it more accessible I&#8217;ll be using a running example: <strong>the bike allocation problem</strong>. Given a group of people and a set of bikes, who gets which bike?</p>
<h3>Partial functions</h3>
<p><img class="size-full wp-image-2271 alignright" title="function_properties_partial" src="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/function_properties_partial.png" alt="function_properties_partial" />Partial functions are pretty self explanatory. All you have to remember is which side the partiality concerns. In our example a partial function means that not every person has been assigned a bike. Some persons do not have bikes, so <code>lookup_bike(person)</code> will not work on all inputs.</p>
<p>Partial functions are common in code: reading from files that don&#8217;t exist, and of course the ever lurking <code>NullPointerException</code> &#8212; following a pointer to an object that is not live. In haskell, this is where the <code>Maybe</code> monad appears.</p>
<h3>Total functions</h3>
<p><img class="size-full wp-image-2278 alignright" title="function_properties_total" src="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/function_properties_total.png" alt="function_properties_total" />Not surprisingly, total functions are the counterpart to partial functions. A total function has a value for every possible input, so that means every person has been assigned a bike. But it doesn&#8217;t tell you anything about how the bikes are distributed over the persons; whether it&#8217;s one-to-one, all persons sharing the same bike etc.</p>
<p>Clearly, total functions are more desirable than partial ones &#8212; it means the caller can call the function with any value without having to check it first. Partial functions often masquerade as total ones, by returning a value outside the expected range (which explains the existence of a <code>null</code> value in just about every programming language and data format). In python the value <code>0</code>, <code>None</code> and any empty sequence (<code>string</code>, <code>list</code>, <code>tuple</code>, <code>dict</code>) all represent null, which makes writing total functions easy.</p>
<h3>Bijective/isomorphic functions (forall one-to-one)</h3>
<p><img class="size-full wp-image-2287 alignright" title="function_properties_bijective" src="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/function_properties_bijective.png" alt="function_properties_bijective" />A bijective function (also called isomorphic) is a one-to-one mapping between the persons and the bikes (between the domain and codomain). It means that if you find a bike, you can trace it back to exactly one person, and that if you have a person you can trace it to exactly one bike. In other words it means the inverse function works, that is both <code>lookup_bike(person)</code> and <code>lookup_person(bike)</code> work for all inputs.</p>
<p>Isomorphic functions are found in all kinds of translations; storing objects in a database, compressing files etc. The name literally means &#8220;the same shape&#8221;, so any format that can reproduce the same structure can represent the same data.</p>
<h3>Injective functions (one-to-one)</h3>
<p><img class="size-full wp-image-2294 alignright" title="function_properties_injective" src="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/function_properties_injective.png" alt="function_properties_injective" />An injective function returns a distinct value for every input. That is, no bike is assigned to more than one person. If the function is total, then what prevents it from being bijective is the unequal cardinality of the domain and codomain (ie. more bikes than persons).</p>
<p>Another way to understand it is to think of something small being stored in (embedded in) something big. In order to maintain unique output values, the codomain must be at least as big as the domain. GUIDs are an example of this. A GUID generator guarantees a globally unique identifier by picking values from a sufficiently large space. Given a GUID that has been issued, you can trace it back to exactly one object, but you cannot take just any value in the GUID space, because most of them have never (and will never) be issued to anyone.</p>
<h3>Surjective functions (many-to-one)</h3>
<p><img class="size-full wp-image-2298 alignright" title="function_properties_surjective" src="http://www.matusiak.eu/numerodix/blog/wp-content/uploads/function_properties_surjective.png" alt="function_properties_surjective" />A surjective function is one where all values in the codomain are used (ie. all bikes are assigned). In a way it is the inverse property of a total function (where all persons have a bike).</p>
<p>Surjective functions are often undesirable in practice, meaning that you have too few resources at your disposal, which forces sharing (threads on a cpu) or rejection (streaming server can only accept so many clients).</p>
<p>The way to think of injections and surjections is <em>not</em> as opposites, but as complementary properties. A function can be both injective (all persons have a unique bike) and surjective (all bikes are used). If so, it is bijective.</p>
<img src="http://feeds.feedburner.com/~r/numerodix/~4/VJtlRt6yYvY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.matusiak.eu/numerodix/blog/index.php/2009/05/24/classes-of-functions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.matusiak.eu/numerodix/blog/index.php/2009/05/24/classes-of-functions/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 0.414 seconds --><!-- Cached page served by WP-Cache -->
