<?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>biotext.org.uk &#187; Tips</title>
	<atom:link href="http://biotext.org.uk/category/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://biotext.org.uk</link>
	<description>Not a typewriter</description>
	<lastBuildDate>Mon, 06 Sep 2010 12:44:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Posting to Twitter automatically using OAuth</title>
		<link>http://biotext.org.uk/posting-to-twitter-automatically-using-oauth/</link>
		<comments>http://biotext.org.uk/posting-to-twitter-automatically-using-oauth/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 12:44:30 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=502</guid>
		<description><![CDATA[Twitter recently switched off basic HTTP authentication, forcing developers to use the more complex (but hopefully safer) OAuth. There are lots of OAuth examples out there, but they all seem to focus on interactive apps, where the user is sent to Twitter to authenticate, and then the app uses the resulting access token to post [...]]]></description>
			<content:encoded><![CDATA[<p>Twitter <a href="http://blog.twitter.com/2010/06/switching-to-oauth.html">recently switched off basic HTTP authentication</a>, forcing developers to use the more complex (but hopefully safer) OAuth. There are lots of OAuth examples out there, but they all seem to focus on interactive apps, where the user is sent to Twitter to authenticate, and then the app uses the resulting <strong>access token</strong> to post on the user&#8217;s behalf.</p>
<p>However, for <a href="http://funcnet.eu/">FuncNet</a> we have a simple script running in a cron job, which posts a status message to <a href="http://twitter.com/FuncNet">@FuncNet</a> every so often. This runs without any supervision, so I was left scratching my head as to how I could obtain the access token and <strong>access token secret</strong> required to post. The app registration page at http://twitter.com/oauth_clients/details/<em>NNNNNN</em> for each app only shows its <strong>consumer key</strong> and <strong>consumer secret</strong> which are something different.</p>
<p>Eventually, thanks to <a href="http://search.cpan.org/dist/Net-Twitter/">Net::Twitter</a> developer Marc Mims on <a href="http://groups.google.com/group/twitter-development-talk/browse_thread/thread/160cb4d3f20ef61">this thread</a>, I discovered that there&#8217;s a whole separate page for each app at http://dev.twitter.com/apps/<em>NNNNNN</em>/my_token which has the access token and access token secret required for the app to post to its own account.</p>
<p>Once you have these, you can post like this (thanks again to Marc for example):</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">use</span> Net<span style="color: #339933;">::</span><span style="color: #006600;">Twitter</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$nt</span> <span style="color: #339933;">=</span> Net<span style="color: #339933;">::</span><span style="color: #006600;">Twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span>
        traits <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#91;</span><span style="color: #000066;">qw</span><span style="color: #339933;">/</span>OAuth API<span style="color: #339933;">::</span><span style="color: #006600;">REST</span><span style="color: #339933;">/</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        consumer_key        <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$YOUR_CONSUMER_KEY</span><span style="color: #339933;">,</span>
        consumer_secret     <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$YOUR_CONSUMER_SECRET</span><span style="color: #339933;">,</span>
        access_token        <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$YOUR_ACCESS_TOKEN</span><span style="color: #339933;">,</span>
        access_token_secret <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$YOUR_ACCESS_SECRET</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #0000ff;">$nt</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">update</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Bob's your uncle!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Why you need 4 distinct incomprehensible strings in order to post a single tweet, I don&#8217;t know, but presumably it&#8217;s justified on security grounds. What <em>isn&#8217;t</em> justified is Twitter hiding two of them somewhere else entirely, and not linking to that place from the main OAuth page for the app.</p>
<p>Not useful, guys.</p>
<p>N.B. In the URLs above, <em>NNNNNN</em> corresponds to the numeric ID for your application. If you don&#8217;t know what this is, just go to http://dev.twitter.com/apps, click on the app name to get the consumer strings, and then click on My Access Token to get the access strings.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/posting-to-twitter-automatically-using-oauth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Spotify on Fedora 13</title>
		<link>http://biotext.org.uk/installing-spotify-on-fedora-13/</link>
		<comments>http://biotext.org.uk/installing-spotify-on-fedora-13/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 11:52:55 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[spotify]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=496</guid>
		<description><![CDATA[I&#8217;ve recently taken possession of a flashy new workstation running Fedora, and with joy in my heart went to install Spotify on it, only to discover&#8230; Noooo&#8230; They only offer .deb packages for Debian and Ubuntu.
Thankfully, the solution was easier than I thought. Do all the following as root&#8230;
1. Install dpkg, the Debian package management [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently taken possession of a flashy new workstation running Fedora, and with joy in my heart went to install <a href="http://www.spotify.com/uk/download/previews/">Spotify</a> on it, only to discover&#8230; Noooo&#8230; They only offer .deb packages for Debian and Ubuntu.</p>
<p>Thankfully, the solution was easier than I thought. Do all the following as root&#8230;</p>
<p>1. Install dpkg, the Debian package management tool:</p>
<p><code>yum install dpkg</code></p>
<p>2. Download the base package for your architecture, and the gnome support package, from here:</p>
<p><a href="http://repository.spotify.com/pool/non-free/s/spotify/">http://repository.spotify.com/pool/non-free/s/spotify/</a></p>
<p>3. Create a temp directory, and unpack them there (we want to check for clashes):</p>
<p><code>mkdir spotify<br />
cd spotify<br />
dpkg -x ../spotify-client-qt_0.4.7.132.g9df34c0-1_amd64.deb .<br />
dpkg -x ../spotify-client-gnome-support_0.4.7.132.g9df34c0-1_all.deb .</code></p>
<p>4. This gives you a directory tree starting at <code>/usr</code>. You can check for clashes like this:</p>
<p><code>find -not -type d -exec ls -l /'{}' \;</code></p>
<p>&#8230; and make sure there&#8217;s no files found.</p>
<p>5. Then re-extract them into your root partition (hence checking for clashes first):</p>
<p><code>dpkg -x ../spotify-client-qt_0.4.7.132.g9df34c0-1_amd64.deb /<br />
dpkg -x ../spotify-client-gnome-support_0.4.7.132.g9df34c0-1_all.deb /</code></p>
<p>6. Finally, we need to manually install qt-x11 as this dependency is needed:</p>
<p><code>yum install qt-x11</code></p>
<p>7. Then just type <code>spotify</code> and log in!</p>
<p>Seems pretty stable so far, apart from a couple of minor glitches.</p>
<p><strong>EDIT:</strong> As suggested by Tyson Key in <a href="http://getsatisfaction.com/spotify/topics/spotify_on_fedora_13_audio_skips">this thread</a>, I got rid of the audio glitches by starting the PulseAudio volume control (<code>/usr/bin/pavucontrol</code>) before Spotify. Maybe this adds some buffering or something.</p>
<p><em>N.B. I take no responsibility if this process damages your computer, your music collection, your hearing or your sanity. Try at your own risk <img src='http://biotext.org.uk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </em></p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/installing-spotify-on-fedora-13/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tunnelling a connection through 2 servers via ssh</title>
		<link>http://biotext.org.uk/tunnelling-a-connection-through-2-servers-via-ssh/</link>
		<comments>http://biotext.org.uk/tunnelling-a-connection-through-2-servers-via-ssh/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 19:19:28 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=490</guid>
		<description><![CDATA[This took a bit of head-scratching, so for future reference, or anyone else looking:
Say I am working outside the office firewall, on a machine called home, and I need to get into a MySQL server inside it. (Doesn&#8217;t have to be MySQL, but just for argument&#8217;s sake.)
There&#8217;s a machine called gateway I can ssh to [...]]]></description>
			<content:encoded><![CDATA[<p>This took a bit of head-scratching, so for future reference, or anyone else looking:</p>
<p>Say I am working outside the office firewall, on a machine called <code>home</code>, and I need to get into a MySQL server inside it. (Doesn&#8217;t have to be MySQL, but just for argument&#8217;s sake.)</p>
<p>There&#8217;s a machine called <code>gateway</code> I can ssh to and tunnel through, but for security reasons, the database server <code>mysql</code> doesn&#8217;t accept connections from <code>gateway</code> directly. But my desktop machine at the office (err&#8230; <code>desktop</code>) can connect to <code>mysql</code>.</p>
<p>One way round it is to ssh from <code>home</code> to <code>gateway</code> and forward a port on <code>gateway</code> to the ssh server on <code>desktop</code>:</p>
<pre>
home $ ssh -L 2222:desktop.example.org:22 -tAY gateway.example.org
</pre>
<p>And then in another terminal, ssh from <code>home</code> to <code>desktop</code> via this tunnel, forwarding another port on <code>home</code> to the incoming connections port on <code>mysql</code> (3306 in MySQL&#8217;s case usually):</p>
<pre>
home $ ssh -p 2222 -L 23306:mysql.example.org:3306 127.0.0.1
</pre>
<p>This time, you&#8217;re connecting to <code>home</code> port 2222, but because of the first command, this forwards you straight to <code>desktop</code> port 22.</p>
<p>Now both tunnels are in place, you can just connect to port 23306 on <code>home</code> and arrive by magic at <code>mysql</code>. In another terminal (or from your MySQL GUI):</p>
<pre>
home $ mysql -uUSER -pPASS -h127.0.0.1 -P23306
</pre>
<p>This example shows a tunnel-within-a-tunnel. There should be a way to make this work using end-to-end tunnelling instead, I tried but didn&#8217;t get anywhere. But that might be due to ssh server restrictions on our equivalent of <code>gateway</code>.</p>
<p>If none of this means anything, there&#8217;s an <a href="http://magazine.redhat.com/2007/11/06/ssh-port-forwarding/">intro to ssh port forwarding here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/tunnelling-a-connection-through-2-servers-via-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Best new feature in Eclipse 3.6 Helios</title>
		<link>http://biotext.org.uk/best-new-feature-in-eclipse-3-6-helios/</link>
		<comments>http://biotext.org.uk/best-new-feature-in-eclipse-3-6-helios/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 13:20:44 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[LJC]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=487</guid>
		<description><![CDATA[&#8230; is hidden away on the last tab of the Java Formatting Profile editor (Preferences -> Java -> Code Style -> Formatter -> Edit).
They&#8217;ve finally (after nearly six years) added the ability to temporarily turn the code formatter off for a tricksy block that needs its own custom formatting. e.g.:

			// @formatter:off
			xml
			.append&#40; &#34;&#60;node id='&#34; &#41;
			.append&#40; protein [...]]]></description>
			<content:encoded><![CDATA[<p>&#8230; is hidden away on the last tab of the Java Formatting Profile editor (Preferences -> Java -> Code Style -> Formatter -> Edit).</p>
<p>They&#8217;ve finally (after <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=76435">nearly six years</a>) added the ability to temporarily turn the code formatter off for a tricksy block that needs its own custom formatting. e.g.:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">			<span style="color: #666666; font-style: italic;">// @formatter:off</span>
			xml
			.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;&lt;node id='&quot;</span> <span style="color: #009900;">&#41;</span>
			.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span> protein <span style="color: #009900;">&#41;</span>
			.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;'&gt;&lt;data key='class'&gt;&quot;</span> <span style="color: #009900;">&#41;</span>
			.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span> cls <span style="color: #009900;">&#41;</span>
			.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;&lt;/data&gt;&lt;data key='label'&gt;&quot;</span> <span style="color: #009900;">&#41;</span>
			.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span> protein <span style="color: #009900;">&#41;</span>
			.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;&lt;/data&gt;&lt;/node&gt;&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// @formatter:on</span></pre></div></div>

<p>See the Off/On Tags tab for details.</p>
<p>Nice one guys&#8230; Eventually.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/best-new-feature-in-eclipse-3-6-helios/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Back up all MySQL databases to separate files</title>
		<link>http://biotext.org.uk/back-up-all-mysql-databases-to-separate-files/</link>
		<comments>http://biotext.org.uk/back-up-all-mysql-databases-to-separate-files/#comments</comments>
		<pubDate>Thu, 13 May 2010 12:24:47 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=463</guid>
		<description><![CDATA[Note to self &#8212; so I don&#8217;t have to think about it again next time.

#!/bin/bash
export MYSQL_PWD=myrootpassword
BACKUP_DIR=/mnt/backups/mysql_backups
DATE=`date -I`
for dbname in `mysql -uroot --batch --skip-column-names -e &#34;show databases;&#34; &#124; grep -v information_schema`; do
	/usr/local/bin/mysqldump -u root $dbname &#124; gzip -9 &#62; $BACKUP_DIR/$dbname-$DATE.sql.gz
done
&#160;
# Clear backups older than 7 days
/usr/local/bin/find $BACKUP_DIR/*.sql.gz -mtime +7 -delete

Edited to include compression. Remember to include [...]]]></description>
			<content:encoded><![CDATA[<p>Note to self &#8212; so I don&#8217;t have to think about it again next time.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">MYSQL_PWD</span>=myrootpassword
<span style="color: #007800;">BACKUP_DIR</span>=<span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>backups<span style="color: #000000; font-weight: bold;">/</span>mysql_backups
<span style="color: #007800;">DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> -I<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">for</span> dbname <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>mysql <span style="color: #660033;">-uroot</span> <span style="color: #660033;">--batch</span> <span style="color: #660033;">--skip-column-names</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;show databases;&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> information_schema<span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysqldump <span style="color: #660033;">-u</span> root <span style="color: #007800;">$dbname</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #660033;">-9</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$BACKUP_DIR</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$dbname</span>-<span style="color: #007800;">$DATE</span>.sql.gz
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Clear backups older than 7 days</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #007800;">$BACKUP_DIR</span><span style="color: #000000; font-weight: bold;">/*</span>.sql.gz <span style="color: #660033;">-mtime</span> +<span style="color: #000000;">7</span> <span style="color: #660033;">-delete</span></pre></div></div>

<p>Edited to include compression. Remember to include full paths if you&#8217;re running it from a crontab, just in case.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/back-up-all-mysql-databases-to-separate-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Chrome (actually Chromium) on Centos</title>
		<link>http://biotext.org.uk/google-chrome-actually-chromium-on-centos/</link>
		<comments>http://biotext.org.uk/google-chrome-actually-chromium-on-centos/#comments</comments>
		<pubDate>Wed, 12 May 2010 13:25:19 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=461</guid>
		<description><![CDATA[Joy at last!
Chris Staite from the University of Birmingham has built a statically-linked version of Chromium, the open source version of Google&#8217;s Chrome browser, for Centos.
You can get it from here.
I was getting so sick of Firefox&#8217;s slowness and bloat, and Chromium is so much snappier, and more memory-efficient too.
Although to be fair, I don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Joy at last!</p>
<p>Chris Staite from the University of Birmingham has built a statically-linked version of Chromium, the open source version of Google&#8217;s Chrome browser, for Centos.</p>
<p>You can <a href="http://www.cs.bham.ac.uk/~cxs548/chrome">get it from here</a>.</p>
<p>I was getting so sick of Firefox&#8217;s slowness and bloat, and Chromium is so much snappier, and more memory-efficient too.</p>
<p>Although to be fair, I don&#8217;t have nearly so many extensions installed yet&#8230;</p>
<p>It should just work out of the box with no extra dependencies to install. I&#8217;m using 64-bit Centos 5.4, and although it&#8217;s a 32-bit app, it seems entirely happy so far.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/google-chrome-actually-chromium-on-centos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Things to try when VirtualBox networking messes up</title>
		<link>http://biotext.org.uk/things-to-try-when-virtualbox-networking-messes-up/</link>
		<comments>http://biotext.org.uk/things-to-try-when-virtualbox-networking-messes-up/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 09:52:40 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[VirtualBox]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=447</guid>
		<description><![CDATA[This is really a note-to-self but it might help other people too.
I have two network interfaces in my Ubuntu guest (on OS X 10.4 host), one NAT, one host-only.
Sometimes one of them doesn&#8217;t get an IP address &#8212; in ifconfig it has an inet6 address but not an inet address.
Today I tried
sudo dhclient eth1
and it [...]]]></description>
			<content:encoded><![CDATA[<p>This is really a note-to-self but it might help other people too.</p>
<p>I have two network interfaces in my Ubuntu guest (on OS X 10.4 host), one NAT, one host-only.</p>
<p>Sometimes one of them doesn&#8217;t get an IP address &#8212; in ifconfig it has an inet6 address but not an inet address.</p>
<p>Today I tried</p>
<p><code>sudo dhclient eth1</code></p>
<p>and it worked &#8212; all it needed to do was re-query VirtualBox&#8217;s built-in DHCP server.</p>
<p>I would have thought this would do that automatically:</p>
<p><code>sudo /etc/init.d/networking restart</code></p>
<p>However that didn&#8217;t help&#8230; But dhclient did.</p>
<p>Another recurring problem is that when I move between different networks, DNS resolution gets screwed up. There&#8217;s a description of this with a suggested work around (using VBox&#8217;s DNS Proxy) here:</p>
<p>http://forums.virtualbox.org/viewtopic.php?f=1&#038;t=28332</p>
<p>However, while this seemed to help with two of the networks I use frequently, it didn&#8217;t with a third, even after rebooting.</p>
<p>So, as suggested on one or two threads, I&#8217;ve removed the DNSProxy setting, and set the Ubuntu guest to use Google&#8217;s public DNS servers instead of those provided by the DHCP server for the NATted virtual NIC. (Blah blah blah.) Follow example here (more or less):</p>
<p><a href="http://grumpymole.posterous.com/how-to-use-google-public-dns-or-opendns-in-ub">http://grumpymole.posterous.com/how-to-use-google-public-dns-or-opendns-in-ub</a></p>
<p>Seems to be working so far&#8230; But only tested on one of the offending networks, and without rebooting yet. Updates to come later.</p>
<p>&#8230; Nope, after upgrading to Snow Leopard and the latest VirtualBox (it&#8217;s now from Oracle &#8212; scary), random problems persist.</p>
<p>Sometimes I&#8217;ll lose guest-host connectivity in the middle of a session, without any sleep or other interruptions, but will still be able to see the internet from the NAT adaptor.</p>
<p>One possible solution here involving using OS X itself as the NAT router:</p>
<p><a href="http://akutz.wordpress.com/2009/08/20/building-a-better-os-x-firewall-or-how-i-solved-the-nat-problem-for-virtualbox/">http://akutz.wordpress.com/2009/08/20/building-a-better-os-x-firewall-or-how-i-solved-the-nat-problem-for-virtualbox/</a></p>
<p>&#8230; but it&#8217;ll take work.</p>
<p>Or maybe a simpler version of the same approach: have a single host-only adaptor, use OS X&#8217;s internet sharing to share the AirPort card, and manually tell the vbox to use 192.168.56.1 as the default gateway:</p>
<p><a href="http://forum.virtualbox.org/viewtopic.php?f=1&#038;t=26544">http://forum.virtualbox.org/viewtopic.php?f=1&#038;t=26544</a></p>
<p>If all else fails, try using a different ethernet hardware emulator.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/things-to-try-when-virtualbox-networking-messes-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NoSuchMethodError when running JUnit tests in Eclipse</title>
		<link>http://biotext.org.uk/nosuchmethoderror-when-running-junit-tests-in-eclipse/</link>
		<comments>http://biotext.org.uk/nosuchmethoderror-when-running-junit-tests-in-eclipse/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 12:25:49 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[LJC]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=439</guid>
		<description><![CDATA[This is worth a quick post as I couldn&#8217;t find a solution on Google and it took me an hour or two of fiddling.
I have a Maven project, call it frontend-war, which contains the main service code for FuncNet. A unit test kept failing in Eclipse with NoSuchMethodError, one of my least favourite screw-ups to [...]]]></description>
			<content:encoded><![CDATA[<p>This is worth a quick post as I couldn&#8217;t find a solution on Google and it took me an hour or two of fiddling.</p>
<p>I have a Maven project, call it <code>frontend-war</code>, which contains the main service code for <a href="http://funcnet.eu/">FuncNet</a>. A unit test kept failing in Eclipse with <code>NoSuchMethodError</code>, one of my least favourite screw-ups to disentangle.</p>
<p>In this case it was particularly frustrating, as the method (on a class in one of the main project&#8217;s dependent jars, called <code>service-utils</code>) definitely existed, was public, and had the right signature. Also, even more weirdly, when I ran the tests in Maven from the command line, they passed.</p>
<p>Cue all the usual Eclipse cargo-cult dead-chicken-waving &#8212; cleaning everything, closing and reopening projects, etc. etc. No joy.</p>
<p>Then it hit me&#8230; (solution below the jump)</p>
<p><span id="more-439"></span><br />
One of the other jars included by <code>frontend-war</code>, called <code>sessionDB</code>, <em>also</em> included <code>service-utils</code> &#8212; and was using an out-of-date version. This version didn&#8217;t include the method I was calling (at least not with that signature). The dependency hierarchy looked something like:</p>
<p><code>frontend-war-CURRENT</code><br />
&nbsp;&nbsp;&nbsp;&nbsp;<code>service-utils-1.2.9</code><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8230;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<code>sessionDB-1.3.3</code><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>service-utils-1.2.4</code><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8230;</p>
<p>So I rebuilt <code>sessionDB</code> against the latest version of <code>service-utils</code>, then rebuilt <code>frontend-war</code> against that, and it worked.</p>
<p>So, my fault for getting myself into <a href="http://en.wikipedia.org/wiki/Java_Classloader#JAR_hell">jar hell</a>, although even if you don&#8217;t bring it on yourself, it&#8217;s hard to avoid it if you use a lot of open-source components, and Maven &#8212; which I still argue is a timesaver overall &#8212; tends to exacerbate it. Take a look at the Dependency Graph view in Eclipse&#8217;s POM Editor sometime &#8212; if you see any red arrows, that means two or more different versions of a dependency are being requested by different modules within your project.</p>
<p>So why did it work on the command line and not in Eclipse? To be honest, I don&#8217;t know in detail. But in cases like this, the classloader will (AFAIK) just pull in whichever version is requested first, so Eclipse&#8217;s classpath management must have happened to process the dependencies in a different order from Maven&#8217;s &#8212; meaning it worked by pure luck.</p>
<p><strong>Note:</strong> My solution &#8212; updating <code>sessionDB</code> to use the latest <code>service-utils</code> &#8212; wasn&#8217;t a problem, because all three of the modules in the unholy <i>ménage à trois</i> belonged to me. But what do you do if two third-party libraries request different versions of the same jar?</p>
<p>A <del datetime="2010-03-17T11:50:48+00:00">famous</del> notorious example of this tends to happen with <a href="https://www.hibernate.org/">Hibernate</a>, which depends on a really out-of-date version of <a href="http://asm.ow2.org/">ASM</a> &#8212; or at least it used to, I haven&#8217;t checked recently. Lots of open-source projects use ASM but more recent versions clash nastily with the old one Hibernate requires.</p>
<p>The <a href="http://blog.springsource.com/2007/06/11/asm-version-incompatibilities-using-spring-autowired-with-hibernate/">solution in this case</a> is to use Maven&#8217;s exclusions clause to specifically exclude ASM from Hibernate&#8217;s transitive dependencies. Thankfully it can just use the more recent versions without problems.</p>
<p>But what would you do if one of the libraries you were using depended on a method that was <em>no longer available</em> in a more recent jar? Then you&#8217;re really in jar hell. Answers on a postcard&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/nosuchmethoderror-when-running-junit-tests-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to make sure your media disk is mounted before starting iTunes</title>
		<link>http://biotext.org.uk/how-to-make-sure-your-media-disk-is-mounted-before-starting-itunes/</link>
		<comments>http://biotext.org.uk/how-to-make-sure-your-media-disk-is-mounted-before-starting-itunes/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 22:25:35 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=427</guid>
		<description><![CDATA[This is an Apple Annoyance that&#8217;s been bugging me for a while &#8212; if your iTunes library is on an external HD, and you start iTunes without it mounted, the bloody thing can seriously mangle its own library index (under Tiger at least).
So I&#8217;ve replaced my iTunes Dock icon with a little AppleScript that checks [...]]]></description>
			<content:encoded><![CDATA[<p>This is an Apple Annoyance that&#8217;s been bugging me for a while &#8212; if your iTunes library is on an external HD, and you start iTunes without it mounted, the bloody thing can seriously mangle its own library index (under Tiger at least).</p>
<p>So I&#8217;ve replaced my iTunes Dock icon with a little AppleScript that checks whether said disk is mounted first:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Finder&quot;</span>
	<span style="color: #ff0033; font-weight: bold;">if</span> <span style="color: #0066ff;">exists</span> <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">disk</span> <span style="color: #009900;">&quot;LaCie&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #ff0033; font-weight: bold;">then</span>
		<span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;iTunes&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">activate</span>
	<span style="color: #ff0033; font-weight: bold;">else</span>
		<span style="color: #0066ff;">display dialog</span> <span style="color: #009900;">&quot;Don't start iTunes without LaCie external disk mounted.&quot;</span> <span style="color: #0066ff;">buttons</span> <span style="color: #000000;">&#123;</span><span style="color: #009900;">&quot;OK&quot;</span><span style="color: #000000;">&#125;</span> default button <span style="color: #000000;">1</span> <span style="color: #ff0033; font-weight: bold;">with</span> title <span style="color: #009900;">&quot;Cannot start iTunes&quot;</span> <span style="color: #ff0033; font-weight: bold;">with</span> icon stop
	<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">if</span>
<span style="color: #ff0033; font-weight: bold;">end</span> <span style="color: #ff0033; font-weight: bold;">tell</span></pre></td></tr></table></div>

<p>Compile, save as script, add to dock, bingo. (Obviously, replace <code>LaCie</code> with the name of your external HD, as it appears in <code>/Volumes</code> when mounted.)</p>
<p>For extra points, you can give it iTunes&#8217; icon too. Just get Info on iTunes and select the little icon in the top left (not the big one under Preview). Then just cmd-c, select the same icon in the script&#8217;s info window, and cmd-v.</p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/how-to-make-sure-your-media-disk-is-mounted-before-starting-itunes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MacBook keyboard hacks for # (hash/pound/numbersign)</title>
		<link>http://biotext.org.uk/macbook-keyboard-hacks-for-hash-pound-numbersign/</link>
		<comments>http://biotext.org.uk/macbook-keyboard-hacks-for-hash-pound-numbersign/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 14:32:09 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<category><![CDATA[X11]]></category>

		<guid isPermaLink="false">http://biotext.org.uk/?p=412</guid>
		<description><![CDATA[One of the few annoying things about my oldish MacBook Pro is its keyboard, for example a few unresponsive keys, but particularly the lack of a # key. It&#8217;s a UK keyboard, and has £ for shift-3, and # is hidden in alt-3 (not labelled).
This is fine in native desktop apps, but less fine in [...]]]></description>
			<content:encoded><![CDATA[<p>One of the few annoying things about my oldish MacBook Pro is its keyboard, for example a few unresponsive keys, but particularly the lack of a # key. It&#8217;s a UK keyboard, and has £ for shift-3, and # is hidden in alt-3 (not labelled).</p>
<p>This is fine in native desktop apps, but less fine in some text-mode programs (e.g. vim), when for some reason this often produces a superscript <sup>3</sup> instead.</p>
<p>So I&#8217;ve set up a custom keyboard mapping in iTerm to map F3 to #, which works nicely. <strong>However!</strong></p>
<p>If I&#8217;m SSHed in to a remote Linux machine (or even my local Ubuntu VirtualBox) neither of these keys work in X apps. But, xmodmap (via the config file ~/.Xmodmap) can help. For some reason, Macs all have a dedicated key for these characters &#8212; § and ± &#8212; which <em>no-one</em> ever uses. But with this line in ~/.Xmodmap we can remap it to produce #:</p>
<p>keycode 18=numbersign</p>
<p><strong>UPDATE:</strong> I&#8217;ve found a better way which works pretty much globally&#8230;</p>
<p>Using <a href="http://scripts.sil.org/Ukelele">Ukelele</a> you can copy the British keyboard layout and then remap keys to your heart&#8217;s content. I&#8217;ve moved the § character to the alt-§ key combination, in case I ever need it, and moved the # character to the raw § key. This seems to be respected <em>almost</em> everywhere so I don&#8217;t need to mess around with alt-3 or F3 any more. Joy. It also works over <a href="http://www.jinx.de/JollysFastVNC.html">JollysFastVNC</a> to a remote RealVNC server, which none of the other methods did.</p>
<p>Unfortunately, things still aren&#8217;t perfect. If I actually open a VirtualBox console session into GNOME on the local Ubuntu VM, the pointless § and ± key actually produces &lt; and &gt; so neither of these tricks work. In fact, I can&#8217;t get anything to generate a # even though I have the MacBook Pro Intl keyboard layout selected in GNOME. Any ideas?</p>
<p><strong>UPDATE 2:</strong> YES!! I&#8217;ve finally cracked it for VirtualBox. With the help of the xkeycaps command, I discovered that X the keycodes coming into Ubuntu weren&#8217;t what I thought they were &#8212; somewhere the Mac-ness of the keyboard layout was getting lost. It turned out that the § key was generating keycode 94 instead. So I set up this in .Xmodmap on the Ubuntu VM:</p>
<p>keycode 94=numbersign</p>
<p>Now it works in VirtualBox too. Leave gifts of thanks below <img src='http://biotext.org.uk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://biotext.org.uk/macbook-keyboard-hacks-for-hash-pound-numbersign/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
