<?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>Digital Ambulation</title>
	<atom:link href="http://www.alanbriolat.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alanbriolat.co.uk</link>
	<description>Life, programming and general geekery</description>
	<lastBuildDate>Mon, 05 Jul 2010 15:12:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Batch Re-tabbing Files with Vim</title>
		<link>http://www.alanbriolat.co.uk/2010/05/batch-re-tabbing-files-with-vim/</link>
		<comments>http://www.alanbriolat.co.uk/2010/05/batch-re-tabbing-files-with-vim/#comments</comments>
		<pubDate>Sun, 23 May 2010 19:04:22 +0000</pubDate>
		<dc:creator>Alan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.alanbriolat.co.uk/?p=416</guid>
		<description><![CDATA[So you have your favourite tabbing convention, but you&#8217;ve ended up with some files in some other convention, for example tabs instead of 4 spaces. If you use Vim and already have it set up to your liking, the :retab command will replace indents in the current buffer with those matching your convention. It&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<p>So you have your favourite tabbing convention, but you&#8217;ve ended up with some files in some other convention, for example tabs instead of 4 spaces.  If you use Vim and already have it set up to your liking, the <code>:retab</code> command will replace indents in the current buffer with those matching your convention.  It&#8217;s a bit tedious to do this manually for each file, so if you trust Vim not to make a mistake (or you&#8217;re using version control) you can use a bit of scripting-fu to make it easier:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> F <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*</span>.<span style="color: #7a0874; font-weight: bold;">&#123;</span>c,h<span style="color: #7a0874; font-weight: bold;">&#125;</span>pp ; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;:retab&quot;</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;:wq&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$F</span>&quot;</span> ; <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.alanbriolat.co.uk/2010/05/batch-re-tabbing-files-with-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remapping Mouse Buttons on Ubuntu Lucid</title>
		<link>http://www.alanbriolat.co.uk/2010/04/remapping-mouse-buttons-on-ubuntu-lucid/</link>
		<comments>http://www.alanbriolat.co.uk/2010/04/remapping-mouse-buttons-on-ubuntu-lucid/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 17:52:49 +0000</pubDate>
		<dc:creator>Alan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.alanbriolat.co.uk/?p=412</guid>
		<description><![CDATA[For ergonomic reasons (discussed previously) I like a side button on my mouse to act as a middle button instead.  Unfortunately there still doesn&#8217;t seem to be an &#8220;easy&#8221; way to remap mouse buttons in Linux, and what&#8217;s more the method of changing such settings seems to keep changing.  To achieve the same results in [...]]]></description>
			<content:encoded><![CDATA[<p>For ergonomic reasons <a href="http://www.alanbriolat.co.uk/2009/06/mouse-button-remapping-with-hal/">(discussed previously)</a> I like a side button on my mouse to act as a middle button instead.  Unfortunately there still doesn&#8217;t seem to be an &#8220;easy&#8221; way to remap mouse buttons in Linux, and what&#8217;s more the method of changing such settings seems to keep changing.  To achieve the same results in Ubuntu Lucid, I added an Xorg configuration fragment at <code>/usr/lib/X11/xorg.conf.d/20-logitech-mx1100.conf</code>:</p>
<pre>
Section "InputClass"
        Identifier "Logitech MX1100 button remap"
        MatchProduct "Logitech USB Receiver"
        MatchDevicePath "/dev/input/event*"
        Option "ButtonMapping" "1 2 3 4 5 6 7 2 9 10"
EndSection
</pre>
<p>As with the previous method, <code>xinput list</code> should give you the product string to use for <code>MatchProduct</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alanbriolat.co.uk/2010/04/remapping-mouse-buttons-on-ubuntu-lucid/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Fixing ugly Qt fonts in GNOME</title>
		<link>http://www.alanbriolat.co.uk/2010/04/fixing-ugly-qt-fonts-in-gnome/</link>
		<comments>http://www.alanbriolat.co.uk/2010/04/fixing-ugly-qt-fonts-in-gnome/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 20:30:51 +0000</pubDate>
		<dc:creator>Alan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.alanbriolat.co.uk/?p=406</guid>
		<description><![CDATA[So far every time I&#8217;ve used Qt applications under GNOME, especially VirtualBox, I&#8217;ve found the Qt font rendering to be appalling.  See this screenshot of VirtualBox alongside the GNOME appearance dialog: As you can see, most of my font settings are at the default &#8220;Sans&#8221; font.  The &#8220;Sans&#8221; and &#8220;Sans serif&#8221; fonts , at least [...]]]></description>
			<content:encoded><![CDATA[<p>So far every time I&#8217;ve used Qt applications under GNOME, especially VirtualBox, I&#8217;ve found the Qt font rendering to be appalling.  See this screenshot of VirtualBox alongside the GNOME appearance dialog:</p>
<p><a href="http://www.alanbriolat.co.uk/wp-content/uploads/2010/04/screenshot_001.png" rel="lightbox[406]"><img class="alignnone size-medium wp-image-407" title="screenshot_001" src="http://www.alanbriolat.co.uk/wp-content/uploads/2010/04/screenshot_001-300x139.png" alt="screenshot_001" width="300" height="139" /></a></p>
<p>As you can see, most of my font settings are at the default &#8220;Sans&#8221; font.  The &#8220;Sans&#8221; and &#8220;Sans serif&#8221; fonts , at least in recent Ubuntu releases, refer to the corresponding DejaVu font variants (previously it was Bitstream Vera).  However as I found out through experimentation, whilst Qt is obeying my font settings, the generic &#8220;Sans&#8221; font seems to mean something completely different (at least to Qt4).  If I instead specify the DejaVu fonts directly in my font settings, the correct font rendering is used:</p>
<p><a href="http://www.alanbriolat.co.uk/wp-content/uploads/2010/04/screenshot_002.png" rel="lightbox[406]"><img class="alignnone size-medium wp-image-408" title="screenshot_002" src="http://www.alanbriolat.co.uk/wp-content/uploads/2010/04/screenshot_002-300x139.png" alt="screenshot_002" width="300" height="139" /></a></p>
<p>So that&#8217;s it: if you&#8217;re using GNOME and you seem to get a Qt font rendering that doesn&#8217;t match your GTK font rendering, try using a more specific font.  (<strong>Note:</strong> I haven&#8217;t got a clue what &#8220;Sans&#8221; <em>actually</em> means to GNOME, but it doesn&#8217;t appear to be a font in it&#8217;s own right.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alanbriolat.co.uk/2010/04/fixing-ugly-qt-fonts-in-gnome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When Dynamic Typing Goes Wrong</title>
		<link>http://www.alanbriolat.co.uk/2009/07/when-dynamic-typing-goes-wrong/</link>
		<comments>http://www.alanbriolat.co.uk/2009/07/when-dynamic-typing-goes-wrong/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 19:01:32 +0000</pubDate>
		<dc:creator>Alan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.alanbriolat.co.uk/?p=388</guid>
		<description><![CDATA[Yesterday I found out first-hand how using a dynamically typed language can get you into trouble in unexpected ways whilst writing unit tests for CSF (my PHP framework). Take a look at this code&#8212;what do you think it should do? $foo = 'bar'; var_dump&#40;isset&#40;$foo&#91;'xyz'&#93;&#41;&#41;; var_dump&#40;$foo&#91;'xyz'&#93;&#41;; Most people would assume that indexing a string on another [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I found out first-hand how using a dynamically typed language can get you into trouble in unexpected ways whilst writing unit tests for <a href="http://codescape.net/csf/">CSF</a> (my PHP framework).</p>
<p><span id="more-388"></span></p>
<p>Take a look at this code&#8212;what do you think it should do?</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$foo</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'bar'</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$foo</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'xyz'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$foo</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'xyz'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Most people would assume that indexing a string on another string is nonsensical, and they would be right&#8212;in PHP you can only index a string with an integer.  The logical extension would be that isset($foo['xyz']) would be false and/or any attempt to index using a string would raise an error.  And that is where they would be wrong.  In fact, isset($foo['xyz']) is true, and $foo['xyz'] is &#8220;b&#8221;.</p>
<p>PHP is <a href="http://en.wikipedia.org/wiki/Dynamic_typing#Dynamic_typing">dynamically typed</a>, which generally means there is a lot of implicit casting between types going on.  In this case, while indexing a string can only be done with an integer, there is an implicit cast from a string to an integer, so this cast is performed and the result used as the index.  However, the usual way of converting from a string to an integer is to use digits (0&#8211;9) up until the first non-digit character (after taking the minus sign into account if there is one).  This means the integer value of &#8216;xyz&#8217; is 0, since there are no digits to add up.</p>
<p>When explained, this may seem like sensible behaviour, but let&#8217;s think about the effect this has when coding and debugging: if you accidentally index a string with another string somewhere, you won&#8217;t know about it straight away.  Instead, you&#8217;ll just be getting &#8220;wrong&#8221; values and scratching your head over where they could be coming from.  I&#8217;m of the opinion that if you can only index a string on an integer, then indexing it on a string should be at the very least a warning.  Silently doing something completely different isn&#8217;t very helpful.</p>
<p>And so that this doesn&#8217;t seem like a nonsensical contrived example, here&#8217;s a reduced version of the code that raised the issue:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_item<span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path</span><span style="color: #339933;">,</span> <span style="color: #000088;">$default</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$item</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$array</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">func_num_args</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span>
                throw <span style="color: #000000; font-weight: bold;">new</span> ItemNotFound<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">else</span>
                <span style="color: #b1b100;">return</span> <span style="color: #000088;">$default</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$item</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$item</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>What this function does is traverse a multi-dimensional array with a &#8220;key path&#8221;, i.e. &#8220;key1.key2&#8243; gets $array['key1']['key2'].  Since isset() is the most common way people check the existence of an array, this is what I used here.  However, things break down in this example:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'foo'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'bar'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> get_item<span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'foo.xyz'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The expected behaviour is that the exception should be thrown, since $array['foo'] is not an array with a &#8220;xyz&#8221; key, but the issue described above instead leads this to return &#8220;b&#8221;.</p>
<p>In this case, there is a way around it: what I really should have been using is the following check:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">array_key_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #339933;">,</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>This has more interesting consequences&#8212;it means that a very very large number of people are using &#8220;isset&#8221; where they mean &#8220;is_array and array_key_exists&#8221;.  As for me, I just fixed a bug in my code exposed by a unit test, so I&#8217;m happy (even if a little bewildered by PHP).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alanbriolat.co.uk/2009/07/when-dynamic-typing-goes-wrong/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why .NET Won&#8217;t Beat Java (Yet)</title>
		<link>http://www.alanbriolat.co.uk/2009/06/why-net-wont-beat-java-yet/</link>
		<comments>http://www.alanbriolat.co.uk/2009/06/why-net-wont-beat-java-yet/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 10:14:10 +0000</pubDate>
		<dc:creator>Alan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.alanbriolat.co.uk/?p=383</guid>
		<description><![CDATA[It&#8217;s been no real secret that the .NET CLR (Common Language Runtime) has been Microsoft&#8217;s answer to Java. Garbage collection, bytecode compilation, large set of core libraries, it&#8217;s all there. But there is a problem that I&#8217;ve encountered recently: distribution size and install base. A fairly clean Windows XP machine is fairly certain to not [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been no real secret that the .NET CLR (Common Language Runtime) has been Microsoft&#8217;s answer to Java.  Garbage collection, bytecode compilation, large set of core libraries, it&#8217;s all there.  But there is a problem that I&#8217;ve encountered recently: distribution size and install base.</p>
<p>A fairly clean Windows XP machine is fairly certain to not have anything higher than .NET 1.x installed.  Anything really compelling in the .NET framework requires 3.5.  This means somehow you need to get version 3.5 onto the machine somehow.  This isn&#8217;t a problem in Windows Vista and later, which include the framework.   Microsoft&#8217;s answer to simple deployment is it&#8217;s &#8220;ClickOnce&#8221; system, where an application automatically installs .NET from the Internet (if necessary) before installing itself.   Sure, it&#8217;s a 60MB download, but it only needs to be done once.</p>
<p>The real issue is when you can&#8217;t guarantee an Internet connection or a working .NET 3.5 installation.  At this point you must resort to the offline installation, and this is where .NET and Java are very different.  For Java 1.6 SE, the offline installer is 16MB for Windows 32-bit.  For .NET 3.5, the offline installer is a <strong>200MB</strong> universal package, with no way to cut out the parts you don&#8217;t need.  Java in fact is so small relatively speaking that many applications actually include the JRE in their package (for example OpenOffice &#8211; 148MB with JRE vs. 134MB without), whereas .NET can turn a 10MB application into a 210MB monstrosity.</p>
<p>Now in my particular situation, I&#8217;m embarassed to have chosen to use C#/.NET/WPF for a simple tool at work.  For programming the tool itself, it was certainly the fastest option &#8211; other kinds of Windows programming, e.g. MFC or Forms, just look painful, and I thought the barrier to entry would be lower than Java.  However this 1MB tool requires the 200MB .NET offline installer to be carted around with it because the network it&#8217;s used on is completely separate from the Internet.</p>
<p>.NET will only be <em>really</em> appealing once it&#8217;s ubiquitous, but then &#8220;critical mass&#8221; is one of the big problems for lots of software.  For now, I think I&#8217;m going to try Java next time&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alanbriolat.co.uk/2009/06/why-net-wont-beat-java-yet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mouse Button Remapping with HAL</title>
		<link>http://www.alanbriolat.co.uk/2009/06/mouse-button-remapping-with-hal/</link>
		<comments>http://www.alanbriolat.co.uk/2009/06/mouse-button-remapping-with-hal/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 09:02:05 +0000</pubDate>
		<dc:creator>Alan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.alanbriolat.co.uk/?p=365</guid>
		<description><![CDATA[I&#8217;ve had a Logitech MX1000 mouse for a few years now, and the two most important features for me have been the ergonomic build and the few extra buttons. Something I&#8217;ve always found with many-buttoned mice is that the side button closest to the thumb is a much more ergonomic way to &#8220;middle click&#8221; than [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had a Logitech MX1000 mouse for a few years now, and the two most important features for me have been the ergonomic build and the few extra buttons.  Something I&#8217;ve always found with many-buttoned mice is that the side button closest to the thumb is a much more ergonomic way to &#8220;middle click&#8221; than the actual middle mouse button&#8212;it&#8217;s a much more natural motion.  Middle clicks are quite useful these days, especially with them being a standard way of closing tabs (and opening them in browsers), and having such a popular button perched on a rocking and rolling peak is far from ideal.</p>
<p>Since I&#8217;m primarily a Linux user, I don&#8217;t have Logitech&#8217;s own SetPoint software at my disposal, so I&#8217;ve always had to find a way to get this functionality in some other way.  When I first got the mouse, this method involved deliberately using a &#8220;basic&#8221; mouse driver (referred to in xorg.conf as &#8220;IMPS/2&#8243;), which didn&#8217;t support many mouse buttons.  The effect was that the button mappings wrapped around, leaving button 8, my preferred &#8220;middle click&#8221;, mapped to button 2 (8 mod 3), the real middle button.</p>
<p>Unfortunately, newer Xorg versions became smarter and better capable of handling more buttons, and this workaround ceased to function.  For the next while, I used something even more hackish: <a href="http://freshmeat.net/projects/xbindkeys/">xbindkeys</a> combined with <a href="http://xmacro.sourceforge.net/">xmacroplay</a> to simulate a middle click with the following part of my .xbindkeysrc:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">&quot;echo ButtonRelease 8 ButtonPress 2 ButtonRelease 2 | xmacroplay -d 0 :0.0 &amp;&quot;
    b:8</pre></div></div>

<p>The downside to this solution is that there are some cases where the button events don&#8217;t work correctly, one of them being open-in-tab from a bookmark menu in Firefox.  It seemed the best solution would be to get Xorg to remap the buttons in such a way that button 8 really was just an extra button 2.  The &#8220;xinput&#8221; utility lets you set button maps in this way&#8212;<a href="https://wiki.ubuntu.com/X/Config/Input#Example:%20Disabling%20middle-mouse%20button%20paste%20on%20a%20scrollwheel%20mouse">this wiki entry</a> shows how to remap mouse buttons (even if for a different purpose).</p>
<p>This method worked fine, and I put it in my startup programs for GNOME, but it didn&#8217;t persist after suspend/resume.  It appears that when resuming, USB devices get &#8220;reattached&#8221;, and therefore don&#8217;t keep the settings applied to them the last time they were attached.  The workaround for this is to set a policy using a HAL (Hardware Abstraction Layer) .fdi file.  These files live in /etc/hal/fdi/policy (at least they do on Ubuntu) and allow you to set various properties on input devices.  <a href="https://help.ubuntu.com/community/Logitech_Marblemouse_USB">This page on the Ubuntu wiki</a> gave me the recipe I needed to remap buttons based on the device name.  I ended up with the following .fdi file (which I saved at /etc/hal/fdi/policy/logitech-mx1000.fdi):</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;deviceinfo</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- Remap Logitech MX1000 buttons so that the most accessible side button</span>
<span style="color: #808080; font-style: italic;">     acts as a middle button --&gt;</span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;device<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;match</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;info.product&quot;</span> <span style="color: #000066;">string</span>=<span style="color: #ff0000;">&quot;Logitech USB RECEIVER&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;merge</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;input.x11_options.ButtonMapping&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;string&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>1 2 3 4 5 6 7 2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/merge<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/match<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/device<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/deviceinfo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Now, whenever my Logitech mouse is connected, it gets the buttons remapped&#8212;this includes when resuming from suspend.  Problem solved&#8230; until things are changed again of course!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alanbriolat.co.uk/2009/06/mouse-button-remapping-with-hal/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The Rise and Fail of Facebook</title>
		<link>http://www.alanbriolat.co.uk/2009/06/the-rise-and-fail-of-facebook/</link>
		<comments>http://www.alanbriolat.co.uk/2009/06/the-rise-and-fail-of-facebook/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 09:33:18 +0000</pubDate>
		<dc:creator>Alan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://www.alanbriolat.co.uk/?p=362</guid>
		<description><![CDATA[A recent Lifehacker story about a Greasemonkey script to remove quiz stuff from Facebook made me realise something: you know your site is too &#8220;web 2.0&#8243; when users are going out of their way to remove features. A quick search on Userscripts.org reveals that a substantial proportion of the Facebook-related scripts are either for removing [...]]]></description>
			<content:encoded><![CDATA[<p>A recent <a href="http://lifehacker.com/5284511/facebook-purity-removes-eye+gouging-quiz-updates">Lifehacker story</a> about a Greasemonkey script to remove quiz stuff from <a href="http://www.facebook.com/">Facebook</a> made me realise something: <strong>you know your site is too &#8220;web 2.0&#8243; when users are going out of their way to remove features.</strong> A quick <a href="http://userscripts.org/scripts/search?q=facebook&amp;sort=rating">search on Userscripts.org</a> reveals that a substantial proportion of the Facebook-related scripts are either for removing features or auto-playing game applications.</p>
<p>I feel that Facebook started off pretty well.  The initial target audience seemed to be students, and that&#8217;s what most of the users were.  It was friendly and uncluttered, compared to other social networking sites like MySpace.  This spread to a wider audience, first sucking in kids and then adults.  This was less than ideal for some, the idea of their parents on a social networking site being horrifying, but still not a disaster.</p>
<p>But in the midst of all this, the apocalypse happened: a powerful API which allowed other people to extend the functionality of Facebook by creating applications that people could add to their account.  Gradually  users became innundated with an unstoppable torrent of application requests, caused by application developers making the &#8220;tell all your friends&#8221; step seem (or be) necessary to using their application.  The average user&#8217;s profile became a mess of applications competing for screen space.  The target audience became those who have the time to play endless Flash games, answer endless quizzes, and generally clutter the &#8220;requests&#8221; page of their friends.</p>
<p>And so Facebook became <a href="http://myspace.com/">MySpace</a> 2.0&#8212;gaudy and cluttered, with infinite ability to add more clutter.  Maybe the lesson learned is that the moment you allow anything &#8220;shiny&#8221; in a social networking site, your demographic will degenerate to schoolkids who want to fill their profiles with as much of it as possible.</p>
<p>Personally, I&#8217;ve reduced my Facebook interaction for the past 2 years to having the site email me when anybody says something directly to me either via message or on my &#8220;wall&#8221;.  There is just too much clutter now for me to wade through the endless application requests, friend requests from people I don&#8217;t know, and news feed items generated by the latest viral quiz.  And maybe pictures of friends getting drunk have lost their novelty value&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alanbriolat.co.uk/2009/06/the-rise-and-fail-of-facebook/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Spectacular IE7 CSS box model failure</title>
		<link>http://www.alanbriolat.co.uk/2009/05/spectacular-ie7-css-box-model-failure/</link>
		<comments>http://www.alanbriolat.co.uk/2009/05/spectacular-ie7-css-box-model-failure/#comments</comments>
		<pubDate>Sun, 17 May 2009 16:31:54 +0000</pubDate>
		<dc:creator>Alan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://www.alanbriolat.co.uk/?p=353</guid>
		<description><![CDATA[When re-theming DokuWiki to fit in with the general look-and-feel of this blog, I thought it would look good to have buttons with images relevant to what they did. Having created the necessary, CSS, I subjected it to my multi-browser test bed (actually a Windows XP virtual machine with the latest versions of the top [...]]]></description>
			<content:encoded><![CDATA[<p>When re-theming DokuWiki to fit in with the general look-and-feel of this blog, I thought it would look good to have buttons with images relevant to what they did.  Having created the necessary, CSS, I subjected it to my <a href="http://iris.codescape.net/~alan/IE-rendering-fail-3.png" rel="lightbox[353]">multi-browser test bed</a> (actually a Windows XP virtual machine with the latest versions of the top 5 browsers running in it).  The CSS I used was along the lines of this:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #6666ff;">.dokuwiki</span> form<span style="color: #6666ff;">.btn_show</span> <span style="color: #6666ff;">.button</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">16px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">transparent</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">images/page.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #933;">0px</span> <span style="color: #933;">1px</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>One thing that became apparent is that IE7 has absolutely no idea how to render this.  The correct rendering (as produced by Firefox 3 and all the other browsers) is this:</p>
<p style="text-align: center;"><a href="http://www.alanbriolat.co.uk/wp-content/uploads/2009/05/button-background-image-ff3.png" rel="lightbox[353]"><img class="size-full wp-image-354 aligncenter" title="button-background-image-ff3" src="http://www.alanbriolat.co.uk/wp-content/uploads/2009/05/button-background-image-ff3.png" alt="button-background-image-ff3" width="243" height="31" /></a></p>
<p>IE7&#8242;s take on rendering this looked more like this:</p>
<p style="text-align: center;"><a href="http://www.alanbriolat.co.uk/wp-content/uploads/2009/05/button-background-image-ie7.png" rel="lightbox[353]"><img class="size-full wp-image-355 aligncenter" title="button-background-image-ie7" src="http://www.alanbriolat.co.uk/wp-content/uploads/2009/05/button-background-image-ie7.png" alt="button-background-image-ie7" width="317" height="41" /></a></p>
<p>After a bit more experimentation, I came up with the following illustration which roughly shows what is happening:</p>
<p style="text-align: center;"><a href="http://iris.codescape.net/~alan/IE7-button-rendering.png" rel="lightbox[353]"><img class="aligncenter" title="IE7 button rendering" src="http://iris.codescape.net/~alan/IE7-button-rendering.png" alt="" width="361" height="155" /></a></p>
<p>The nice thing is that this is fixed in the upcoming IE8, so I&#8217;ve taken the stress-free approach; since it&#8217;s a relatively &#8220;minor&#8221; visual bug, there&#8217;s no sense it tearing my hair out trying to make it render correctly everywhere.  On this occasion I&#8217;ve decided that people can either deal with the fact their browser is behind the times, or upgrade, or wait for the upgrade to happen for them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alanbriolat.co.uk/2009/05/spectacular-ie7-css-box-model-failure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick and dirty screen scraping of UK MP expenses data</title>
		<link>http://www.alanbriolat.co.uk/2009/05/quick-and-dirty-screen-scraping-of-uk-mp-expenses-data/</link>
		<comments>http://www.alanbriolat.co.uk/2009/05/quick-and-dirty-screen-scraping-of-uk-mp-expenses-data/#comments</comments>
		<pubDate>Wed, 13 May 2009 21:41:56 +0000</pubDate>
		<dc:creator>Alan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[politics]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.alanbriolat.co.uk/?p=340</guid>
		<description><![CDATA[A dominating story in the news recently has been that of UK Members of Parliament &#8220;abusing&#8221; the expenses system. As part of this, expense claims data has been released to the public, but unsurprisingly not in a simple CSV format that just anybody can play with. All I could find were PDF files and news [...]]]></description>
			<content:encoded><![CDATA[<p>A dominating story in the news recently has been that of UK Members of Parliament &#8220;abusing&#8221; the expenses system.  As part of this, expense claims data has been released to the public, but unsurprisingly not in a simple CSV format that just anybody can play with.  All I could find were PDF files and news sites representing the data in their own way.</p>
<p>This led me to wonder how easy it would be to &#8220;scrape&#8221; the data from one of these sites.  Having heard about <a href="http://www.crummy.com/software/BeautifulSoup/">BeautifulSoup</a>, a Python HTML &#8220;tag soup&#8221; parser, I opened up an interactive Python session and started to play with the data from <a href="http://news.bbc.co.uk/1/hi/uk_politics/8044207.stm">this BBC News page</a>.  Luckily for me, the BBC page&#8217;s HTML isn&#8217;t <em>too</em> ugly, so figuring out how to get the data rows wasn&#8217;t that hard.</p>
<p>The end result is the following Python script which scrapes the data from the BBC News page and saves it in both CSV and JSON formats.</p>
Note: There is a file embedded within this post, please visit this post to download the file.
]]></content:encoded>
			<wfw:commentRss>http://www.alanbriolat.co.uk/2009/05/quick-and-dirty-screen-scraping-of-uk-mp-expenses-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mozilla/1.22 (compatible; MSIE 2.0; Windows 95)</title>
		<link>http://www.alanbriolat.co.uk/2009/05/mozilla122-compatible-msie-20-windows-95/</link>
		<comments>http://www.alanbriolat.co.uk/2009/05/mozilla122-compatible-msie-20-windows-95/#comments</comments>
		<pubDate>Mon, 11 May 2009 09:46:24 +0000</pubDate>
		<dc:creator>Alan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.alanbriolat.co.uk/?p=333</guid>
		<description><![CDATA[Browsing the visitor stats today, I found this little gem: &#8220;Mozilla/1.22 (compatible; MSIE 2.0; Windows 95)&#8221;?  Who uses such a browser?  My bet is on it being a zombie machine that somebody has completely forgotten about, which would explain the several other hits I have from versions of IE before 5.0&#8230;  These visitors turn up, [...]]]></description>
			<content:encoded><![CDATA[<p>Browsing the visitor stats today, I found this little gem:</p>
<p><a href="http://www.alanbriolat.co.uk/wp-content/uploads/2009/05/ancient-browser1.png" rel="lightbox[333]"><img class="alignnone size-full wp-image-337" title="Ancient browser user agent" src="http://www.alanbriolat.co.uk/wp-content/uploads/2009/05/ancient-browser1.png" alt="Ancient browser user agent" width="592" height="255" /></a></p>
<p>&#8220;Mozilla/1.22 (compatible; MSIE 2.0; Windows 95)&#8221;?  Who uses such a browser?  My bet is on it being a zombie machine that somebody has completely forgotten about, which would explain the several other hits I have from versions of IE before 5.0&#8230;  These visitors turn up, hit the same page repeatedly, and then leave.  Unfortunately I deleted my spam before seeing this, otherwise I&#8217;d be able to verify this theory.  Maybe I&#8217;ll look more closely next time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alanbriolat.co.uk/2009/05/mozilla122-compatible-msie-20-windows-95/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
