<?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>Allan McRae &#187; Software</title>
	<atom:link href="http://allanmcrae.com/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://allanmcrae.com</link>
	<description>One day this will feature a witty tagline…</description>
	<lastBuildDate>Thu, 26 Jan 2012 10:31:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MBP Fan Daemon Update</title>
		<link>http://allanmcrae.com/2011/08/mbp-fan-daemon-update/</link>
		<comments>http://allanmcrae.com/2011/08/mbp-fan-daemon-update/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 09:59:58 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://allanmcrae.com/?p=1320</guid>
		<description><![CDATA[For those using my simple MacBook Pro fan daemon, you probably want to check that it still works&#8230; At least on my system, the location of the core temperature measurements have changed from /sys/devices/platform/coretemp.{0,1}/temp1_input to /sys/devices/platform/coretemp.0/temp{2,3}_input. I think this occured with the update to Linux 3.0 (but I am too lazy to confirm that is [...]]]></description>
			<content:encoded><![CDATA[<p>For those using my <a href="http://allanmcrae.com/2010/05/simple-macbook-pro-fan-daemon/">simple MacBook Pro fan daemon</a>, you probably want to check that it still works&#8230;  At least on my system, the location of the core temperature measurements have changed from <tt>/sys/devices/platform/coretemp.{0,1}/temp1_input</tt> to <tt>/sys/devices/platform/coretemp.0/temp{2,3}_input</tt>.  I think this occured with the update to Linux 3.0 (but I am too lazy to confirm that is the actual update to blame&#8230;).</p>
<p>If you also have this change, you can grab an updated version of the daemon <a href="http://allanmcrae.com/packages/mbpfan-1.1-1.src.tar.gz">here</a>.  As always, it is only tested on my machine (MBP 5.5 13&#8243;), so it may not work anywhere else without adjustment&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://allanmcrae.com/2011/08/mbp-fan-daemon-update/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Syncing Files Across SFTP With LFTP</title>
		<link>http://allanmcrae.com/2011/07/syncing-files-across-sftp-with-lftp/</link>
		<comments>http://allanmcrae.com/2011/07/syncing-files-across-sftp-with-lftp/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 08:48:57 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://allanmcrae.com/?p=1271</guid>
		<description><![CDATA[My webhost only provides SFTP access (which is not surprising given what I pay&#8230;). But this can become annoying for maintaining things like a package repository where I would like to keep the remote files in sync with my local copy. My first thought was to go with a FUSE based solution in combination with [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://laughingsquid.us/">webhost</a> only provides SFTP access (which is not surprising given what I pay&#8230;).  But this can become annoying for maintaining things like a <a href="http://allanmcrae.com/2011/06/the-allanbrokeit-repo-that-might-really-break-your-system/">package repository</a> where I would like to keep the remote files in sync with my local copy.  My first thought was to go with a FUSE based solution in combination with rsync. Looking into the current best options to mount the remote directory (probably <a href="http://fuse.sourceforge.net/sshfs.html">sshfs</a>), I was eventually lead to <a href="http://lftpfs.sourceforge.net/">LftpFS</a> and on to its underlying software <a href="http://lftp.yar.ru/">LFTP</a>.  </p>
<p>LFTP is a sophisticate command-line file transfer program with its own shell-like command syntax.  This allows syncing from my local repo copy to the remote server in a single command:</p>
<p><code>lftp -c "open -u &lt;user&gt;,&lt;password&gt; &lt;host url&gt;; mirror -c -e -R -L &lt;path from&gt; &lt;path to&gt;"</code></p>
<p>The <tt>-c</tt> flag tell LFTP to run the following commands (separated by a semicolon).  I use two commands; the <tt>open</tt> command (should be obvious what it does&#8230;) and a <tt>mirror</tt> command.  The only real &#8220;trick&#8221; there is to add <tt>-L</tt> to the <tt>mirror</tt> command, which makes symlinks be uploaded as the files they point to.  This is required as the FTP protocol does not support symlinks and <tt>repo-add</tt> generates some.</p>
<p>That was exactly what I needed and it makes a nice bash alias being a single command.</p>
]]></content:encoded>
			<wfw:commentRss>http://allanmcrae.com/2011/07/syncing-files-across-sftp-with-lftp/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Local WordPress Install On Arch Linux</title>
		<link>http://allanmcrae.com/2011/07/local-wordpress-install-on-arch-linux/</link>
		<comments>http://allanmcrae.com/2011/07/local-wordpress-install-on-arch-linux/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 21:33:18 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://allanmcrae.com/?p=1274</guid>
		<description><![CDATA[After the WordPress update from 3.1.3 to 3.1.4 unexpectedly broke one of the plugins I use (My Link Order &#8211; why this was removed as a native feature in WordPress is beyond me&#8230;), I decided it was time to actually test updates locally before I pushed them to my site. That would also allow me [...]]]></description>
			<content:encoded><![CDATA[<p>After the WordPress update from 3.1.3 to 3.1.4 unexpectedly broke one of the plugins I use (<a href="http://geekyweekly.com/mylinkorder">My Link Order</a> &#8211; why this was removed as a native feature in WordPress is beyond me&#8230;), I decided it was time to actually test updates locally before I pushed them to my site.  That would also allow me to locally test theme changes and new plugins rather than just doing it live and attempting to quickly revert all breakages I made.  It is still not the worlds best testing set-up as it does not use the same web server, PHP or MySQL version as my host, but I am fairly happy assuming the basics of WordPress will be compatibly with what my host provides and so only really need to test functionality that should not be affected by such differences.</p>
<p>Note I decided to go with <a href="http://nginx.net/">Nginx</a> as the web server as it seemed an easy way to go.  I also did not use the WordPress package provided in the Arch Linux repos as it kind of defeats the whole purpose of testing the upgrade, requires slightly more set-up in nginx.conf and I think files in <tt>/srv/http</tt> should not be managed by the package manager (but that is another rant&#8230;).</p>
<p>So here is a super-quick ten-step guide to getting a local WordPress install up and running.  </p>
<ul>
<li><tt>pacman -S nginx php-fpm mysql</tt></li>
<li>Adjust <tt>/etc/nginx/conf/nginx.conf</tt> to enable PHP as described <a href="https://wiki.archlinux.org/index.php/Nginx#Step_2:_Edit_.2Fetc.2Fnginx.2Fconf.2Fnginx.conf">here</a></li>
<li>Enable the <tt>mysql.so</tt> and <tt>mysqli.so</tt> extensions in <tt>/etc/php/php.ini</tt></li>
<li><tt>sudo rc.d start mysqld php-fpm nginx</tt></li>
<li>If this is your first MySQL install, run <tt>sudo mysql_secure_installation</tt></li>
<li>Give yourself permission to write to <tt>/srv/http/nginx</tt></li>
<li>Download and extract the WordPress tarball into <tt>/srv/http/nginx</tt></li>
<li>Create the MySQL database and user as described <a href="http://codex.wordpress.org/Installing_WordPress#Using_the_MySQL_Client">here</a></li>
<li>Adjust the <tt>wp-config.php</tt> file as needed (see <a href="http://codex.wordpress.org/Installing_WordPress#Step_3:_Set_up_wp-config.php">here</a>)</li>
<li>Point your browser at <tt>http://127.0.0.1/wp-admin/install.php</tt></li>
</ul>
<p>And it is done!  I have not attempted to set-up the auto-update features in WordPress as that involves either setting up and FTP or SSH server and I have no need to do either on my laptop.</p>
<p>As a bonus, I can now draft blog posts while offline and preview them with all their formatting.  So you can all look forward to more rambling posts here from me&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://allanmcrae.com/2011/07/local-wordpress-install-on-arch-linux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The &#8220;python2&#8243; PEP</title>
		<link>http://allanmcrae.com/2011/03/the-python2-pep/</link>
		<comments>http://allanmcrae.com/2011/03/the-python2-pep/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 03:37:25 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://allanmcrae.com/?p=790</guid>
		<description><![CDATA[When Arch Linux switched its /usr/bin/python from python-2.x to python-3.x, it caused a little controversy&#8230; There were rumours that it had been decided upstream that /usr/bin/python would always point at a python-2.x install (although what version that should be was unclear). Although these rumours were abundant and so more than likely such a discussion did [...]]]></description>
			<content:encoded><![CDATA[<p>When Arch Linux <a href="http://allanmcrae.com/2010/10/big-python-transition-in-arch-linux/">switched</a> its <tt>/usr/bin/python</tt> from python-2.x to python-3.x, it caused a little <a href="http://juliank.wordpress.com/2010/10/22/arch-linux-python-3-and-users/">controversy</a>&#8230; There were rumours that it had been decided upstream that <tt>/usr/bin/python</tt> would <strong><em>always</em></strong> point at a python-2.x install (although what version that should be was unclear).  Although these rumours were abundant and so more than likely such a discussion did occur (probably offline at PyCon 2009), this decision was never documented.  Also, whether such a decision can formally be made off the main development list is debatable.</p>
<p>Enter <a href="http://www.python.org/dev/peps/pep-0394/">PEP 394</a>.  Depending on how I am feeling, I call this the &#8220;justify Arch&#8217;s treatment of python&#8221; PEP or the &#8220;make Debian include a python2 symlink&#8221; PEP.  Either way, the basic outcome is:</p>
<ul>
<li>python2 will refer to some version of Python 2.x</li>
<li>python3 will refer to some version of Python 3.x</li>
<li>python should refer to the same target as python2 but may refer to python3 on some bleeding edge distributions</li>
</ul>
<p>The PEP is still labeled as a draft, but all discussion is over as far as I can tell and I think it will probably be accepted without much of any further modification.  The upshot is, using &#8220;<tt>#!/usr/bin/env python2</tt>&#8221; and &#8220;<tt>#!/usr/bin/env python3</tt>&#8221; in your code will become the gold standard (unless of course you code can run on both python-2.x and python-3.x).  There is still no guarantee what versions of python-2.x or python-3.x you will get, but it is better than nothing&#8230;</p>
<p>One recommendation made by the PEP is that all distribution packages use the python2/python3 convention.  That means the packages containing python-3.x code in Arch should have their shebangs changed to point at <tt>python3</tt> rather than <tt>python</tt>.  Given our experience doing the same thing with <tt>python2</tt>, this should not be too hard to achieve and is something that we should do once the PEP is out of draft stage.  This has a couple of advantages.  Firstly, we will likely get more success with upstream developers preparing their software to have a versioned python in their shebangs (or at least change <strong><em>all</em></strong> of them when installing with <tt>PYTHON=python2 ...</tt>).  That would remove many sed lines from our PKGBUILDs.  Secondly, if all packages only use <tt>python2</tt> or <tt>python3</tt>, then the only use of the <tt>/usr/bin/python</tt> symlink would be interactively.  That would mean that a system administrator could potentially change that symlink to point at any version of python that they wished.</p>
]]></content:encoded>
			<wfw:commentRss>http://allanmcrae.com/2011/03/the-python2-pep/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Python 3 Module Support</title>
		<link>http://allanmcrae.com/2010/12/python-3-module-support/</link>
		<comments>http://allanmcrae.com/2010/12/python-3-module-support/#comments</comments>
		<pubDate>Sat, 04 Dec 2010 07:22:03 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://allanmcrae.com/?p=684</guid>
		<description><![CDATA[I was reading a thread on the python-dev mailing list where someone asked about ideas for porting modules to python-3.x. That lead me to wonder what the current status of python-3 support was in various well used modules. So here is a summary of my research. As a disclaimer, I have not directly asked any [...]]]></description>
			<content:encoded><![CDATA[<p>I was reading a thread on the python-dev mailing list where someone asked about ideas for porting modules to python-3.x.  That lead me to wonder what the current status of python-3 support was in various well used modules.  So here is a summary of my research.   As a disclaimer, I have not directly asked any of the involved module developers what their opinion is, but have rather summarised what I can find posted on various mailing lists.  Also, the modules I list are my own subjective selection of what I think are popular modules, so do not take inclusion/exclusion in this list to mean anything.</p>
<p><strong>GUI Toolkits:</strong></p>
<p><em><a href="http://www.riverbankcomputing.co.uk/software/pyqt/intro">PyQt</a></em> &#8211; Has supported python-3 since v4.5 (release 2009-06-05).</p>
<p><em><a href="http://www.pygtk.org/">PyGTK</a></em> &#8211; Is effectively going to be a dead project with the upcoming release of GTK+3 so will not be ported to python-3.  Instead, projects should move to <a href="http://live.gnome.org/PyGObject">PyGObject</a>, which has some limited python-3 support with v2.26.0 (base and Introspection modules only &#8211; released 2010-09-27)</p>
<p><em><a href="http://wxpython.org/">wxPython</a></em> &#8211; python-3 support has not been started and according to their <a href="http://wiki.wxpython.org/TentativeRoadmap">roadmap</a> will likely be on hold until a major rewrite is finished.</p>
<p><strong>Science:</strong></p>
<p><em><a href="http://numpy.scipy.org/">numpy</a></em> &#8211; Supports python-2 and python-3 from a single code base since v1.5.0 (released 2010-08-31), although the module needed for its testing framework (python-nose) is not yet officially ported.</p>
<p><em><a href="http://www.scipy.org/">scipy</a></em> &#8211; Will support python-3 with the release of <a href="http://docs.scipy.org/doc/scipy/reference/release.0.9.0.html">v0.9.0</a>. As far as I can tell, python-3 support is finished in their SVN.</p>
<p><em><a href="http://matplotlib.sourceforge.net/">matplotlib</a></em> &#8211; I could not find any details on the current status of python-3 support for matplotlib, so I assume this has yet to start.  The porting of numpy to python-3 should give this a huge boost.</p>
<p><strong>Database:</strong></p>
<p><em><a href="http://code.google.com/p/pysqlite/">pysqlite</a></em> &#8211; the sqlite module has been part of the Python stdlib for a while now, so has supported python-3 from the beginning.  I guess the external development version has similar support.</p>
<p><em><a href="http://initd.org/psycopg/">psycopg2</a></em>  &#8211; This is actually quite a weird situation&#8230;  It <a href="http://mail.python.org/pipermail/python-porting/2008-December/000004.html">appears</a> to have been ported at the end of 2008 and looking at the patch should have been able to simulataneously support python-2 and python-3.  However, when it got applied to the <a href="https://dndg.it/cgi-bin/gitweb.cgi?p=public/psycopg2.git">master</a> git branch in mid 2009, a python2 branch was immediately created and all development for the last 18 months has occurred on that branch.</p>
<p><em><a href="http://mysql-python.sourceforge.net/">mysql-python</a></em> &#8211; An old <a href="http://mysql-python.blogspot.com/2010/02/new-releases-coming-soon.html">blog post</a> indicates there is a rewrite happening and python-3.x support will be added once this starts shaping up to beta level.</p>
<p><strong>Misc:</strong></p>
<p><em><a href="http://packages.python.org/distribute/">distribute</a></em> &#8211; Supported python-3 since v0.6.2 (released 2009-09-26).</p>
<p><em><a href="http://www.djangoproject.com/">Django</a></em> &#8211; The <a href="http://docs.djangoproject.com/en/dev/faq/install/#can-i-use-django-with-python-3">FAQ</a> indicates they believe porting to python-3 will require dropping support for older python-2.x versions.  According to mailing lists posts I could find, they intend to support the main python version that is used by a currently supported RHEL, so it could take quite some time before they do this.  However, an initial <a href="http://wiki.python.org/moin/PortingDjangoTo3k">porting</a> effort showed that quite some progress could be made without having to drop support for current python-2.x versions.</p>
<p><em><a href="http://www.pythonware.com/products/pil/">PIL</a></em> &#8211; The release notes for 1.1.7 states that &#8220;A version of 1.1.7 for 3.X will be released later&#8221;, but that was posted on 2009-11-15 and there is a lack of further updates on its status.</p>
<p><em><a href="http://www.pygame.org/">pygame</a></em> &#8211; Some python-3 support was available in 1.9.0 (released 2009-07-31) and the number of modules that work with python-3 looks set to markedly increase with 1.9.2 (due to numpy now being python-3 compatible).  Its successor (<a href="http://code.google.com/p/pgreloaded/">pgreloaded</a>) similarly supports python-3.</p>
<p><em><a href="http://twistedmatrix.com/trac/">Twisted</a></em> &#8211; There is a <a href="http://twistedmatrix.com/trac/milestone/Python-3.x">python-3.x</a> milestone in their bug tracker, but there appears to be no dedicated porting effort.  Having a quick look at its dependencies, there may need to be some downstream work before it is started anyway.  Also, their <a href="http://buildbot.twistedmatrix.com/builders/python-3k-warnings">buildbot</a> that uses the &#8220;-3&#8243; warnings flag shows there is a lot of groundwork to be done.</p>
<p>So depending on exactly what you want to do, python-3.x might be an option. Graphical application programming, scientific programming and gaming all have reasonable support currently and that only looks set to get better in the near future.  However, if you want to do anything web based or interact with a database other than MySQL, it looks like python-3 support could be quite some time away.</p>
]]></content:encoded>
			<wfw:commentRss>http://allanmcrae.com/2010/12/python-3-module-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When Good Features Go Bad!</title>
		<link>http://allanmcrae.com/2010/11/when-good-features-go-bad/</link>
		<comments>http://allanmcrae.com/2010/11/when-good-features-go-bad/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 15:17:24 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://allanmcrae.com/?p=675</guid>
		<description><![CDATA[Sometimes people have really good ideas of features that should be included in software that end up having unintended side effects. This is one of those stories. Enter Liferea, probably the best RSS feed reader written in GTK2. You can tell it is good because they provide links to alternative feed readers on their front [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes people have really good ideas of features that should be included in software that end up having unintended side effects.  This is one of those stories.</p>
<p>Enter <a href="http://liferea.sourceforge.net/">Liferea</a>, probably the best RSS feed reader written in GTK2.  You can tell it is good because they provide links to alternative feed readers on their front page&#8230;  that shows confidence!</p>
<p>But it has one &#8220;feature&#8221; that has had me tearing my hair out.  Whenever it checks a feed and encounters a redirect, it blindly updates the feeds URL.  While that seems a good idea (as it prevents constant redirects), it causes some issues&#8230;  Imagine opening your feed reader in a hotel with a paywall or terms of service page where you have to agree to go any further and all your feeds get their URL changed.</p>
<p>When that happened to me, I grabbed the source code and deleted the entire URL update segment.  Given the Arch policies on patching and upstream issues, this is the sort of &#8220;fix&#8221; that would not make it into our repos so I have had to maintain my own Liferea package for a few months now.  But that is all to change with a <a href="http://sourceforge.net/tracker/?func=detail&#038;aid=3078896&#038;group_id=87005&#038;atid=581686">patch</a> being accepted upstream.  Of course, the patch does things the correct way and updates URLs that redirect only with HTTP 301 (Moved Permanently) codes.</p>
<p>So now I just have to trust that hotels do not issue a 301 codes to their paywall.  For some reason, I am still worried&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://allanmcrae.com/2010/11/when-good-features-go-bad/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Recovering Files From an NTFS Drive</title>
		<link>http://allanmcrae.com/2010/09/recovering-files-from-an-ntfs-drive/</link>
		<comments>http://allanmcrae.com/2010/09/recovering-files-from-an-ntfs-drive/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 04:48:13 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://allanmcrae.com/?p=532</guid>
		<description><![CDATA[Important lessons for computers owners: Set up a backup system Use that backup system regularly It turns out that while I set up a backup system for my wife&#8217;s computer, the last time it was ran was sometime late 2009&#8230; So when the primary Windows partition on that computer no longer booted; was not recognised [...]]]></description>
			<content:encoded><![CDATA[<p>Important lessons for computers owners:</p>
<ol>
<li>Set up a backup system</li>
<li>Use that backup system regularly</li>
</ol>
<p>It turns out that while I set up a backup system for my wife&#8217;s computer, the last time it was ran was sometime late 2009&#8230;    So when the primary Windows partition on that computer no longer booted; was not recognised as a Windows install by the Windows install CD rescue option; and would not mount using the ntfs-3g driver from Linux, I knew I was in trouble!  Luckily, I had split the Windows install to have a separate partition where most of her data (photos, music, documents) were sitting and that partition was still mountable.  So, in the worst case scenario, the total damage would be limited to Firefox and Thunderbird profiles and whatever was saved on the desktop.</p>
<p>Recovering more data from the hard-drive was not particularly difficult as the hard-drive still basically worked.  In that case, the first step in any data recovery attempt is to create a disk image of the broken partition.  This prevents any further damage to the hard-drive making you life worse.  A good tool for the job is <a href="http://www.gnu.org/software/ddrescue/ddrescue.html">GNU ddrescure</a> (which may be named ddrescue or gddrescue depending on your Linux distribution).  Make sure you have the GNU version as the other software with the same name is less user friendly.  It can take a long time to take an image of a hard-drive so having some nice output and being able to stop and restart at any stage are quite essential.  Creating an image is as simple as running (as root):</p>
<p><code>ddrescue -r3 /dev/sda2 imagefile logfile</code><br />
The log file shows that the hard-drive had quite a few corrupt parts, all relatively small and close together so my guess is some sort of physical damage preventing those being read.</p>
<p><code># Rescue Logfile. Created by GNU ddrescue version 1.13<br />
# Command line: ddrescue -r3 /dev/sda2 imagefile logfile<br />
# current_pos  current_status<br />
0x30D31E00     +<br />
#      pos        size  status<br />
0x00000000  0x309EB000  +<br />
0x309EB000  0x00001000  -<br />
0x309EC000  0x00073000  +<br />
0x30A5F000  0x00002000  -<br />
0x30A61000  0x00073000  +<br />
0x30AD4000  0x00002000  -<br />
0x30AD6000  0x00073000  +<br />
0x30B49000  0x00002000  -<br />
0x30B4B000  0x000FC000  +<br />
0x30C47000  0x00001000  -<br />
0x30C48000  0x00074000  +<br />
0x30CBC000  0x00001000  -<br />
0x30CBD000  0x00074000  +<br />
0x30D31000  0x00001000  -<br />
0x30D32000  0x7F5409E00  +<br />
</code></p>
<p>So now you have an image of your hard-drive, it is time to get those files out.  Given the disk image was relatively complete, I went for software called <a href="http://www.sleuthkit.org/">Sleuth Kit</a>.  It has a frontend called Autopsy, which I found fairly useless apart from browsing the data.  To use it, start Autopsy by pointing it at directory where all its files are to be stored and then point your web browser at the relevant place:</p>
<p><code>mkdir autopsydir<br />
autopsy -d autopsydir<br />
firefox http://localhost:9999/autopsy<br />
</code></p>
<p>While browsing the data was good to confirm that most of the files I wanted were still there, I just wanted to extract every single file possible from the image and I would then copy all the relevant stuff over to the new computer as necessary.  Slueth Kit has some command-line tools for doing that; <tt>fls</tt> for listing files and <tt>icat</tt> for getting them.  Using these, you can extract the files one at a time&#8230;  but a simple script will automate extracting everything.  </p>
<p><code>#!/bin/sh<br />
IMAGE=../imagefile<br />
fls -urp $IMAGE |<br />
while read type inode name; do<br />
&nbsp;&nbsp;&nbsp;echo $name<br />
&nbsp;&nbsp;&nbsp;case $type in<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d/d) mkdir -p "$name" ;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;r/r) [ ! -f "$name" ] &#038;&#038; icat $IMAGE $(echo $inode | sed 's/://g') > "$name" ;;<br />
&nbsp;&nbsp;&nbsp;esac<br />
done<br />
</code></p>
<p>That will take a long time to run, especially if it is your primary Windows install drive as it will have lots of small files to extract.  So I made that script so that it can continue where it left off.  Just do not stop one run in the middle of an important file or it will not finish extracting it.  You might want to also touch <tt>hiberfil.sys</tt> and <tt>pagefile.sys</tt> in the extraction directory first as they are relatively useless and will take up a few gigabytes each.</p>
<p>So everything appears to have been recovered and I survived the lack of backup!  Windows 7 has a good feature that reminds you to set up a backup and run it regularly, so hopefully I will not need to do this again.</p>
]]></content:encoded>
			<wfw:commentRss>http://allanmcrae.com/2010/09/recovering-files-from-an-ntfs-drive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GCC in C++</title>
		<link>http://allanmcrae.com/2010/06/gcc-in-cxx/</link>
		<comments>http://allanmcrae.com/2010/06/gcc-in-cxx/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 13:18:17 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://allanmcrae.com/?p=479</guid>
		<description><![CDATA[As is becoming widely covered, the GCC Steering Committee and the FSF have approved the use of C++ in the GCC codebase. This is not a particularly sudden decision&#8230; I originally saw this proposed by Ian Lance Taylor on his blog a couple of years ago. He also has some good slides about how using [...]]]></description>
			<content:encoded><![CDATA[<p>As is becoming widely covered, the GCC Steering Committee and the FSF have <a href="http://gcc.gnu.org/ml/gcc/2010-05/msg00705.html">approved</a> the use of C++ in the GCC codebase.  This is not a particularly sudden decision&#8230;  I originally saw this <a href="http://www.airs.com/blog/archives/187">proposed</a> by Ian Lance Taylor on his blog a couple of years ago.  He also has some good <a href="http://airs.com/ian/cxx-slides.pdf">slides</a> about how using C++ would be benificial.  There was a <tt>gcc-in-c++</tt> branch that corrected incompatibilities flagged by <tt>-Wc++-compat</tt>, but I think this is mostly merged and there is now an experimental <tt>--enable-build-with-cxx</tt> configure flag.  So I think that this decision comes at no real surprise to anyone involved.</p>
<p>I think this is a great idea!  Why?  Because if the compiler is written in C++, then the compiler developers have more motivation to make C++ compilation faster.  This is good for me as C++ is my primary choice for a writing in a compiled programming language.  So this is a win for me.</p>
<p>Is it a win for GCC?  I know some people (especially <a href="http://thread.gmane.org/gmane.comp.version-control.git/57643/focus=57918">Linus Torvalds</a>) think using C++ for anything is a major disaster.  In fact, despite being a C++ proponent, I tend to agree&#8230;  99% of people who propose the usage of C++ for something are wrong.  Many of the complexities in C++ have no place in most projects and too many C++ programmers feel the need to use the entire C++ toolset.  Let be honest, the <a href="http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern">curiously recurring template pattern</a> and <a href="http://en.wikipedia.org/wiki/Template_metaprogramming">template metaprogramming</a> have no real place anywhere but in academia<sup>[1]</sup>.  But (single) inheritance and the STL do provide what I have seen people try to replicate in C many times.  Using C++ as a C with classes is not really that different from C but it can be much simpler to write. </p>
<p>There are some obvious cases where changing to C++ in the GCC codebase would be of great benefit. Take a look in <tt>gcc/vec.h</tt> in the gcc source. </p>
<p><code>/* The macros here implement a set of templated vector types and<br />
   associated interfaces.  These templates are implemented with<br />
   macros, as we're not in C++ land.  The interface functions are<br />
   typesafe and use static inline functions, sometimes backed by<br />
   out-of-line generic functions. ...</code><br />
That is screaming out to be replaced by a <tt>std::vector</tt>.  There are other examples where simple inheritance is mimicked using a slew of (un)defines and switch statements.  Some of these are so complex, I wonder whether there will be any performance loss due to the introduction of virtual function calls.  Certainly, it will be a win in terms of maintainability.</p>
<p><small>[1] Although in combination you get the expression template paradigm, which allows you to build a really nice numeric vector class that unrolls all loops at compile time and does not suffer from virtual function overhead, making it as fast as manually programming the vector arithmetic in C but much more convenient to use.  Then you go back to using <tt>std::valarray</tt> which is close enough&#8230;</small></p>
]]></content:encoded>
			<wfw:commentRss>http://allanmcrae.com/2010/06/gcc-in-cxx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Thunderbird vs Exchange IMAP</title>
		<link>http://allanmcrae.com/2010/05/thunderbird-vs-excange-imap/</link>
		<comments>http://allanmcrae.com/2010/05/thunderbird-vs-excange-imap/#comments</comments>
		<pubDate>Tue, 25 May 2010 00:49:33 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://allanmcrae.com/?p=472</guid>
		<description><![CDATA[I was having issues with attachments only being partially downloaded in Thunderbird from an IMAP account on a MS Exchange server (2003 I think). Turns out I ran into a very old Thunderbird bug (filed 2001-07-24). MS Exchange by default does not return the actual size to the IMAP4 command &#8220;FETCH RFC822.SIZE&#8221;. This is deliberate [...]]]></description>
			<content:encoded><![CDATA[<p>I was having issues with attachments only being partially downloaded in Thunderbird from an IMAP account on a MS Exchange server (2003 I think).  Turns out I ran into a very old Thunderbird <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=92111">bug</a> (filed 2001-07-24).   MS Exchange by default does not return the actual size to the IMAP4 command &#8220;FETCH RFC822.SIZE&#8221;.  This is <a href="http://support.microsoft.com/kb/191504">deliberate</a> as it provides a nice perfomance advantage.  </p>
<p>So&#8230;  like a good Linux user I should once again blame Microsoft software for being broken?  Not this time.  It turns out section 3.4.5 of RFC 2683 (IMAP4 Implementation Recommendations) says that the RCF822.SIZE value should only used for things like providing estimates to the user and not for allocating buffers and the like.  Bad Thunderbird!</p>
<p>The work around is to go to Preferences > Advanced > Config Editor&#8230; and set <tt>mail.server.default.fetch_by_chunks</tt> to FALSE. Old emails will need to be redownloaded to fix the attachments.</p>
]]></content:encoded>
			<wfw:commentRss>http://allanmcrae.com/2010/05/thunderbird-vs-excange-imap/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple MacBook Pro Fan Daemon</title>
		<link>http://allanmcrae.com/2010/05/simple-macbook-pro-fan-daemon/</link>
		<comments>http://allanmcrae.com/2010/05/simple-macbook-pro-fan-daemon/#comments</comments>
		<pubDate>Sun, 23 May 2010 10:19:37 +0000</pubDate>
		<dc:creator>Allan</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://allanmcrae.com/?p=435</guid>
		<description><![CDATA[The fan control on the MacBook Pro under Linux is not the best&#8230; I would say it does not work at all but I once saw the fan speed increase slightly on its own so it appears to do something, sometimes, according to some logic I can not figure out. It turns out that taking [...]]]></description>
			<content:encoded><![CDATA[<p>The fan control on the MacBook Pro under Linux is not the best&#8230;   I would say it does not work at all but I once saw the fan speed increase slightly on its own so it appears to do something, sometimes, according to some logic I can not figure out.</p>
<p>It turns out that taking &#8220;manual&#8221; control of the fan is quite easy.  A simple</p>
<p><code>echo 1 &gt; /sys/devices/platform/applesmc.768/fan1_manual</code><br />
sets the fan to manual mode.  Then you can adjust <tt>fan1_output</tt> in the same directory to set the current fan speed.  Do not get confused with <tt>fan1_input</tt>, as that is strangely the actual fan speed! The minimum and maximum speeds are given by <tt>fan1_min</tt> and <tt>fan1_max</tt>.  If the minimum speed is reported as 0 or 1, ignore it.  For MacBook Pros with Core 2 Duo processors the minimum fan speed should be 2000.  The maximum fan speed is 6200.</p>
<p>So now that we know how to control the fan, we just need some sort of algorithm to choose what the fan speed should be based on the temperature.  The MacBook Pro has a whole bunch of temperature sensors, but the ones that matter are for the processors as they are always the highest.    These are found in <tt>/sys/devices/platform/coretemp.{0,1}/temp1_input</tt> (you may need to load the <tt>coretemp</tt> module).  Montoring these during basic usage shows the average temperatures of the two processors is around 40-45C during idle, 50-55C with basic web browsing and 60-65C when watching a HD movie (at least in warm Australian ambient temperatures).</p>
<p>To save battery on a laptop, I think that the fan should not come on when the computer is doing anything less intensive than watching a movie, so I set that fan to kick in at 65C.  This coincides with what Mac OSX does.  From OSX, it appears that the fans should hit full speed at 80C and the speed builds up exponentially to that point.  The formula I use for changing the fan speed when the temperature is increasing is:</p>
<p><code>temp &lt;= 65:<br />
&nbsp;&nbsp;&nbsp;speed = max(current_speed, 2000)<br />
65 &lt; temp &lt; 80:<br />
&nbsp;&nbsp;&nbsp;step = (6200 - 2000) / ( (80 - 65) * (80 - 64) / 2 )<br />
&nbsp;&nbsp;&nbsp;speed = max(current_speed, ceil(2000 + (temp - 65) * (temp - 64) / 2 * step))<br />
temp &gt;= 80:<br />
&nbsp;&nbsp;&nbsp;speed = 6200</code></p>
<p>When the temperature is decreasing, I prefer to keep the fan going slightly longer to force the temperature down to low levels as quickly as possible.   I push it back down to 55C using this formula:</p>
<p><code>temp &gt;= 80:<br />
&nbsp;&nbsp;&nbsp;speed = 6200<br />
55 &lt; temp &lt; 80:<br />
&nbsp;&nbsp;&nbsp;step = (6200 - 2000) / ( (80 - 55) * (80 - 54) / 2 )<br />
&nbsp;&nbsp;&nbsp;speed = min(current_speed, floor(6200 - (80 - temp) * (81 - temp) / 2 * step)<br />
temp &lt;= 55:<br />
&nbsp;&nbsp;&nbsp;speed = 2000</code><br />
Here is a graphic of what that looks like (red = increasing, blue = decreasing):</p>
<p><img class="aligncenter" src="http://allanmcrae.com/images/fanspeed.png" alt="fan speed" /></p>
<p>Grap the source code <a href="http://allanmcrae.com/packages/mbpfan-1.0-1.src.tar.gz">here</a>.  It assumes two processors and a single fan (not true for all MacBook Pros&#8230;).  For Arch Linux users, there is also a PKGBUILD and daemon (mbpfan) for ease of use.  I am lazy, so there is very little error checking in the code.  It works for me but use at your own risk&#8230;</p>
<p>Update (2011-08-11): <a href="http://allanmcrae.com/2011/08/mbp-fan-daemon-update/">MBP Fan Daemon Update</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://allanmcrae.com/2010/05/simple-macbook-pro-fan-daemon/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

