<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Space Station Lambda &#187; GNU/Linux</title>
	<atom:link href="http://blog.viridian-project.de/sections/tech/gnu-linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.viridian-project.de</link>
	<description>Leslie P. Polzer on code, music, literature, design and free software business.</description>
	<lastBuildDate>Wed, 19 May 2010 07:44:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Starcraft on VirtualBox (and Hamachi)</title>
		<link>http://blog.viridian-project.de/2009/06/24/starcraft-on-virtualbox-and-hamachi/</link>
		<comments>http://blog.viridian-project.de/2009/06/24/starcraft-on-virtualbox-and-hamachi/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 20:37:35 +0000</pubDate>
		<dc:creator>Leslie</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[broodwar]]></category>
		<category><![CDATA[dib]]></category>
		<category><![CDATA[hamachi]]></category>
		<category><![CDATA[scbw]]></category>
		<category><![CDATA[slow]]></category>
		<category><![CDATA[starcraft]]></category>
		<category><![CDATA[virtualbox]]></category>

		<guid isPermaLink="false">http://blog.viridian-project.de/?p=166</guid>
		<description><![CDATA[Rationale Starcraft on Wine is horribly slow due to the missing DIB engine. Handling DIBs is a crucial component when it comes to fast 2D drawing. Other games like Age of Empires and even applications like Adobe Photoshop are affected by this weakness in Wine. Work on this has started last year as a Summer [...]]]></description>
			<content:encoded><![CDATA[<h2>Rationale</h2>
<p>Starcraft on Wine is horribly slow due to the missing <a href="http://wiki.winehq.org/DIBEngine">DIB engine</a>.</p>
<p>Handling DIBs is a crucial component when it comes to fast 2D drawing. Other games like Age of Empires and even applications like Adobe Photoshop are affected by this weakness in Wine.</p>
<p>Work on this has started last year as a Summer of Code program, but progress has slowed down recently.</p>
<p>All in all I guess we won&#8217;t get a usable implementation within the next few years except if another dedicated effort is spent on it.</p>
<h2>Enter VirtualBox</h2>
<p>Luckily another solution has come up recently: Sun&#8217;s <a href="http://www.virtualbox.org/">VirtualBox</a> virtualization product is free (as in beer and freedom), easy to use and works well enough with Starcraft.</p>
<p>Here&#8217;s my basic setup: VirtualBox 3.0.0 (in beta state right now but so far it hasn&#8217;t crashed on me) with guest additions, Windows XP and Starcraft Brood War 1.16.1.</p>
<p>I have enabled DirectDraw acceleration and bridging as network mode in VirtualBox. Both are simple point-and-click settings; you need to make sure the <tt>vboxnetflt</tt> module is loaded, though.</p>
<p>All of Starcraft is usable and very importantly fast.</p>
<h2>Resolution issues</h2>
<p><strong>Update:</strong> You can just use <a href="http://www.virtualbox.org/manual/UserManual.html#vboxsdl"><code>VBoxSDL</code></a> to start your VM in proper fullscreen mode without jumping through the hoops below. Makes it much more convenient and reliable.</p>
<p>VirtualBox does not have a real full-screen mode. With the guest additions you&#8217;re able to get a Desktop that resizes automatically to fit, but fixed resolutions (Starcraft uses 640&#215;480) will not be scaled up to fill the VirtualBox window or the whole screen.</p>
<p>I have tried <a href="http://www.x.org/wiki/Projects/XRandR">XRandR</a> but it just made the viewport smaller which is worse than useless.</p>
<p>The kludge here is to copy over your X config, remove all resolutions except for 640&#215;480 and start a new X server. I cannot go into the full detail here but it boils down to this:</p>
<pre>
xinit /home/sky/scripts/xinitrc.2 -display :1 \
  -- :1 -ac -config xorg.conf.lowres
</pre>
<p>Put in some lightweight window manager or VirtualBox itself at the end of <tt>xinitrc.2</tt>.</p>
<p>After that just use VirtualBox as you have before and switch to full screen.</p>
<p>You should be ready to get the full experience of playing Starcraft now!</p>
<h2>Bonus: Hamachi integration</h2>
<p><a href="https://secure.logmein.com/products/hamachi/vpn.asp?lang=en">Hamachi</a> is a proprietary cross-platform VPN solution that is also beginner-friendly and gratis. It works well with my VirtualBox setup, too.</p>
<p>However the latest version (1.0.3.0) does seem to have some problems with UDP networking.</p>
<p>Downgrading to <a href="http://www.filehippo.com/download_hamachi/2101/">1.0.1.4</a> helped, and I was even able to play Starcraft via a VPN. Don&#8217;t forget to turn off the helpful Windows firewall least it might interfere with your network.</p>
<h2>Did this post help you?</h2>
<p>If yes, then I&#8217;d like to know about it. Please also tell me about other games that work or don&#8217;t work with this setup.</p>
<p>If you&#8217;re really happy about it you may also <a href="http://www.amazon.de/gp/registry/registry.html?ie=UTF8&#038;type=wishlist&#038;id=2NRMXK4NC27QE">send me a gift</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.viridian-project.de/2009/06/24/starcraft-on-virtualbox-and-hamachi/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Mercurial extensions for git features</title>
		<link>http://blog.viridian-project.de/2008/11/05/mercurial-extensions-for-git-features/</link>
		<comments>http://blog.viridian-project.de/2008/11/05/mercurial-extensions-for-git-features/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 10:20:42 +0000</pubDate>
		<dc:creator>Leslie</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Branching]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[local branches]]></category>
		<category><![CDATA[localbranches]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[revision control]]></category>
		<category><![CDATA[shelve]]></category>
		<category><![CDATA[stash]]></category>

		<guid isPermaLink="false">http://blog.viridian-project.de/?p=147</guid>
		<description><![CDATA[I still enjoy work with Mercurial more, although git has grown a lot better in the last few years. In the last few days I especially noticed that hg is faster for me than git (even after repack of the git repository). That said, git has some very cool features that are missing in Mercurial. [...]]]></description>
			<content:encoded><![CDATA[<p>I still enjoy work with <a href="http://www.selenic.com/mercurial/" title="Mercurial (software)" rel="homepage" class="zem_slink">Mercurial</a> more, although git has grown a lot better in the last few years.</p>
<p>In the last few days I especially noticed that hg is faster for me than git (even after repack of the git repository).</p>
<p>That said, git has some very cool features that are missing in Mercurial.<br />
Two of them are local branches (helpful for feature development or bug isolation) and the <em>stash</em> command that lets you stash away local changes for later (sort of a simplified patch queue).</p>
<p>Fortunately there are two extensions that provide both local branching and stash functionality.</p>
<h3>Localbranches extension</h3>
<dl>
<dt>Wiki page</dt>
<dd>http://www.selenic.com/mercurial/wiki/index.cgi/LocalBranches</dd>
<dt>Repository</dt>
<dd>http://hg.kublai.com/mercurial/extensions/localbranch</dd>
</dl>
<h3>Shelve extension</h3>
<dl>
<dt>Wiki page</dt>
<dd>http://www.selenic.com/mercurial/wiki/index.cgi/ShelveExtension</dd>
<dt>Repository</dt>
<dd>http://freehg.org/u/tksoh/hgshelve/</dd>
</dl>
<h2>Installation</h2>
<p>To use an extension just clone the repository and put the following line into the [extensions] section of your hgrc (create file and section if necessary):</p>
<pre>EXTNAME=/path/to/EXTNAME.py
</pre>
<p>Usage examples are on the wiki pages.</p>
<p>Happy hacking!</p>
<div style="margin-top: 10px; height: 15px;" class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/9849a907-4ec8-4496-a2be-8e20491bb0ea/" title="Zemified by Zemanta"><img style="border: medium none ; float: right;" class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_c.png?x-id=9849a907-4ec8-4496-a2be-8e20491bb0ea" alt="Reblog this post [with Zemanta]"/></a></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.viridian-project.de/2008/11/05/mercurial-extensions-for-git-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JES, a KISS mail server</title>
		<link>http://blog.viridian-project.de/2008/10/04/jes-a-kiss-mail-server/</link>
		<comments>http://blog.viridian-project.de/2008/10/04/jes-a-kiss-mail-server/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 13:05:27 +0000</pubDate>
		<dc:creator>Leslie</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Web engineering]]></category>
		<category><![CDATA[dwim]]></category>
		<category><![CDATA[kiss]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[simple]]></category>
		<category><![CDATA[small]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[tiny]]></category>

		<guid isPermaLink="false">http://blog.viridian-project.de/?p=132</guid>
		<description><![CDATA[JES is a tiny Java mail server. Very useful for testing local mail emitting routines. Usage: download, extract, quickly edit the configuration files and execute bin/mail.sh. Thanks, Eric!]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ericdaugherty.com/java/mailserver/">JES</a> is a tiny Java mail server.</p>
<p>Very useful for testing local mail emitting routines.</p>
<p>Usage: download, extract, quickly edit the configuration files and execute <code>bin/mail.sh</code>.</p>
<p>Thanks, Eric!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.viridian-project.de/2008/10/04/jes-a-kiss-mail-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hard Disk Sentinel</title>
		<link>http://blog.viridian-project.de/2008/09/28/hard-disk-sentinel/</link>
		<comments>http://blog.viridian-project.de/2008/09/28/hard-disk-sentinel/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 12:27:00 +0000</pubDate>
		<dc:creator>Leslie</dc:creator>
				<category><![CDATA[Arch Linux]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[aur]]></category>
		<category><![CDATA[failure]]></category>
		<category><![CDATA[hard disk]]></category>
		<category><![CDATA[hdd]]></category>
		<category><![CDATA[hdsentinel]]></category>
		<category><![CDATA[prediction]]></category>
		<category><![CDATA[smart]]></category>

		<guid isPermaLink="false">http://blog.viridian-project.de/?p=109</guid>
		<description><![CDATA[HDSentinel is an utility that interprets the SMART information of your hard disk drives. Their flagship product is an extensive GUI tool for Win32, but they also have a small command-line application for GNU/Linux. It was recently uploaded to ArchLinux AUR and I gave it a whirl. Its output for one of my disks claimed [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.hdsentinel.com/">HDSentinel</a> is an utility that interprets the <a href="http://en.wikipedia.org/wiki/Self-Monitoring,_Analysis,_and_Reporting_Technology">SMART</a> information of your hard disk drives. Their flagship product is an extensive GUI tool for Win32, but they also have a <a href="http://www.hdsentinel.com/hdslin.php">small command-line application for GNU/Linux</a>.</p>
<p>It was recently <a href="http://aur.archlinux.org/packages.php?ID=20276">uploaded to ArchLinux AUR</a> and I gave it a whirl.</p>
<p>Its output for one of my disks claimed it to be close to failure:</p>
<pre>
HDD Device  2: /dev/sda
HDD Model ID : ST3160023A
HDD Serial No: 5JS2NX0R
HDD Revision : 3.06
HDD Size     : 152628 MB
Interface    : IDE/ATA
Temperature  : 42 °C
Health       : 13 %
Performance  : 100 %
Power on time: 658 days, 7 hours
Est. lifetime: 19 days
</pre>
<p>The <a href="http://www.hdsentinel.com/smart/index.php">theory behind HDSentinel</a> seems sound, so I&#8217;m looking forward to see whether the prediction will hold.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.viridian-project.de/2008/09/28/hard-disk-sentinel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lightning link checker</title>
		<link>http://blog.viridian-project.de/2008/07/13/lightning-link-checker/</link>
		<comments>http://blog.viridian-project.de/2008/07/13/lightning-link-checker/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 09:00:51 +0000</pubDate>
		<dc:creator>Leslie</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Web engineering]]></category>
		<category><![CDATA[concurrent]]></category>
		<category><![CDATA[fast]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[quick]]></category>
		<category><![CDATA[smp]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[urlcheck]]></category>

		<guid isPermaLink="false">http://blog.viridian-project.de/?p=87</guid>
		<description><![CDATA[Wow! urlcheck is lightweight, concurrent url checker. It uses minimal resources, and is multicore-capable. In contrast to popular link checkers, it uses few resources, will readily take advantage of multiple cores, and is easily killable. Works great and is fast as lightning. Plus, it&#8217;s written in Haskell. Arch Linux users get it from AUR, all [...]]]></description>
			<content:encoded><![CDATA[<p>Wow!</p>
<blockquote><p>
    urlcheck is lightweight, concurrent url checker. It uses minimal resources, and is multicore-capable.</p>
<p>    In contrast to popular link checkers, it uses few resources, will readily take advantage of multiple cores, and is easily killable.
</p></blockquote>
<p>Works great and is fast as lightning. Plus, it&#8217;s written in Haskell.</p>
<p>Arch Linux users <a href="http://aur.archlinux.org/packages.php?ID=17702">get it from AUR</a>, all others from their distribution or directly <a href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/urlcheck">from source</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.viridian-project.de/2008/07/13/lightning-link-checker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZSH tip: handling URLs with url-quote-magic</title>
		<link>http://blog.viridian-project.de/2008/07/03/zsh-tip-handling-urls-with-url-quote-magic/</link>
		<comments>http://blog.viridian-project.de/2008/07/03/zsh-tip-handling-urls-with-url-quote-magic/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 18:13:46 +0000</pubDate>
		<dc:creator>Leslie</dc:creator>
				<category><![CDATA[Arch Linux]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[quoting]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[shells]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[urls]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://blog.viridian-project.de/?p=83</guid>
		<description><![CDATA[The awesome Z Shell lets you forget about the quoting headeaches some URLs would cause. Its url-quote-magic line editing plugin automatically quotes metacharacters like question marks, quotes and ampersands while you type or paste them. You just have to enable it in your .zshrc (after installing ZSH, of course): autoload -U url-quote-magic zle -N self-insert [...]]]></description>
			<content:encoded><![CDATA[<p>The awesome <a href="http://www.zsh.org/">Z Shell</a> lets you forget about the quoting headeaches some URLs would cause. Its url-quote-magic line editing plugin automatically quotes metacharacters like question marks, quotes and ampersands while you type or paste them.</p>
<p>You just have to enable it in your <code>.zshrc</code> (after installing ZSH, of course):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">autoload <span style="color: #660033;">-U</span> url-quote-magic
zle <span style="color: #660033;">-N</span> self-insert url-quote-magic</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.viridian-project.de/2008/07/03/zsh-tip-handling-urls-with-url-quote-magic/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Poor man&#8217;s ALSA sound server</title>
		<link>http://blog.viridian-project.de/2008/04/05/poor-mans-alsa-sound-server/</link>
		<comments>http://blog.viridian-project.de/2008/04/05/poor-mans-alsa-sound-server/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 09:57:52 +0000</pubDate>
		<dc:creator>Leslie</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[alsa]]></category>
		<category><![CDATA[aplay]]></category>
		<category><![CDATA[arecord]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[gnu/linux]]></category>
		<category><![CDATA[kiss]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[netcat]]></category>
		<category><![CDATA[sound]]></category>
		<category><![CDATA[sound server]]></category>
		<category><![CDATA[trivial]]></category>

		<guid isPermaLink="false">http://blog.viridian-project.de/2008/04/05/poor-mans-alsa-sound-server/</guid>
		<description><![CDATA[I&#8217;m currently visiting my family, and an inevitable part of it is playing some good old games with my brothers. The hardware situation here is a bit peculiar, though; I need to play on two different machines, and only one of them has speakers. Those speakers are built-in, too, so I can&#8217;t change them easily. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently visiting my family, and an inevitable part of it is playing some good old games with my brothers. The hardware situation here is a bit peculiar, though; I need to play on two different machines, and only one of them has speakers.</p>
<p>Those speakers are built-in, too, so I can&#8217;t change them easily.<br />
No problem, there&#8217;s <a href="http://www.tux.org/~ricdude/EsounD.html">ESD</a>, right? Well. The Enlightened Sound Daemon might have deserved its name when it was released, but since then a bunch of years have passed and it didn&#8217;t show acceptable quality when I tried it here.</p>
<p><a href="http://www.pulseaudio.org/">PulseAudio</a> to the rescue! This modern solution runs even on Microsoft Windows (although not on the 9x series, it seems), has dead simple GUI tools and is the best thing since sliced bread. A real sports car.<br />
Except, for some unknown reason, I couldn&#8217;t get it to work on one of the machines in question. No sliced bread for me, I guess.</p>
<p>But then I came across a real slick solution in the ALSA wiki: a <a href="http://alsa.opensrc.org/index.php/Network">sound server using Netcat and the out-of-the-box ALSA utilities <em>aplay</em> and <em>arecord</em></a>.</p>
<p>Setup is as simple as:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># on the server:</span>
nc <span style="color: #660033;">-u</span> <span style="color: #660033;">-l</span> <span style="color: #660033;">-p</span> <span style="color: #000000;">9999</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">aplay</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># on the client</span>
<span style="color: #c20cb9; font-weight: bold;">arecord</span> <span style="color: #660033;">-t</span> wav <span style="color: #660033;">-f</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">|</span> nc <span style="color: #660033;">-u</span> SERVER <span style="color: #000000;">9999</span></pre></div></div>

<p>Now just set your recording source via <code>alsamixer -Vc</code> to &#8220;Mix&#8221; and adjust the output volume levels on client, server and speaker.</p>
<p>Made me slap my head &#8217;cause I didn&#8217;t think of it myself.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.viridian-project.de/2008/04/05/poor-mans-alsa-sound-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting started with CFFI</title>
		<link>http://blog.viridian-project.de/2008/01/24/getting-started-with-cffi/</link>
		<comments>http://blog.viridian-project.de/2008/01/24/getting-started-with-cffi/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 13:53:18 +0000</pubDate>
		<dc:creator>Leslie</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[cffi]]></category>
		<category><![CDATA[foreign function]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[load average]]></category>
		<category><![CDATA[pointer]]></category>
		<category><![CDATA[uptime]]></category>

		<guid isPermaLink="false">http://blog.viridian-project.de/2008/01/24/getting-started-with-cffi/</guid>
		<description><![CDATA[I really like the Lisp approach of accessing foreign functions; it puts the programmer in charge (as usual) instead of making him wait for some bindings to appear or get updated. Here&#8217;s a little recipe that shows how to get the load averages (the thing uptime shows) in Lisp, which will be useful later when [...]]]></description>
			<content:encoded><![CDATA[<p>I really like the Lisp approach of accessing foreign functions; it puts the programmer in charge (as usual) instead of making him wait for some bindings to appear or get updated.</p>
<p>Here&#8217;s a little recipe that shows how to get the load averages (the thing <code>uptime</code> shows) in Lisp, which will be useful later when we build a solid logging foundation with Gary&#8217;s <a href="http://common-lisp.net/project/log5">log5</a> package.<br />
In case you don&#8217;t know, the load average shows an approximation of the number of processes in the system&#8217;s task queue, thus serving as indication for machine load. </p>
<p>First, let&#8217;s do the initialization work for CFFI, as pointed out in its user guide:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>asdf<span style="color: #66cc66;">:</span><span style="color: #555;">oos</span> 'asdf<span style="color: #66cc66;">:</span><span style="color: #555;">load-op</span> 'cffi<span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>defpackage <span style="color: #66cc66;">:</span><span style="color: #555;">cffi-user</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">use</span> <span style="color: #66cc66;">:</span><span style="color: #555;">common-lisp</span> <span style="color: #66cc66;">:</span><span style="color: #555;">cffi</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>in-package <span style="color: #66cc66;">:</span><span style="color: #555;">cffi-user</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>define-foreign-library libc
  <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">unix</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #b1b100;">or</span> <span style="color: #ff0000;">&quot;libc.so.6&quot;</span> <span style="color: #ff0000;">&quot;libc.so.5&quot;</span> <span style="color: #ff0000;">&quot;libc.so&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>t <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">default</span> <span style="color: #ff0000;">&quot;libc.so&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>use-foreign-library libc<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Now we actually need to start thinking. How do we get at the numbers?<br />
Let&#8217;s find the C function:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">% apropos load | egrep -i &quot;average|avg&quot;
getloadavg           (3)  - get system load averages
[...]
% man 3 getloadavg</pre></div></div>

<p>The man page gives us this prototype:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> getloadavg<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span> loadavg<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #993333;">int</span> nelem<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>It also tells us that the first parameter will be filled with <code>nelem</code> samples and notes that (at least on my Linux system) the maximum number of samples is three, denoting the load averages of the last 1, 5 and 15 minutes. Let&#8217;s say that we want all three.</p>
<p>Now unfortunately the CFFI manual doesn&#8217;t say anything about arrays. But we can rewrite the prototype as</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> getloadavg<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #339933;">*</span> loadavg<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> nelem<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>leading to the following CFFI function spec:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>defcfun <span style="color: #ff0000;">&quot;getloadavg&quot;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">int</span> <span style="color: #66cc66;">&#40;</span>loadavg <span style="color: #66cc66;">:</span><span style="color: #555;">pointer</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>nelem <span style="color: #66cc66;">:</span><span style="color: #555;">int</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Now we are able to use <a href="http://common-lisp.net/project/cffi/manual/html_node/foreign_002dalloc.html">foreign-alloc</a> to allocate a pointer of the correct size (i.e. <code>3*sizeof(double)</code>), and <a href="http://www.common-lisp.net/project/cffi/manual/html_node/mem_002daref.html">mem-aref</a> to access the resulting array.</p>
<p>Combined with matching LOOP and FORMAT programs and the manual garbage collection we get:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> load-averages <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>loadavg <span style="color: #66cc66;">&#40;</span>foreign-alloc <span style="color: #66cc66;">:</span><span style="color: #555;">double</span> <span style="color: #66cc66;">:</span><span style="color: #555;">count</span> <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>getloadavg loadavg <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">; note the imperative style we are forced to use</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">prog1</span> <span style="color: #808080; font-style: italic;">; we need to clean up after producing the return value</span>
      <span style="color: #66cc66;">&#40;</span>format <span style="color: #b1b100;">nil</span> <span style="color: #ff0000;">&quot;~{~,2F~^ ~}&quot;</span> <span style="color: #66cc66;">&#40;</span>loop for i from <span style="color: #cc66cc;">0</span> to <span style="color: #cc66cc;">2</span>
                                    collect <span style="color: #66cc66;">&#40;</span>mem-<span style="color: #b1b100;">aref</span> loadavg <span style="color: #66cc66;">:</span><span style="color: #555;">double</span> i<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
      <span style="color: #66cc66;">&#40;</span>foreign-free loadavg<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>If you have questions regarding any part of that last snippet, feel free to ask.</p>
<p>Note that we don&#8217;t do any error checking here; <code>getloadavg</code> will return <code>-1</code> on failure, although I can&#8217;t imagine why it would do so.</p>
<p>You can access the full code at <a href="http://paste.lisp.org/display/54746">http://paste.lisp.org/display/54746</a>.</p>
<p>I hope this post wasn&#8217;t overly verbose (read: boring) to you.<br />
It was my intention to make this understandable for beginners.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.viridian-project.de/2008/01/24/getting-started-with-cffi/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Locating a font&#8217;s files by its name</title>
		<link>http://blog.viridian-project.de/2008/01/23/locating-a-fonts-files-by-its-name/</link>
		<comments>http://blog.viridian-project.de/2008/01/23/locating-a-fonts-files-by-its-name/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 13:18:27 +0000</pubDate>
		<dc:creator>Leslie</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[browsing]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[finding]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[location]]></category>
		<category><![CDATA[name]]></category>
		<category><![CDATA[x]]></category>
		<category><![CDATA[x server]]></category>
		<category><![CDATA[x window]]></category>
		<category><![CDATA[yahoo]]></category>
		<category><![CDATA[yui]]></category>

		<guid isPermaLink="false">http://blog.viridian-project.de/2008/01/23/locating-a-fonts-files-by-its-name/</guid>
		<description><![CDATA[Over the last months I had a problem when browsing sites using the YUI font library. Those sites would have a hard to read monospaced font instead of a variable-width sans-serif one. Today I decided to find out what was the culprit of this. I started Firebug and inspected the offending CSS. It turned out [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last months I had a problem when browsing sites using the <a href="http://developer.yahoo.com/yui/fonts/">YUI font library</a>. Those sites would have a hard to read monospaced font instead of a variable-width sans-serif one.</p>
<p>Today I decided to find out what was the culprit of this. I started <a href="http://getfirebug.com/">Firebug</a> and inspected the offending CSS. It turned out that they mention the font name <code>clean</code> in their <code>font-family</code> path, and that removing this from the valid families helped restore order among the glyphs. To make this permanent I had to find the offending font and delete it.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">xlsfonts | grep -i clean</pre></div></div>

<p>told me that the subject was “Schumacher Clean”, but not more. After messing around with <a href="http://www.fontmatrix.net/">Fontmatrix</a> (which doesn&#8217;t attempt to find the fonts registered with the X server by itself) and <a href="http://uwstopia.nl/blog/2007/06/gnome-specimen-0-2-is-out">GNOME Specimen</a> (which didn&#8217;t knew about or refused to tell me the location of a font&#8217;s files), this helped:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">fc-cat | grep -i clean
# showed something like clR6x12.pcf.gz
locate clR6x12.pcf.gz
# gave me the location
sudo rm /usr/share/fonts/misc/clR*
# removed all incarnations of the font
sudo fc-cache
# informed the X server</pre></div></div>

<p>Once again command-line tools proved to be the solution. Great for me, but quite problematic in a world where more than 99% of users don&#8217;t use it (because they don&#8217;t know what it is or how to use it productively).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.viridian-project.de/2008/01/23/locating-a-fonts-files-by-its-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pacman 3.1.0: better and better</title>
		<link>http://blog.viridian-project.de/2008/01/15/pacman-310-better-and-better/</link>
		<comments>http://blog.viridian-project.de/2008/01/15/pacman-310-better-and-better/#comments</comments>
		<pubDate>Tue, 15 Jan 2008 13:00:20 +0000</pubDate>
		<dc:creator>Leslie</dc:creator>
				<category><![CDATA[Arch Linux]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[good thing]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[package management]]></category>
		<category><![CDATA[package manager]]></category>
		<category><![CDATA[packages]]></category>
		<category><![CDATA[pacman]]></category>

		<guid isPermaLink="false">http://blog.viridian-project.de/2008/01/15/pacman-310-better-and-better/</guid>
		<description><![CDATA[Pacman is the package manager that once having used, you don&#8217;t want to go back to others. Why? Simplicity! My personal highlights in the new version: Support for xdelta diffs: binary diffs so I can go back to previous package versions if the current one is borked. Previously one had to hope to have the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.archlinux.org/pacman/">Pacman</a> is the package manager that once having used, you don&#8217;t want to go back to others.</p>
<p>Why? Simplicity!</p>
<p>My personal highlights in the new version:</p>
<ul>
<li>Support for <a href="http://xdelta.org/">xdelta</a> diffs: binary diffs so I can go back to previous package versions if the current one is borked. Previously one had to hope to have the old version in the cache or find some outdated mirror.</li>
<li><code>--ignorearch</code> option for <i>makepkg</i></li>
<p> &#8212; no more hacking of PKGBUILD files that don&#8217;t have <i>arch</i> information.</p>
<li>Topological sorting for dependencies: I suspect this is responsible for the speed-up I noticed.</li>
<li>Massive optimization and speed-up for <code>--owns</code>: finding the package a certain file belongs to is a function I often need.</li>
<li>single mirrorfile: finally a centralized place for the mirror list.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.viridian-project.de/2008/01/15/pacman-310-better-and-better/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
