<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Arg and gah and ap and pa</title>
	<atom:link href="http://argandgahandapandpa.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://argandgahandapandpa.wordpress.com</link>
	<description>Another blog with random computer-related musings</description>
	<lastBuildDate>Sun, 22 Nov 2009 18:13:43 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='argandgahandapandpa.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/fb277ac6dd131d371770c3fdbadad380?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Arg and gah and ap and pa</title>
		<link>http://argandgahandapandpa.wordpress.com</link>
	</image>
			<item>
		<title>Getting emacs to behave more like vim</title>
		<link>http://argandgahandapandpa.wordpress.com/2009/11/22/getting-emacs-to-behave-more-like-vim/</link>
		<comments>http://argandgahandapandpa.wordpress.com/2009/11/22/getting-emacs-to-behave-more-like-vim/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 18:13:43 +0000</pubDate>
		<dc:creator>existentiality</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://argandgahandapandpa.wordpress.com/2009/11/22/getting-emacs-to-behave-more-like-vim/</guid>
		<description><![CDATA[Although the viper mode does not provide a lot of vim&#8217;s motions e.g diw and similar. The vimpulse plugin (http://www.emacswiki.org/emacs/download/vimpulse.el) does extends viper to provide several of these.
Supported commands in include
diw, ciw, yiw, di&#8221;, da&#8221;, ci&#8221;, ca&#8221;, yi&#8221;, ya&#8221;,
di(, da(, ci(, ca(, yi(, ya(,
di&#8217;, da&#8217;, ci&#8217;, ca&#8217;, yi&#8217;, ya&#8217;,
(take that google)
I find these vim text [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=177&subd=argandgahandapandpa&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Although the viper mode does not provide a lot of vim&#8217;s motions e.g diw and similar. The vimpulse plugin (http://www.emacswiki.org/emacs/download/vimpulse.el) does extends viper to provide several of these.</p>
<p>Supported commands in include</p>
<p>diw, ciw, yiw, di&#8221;, da&#8221;, ci&#8221;, ca&#8221;, yi&#8221;, ya&#8221;,<br />
di(, da(, ci(, ca(, yi(, ya(,<br />
di&#8217;, da&#8217;, ci&#8217;, ca&#8217;, yi&#8217;, ya&#8217;,</p>
<p>(take that google)</p>
<p>I find these vim text objects fairly useful.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/argandgahandapandpa.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/argandgahandapandpa.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/argandgahandapandpa.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/argandgahandapandpa.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/argandgahandapandpa.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/argandgahandapandpa.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/argandgahandapandpa.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/argandgahandapandpa.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/argandgahandapandpa.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/argandgahandapandpa.wordpress.com/177/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=177&subd=argandgahandapandpa&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://argandgahandapandpa.wordpress.com/2009/11/22/getting-emacs-to-behave-more-like-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da1c6e03b2ed78782c80a244a985b2b1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Anon</media:title>
		</media:content>
	</item>
		<item>
		<title>Making viper mode in emacs use C-[ for escape rather than escape</title>
		<link>http://argandgahandapandpa.wordpress.com/2009/11/18/making-viper-mode-in-emacs-use-c-for-escape-rather-than-escape/</link>
		<comments>http://argandgahandapandpa.wordpress.com/2009/11/18/making-viper-mode-in-emacs-use-c-for-escape-rather-than-escape/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 14:59:13 +0000</pubDate>
		<dc:creator>existentiality</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[viper]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://argandgahandapandpa.wordpress.com/?p=175</guid>
		<description><![CDATA[Pressing the actual escape button is far too much effort, so my brain seems to have decided to learn to us C-[ in vim in preference to escape.
To get this working in viper add the following line:
(setq viper-ESC-key &#8220;\C-[&#8220;)
To your emacs init file before you have required viper. Note that this variable cannot be set [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=175&subd=argandgahandapandpa&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Pressing the actual escape button is far too much effort, so my brain seems to have decided to learn to us C-[ in vim in preference to escape.</p>
<p>To get this working in viper add the following line:</p>
<p>(setq viper-ESC-key &#8220;\C-[&#8220;)</p>
<p>To your emacs init file <strong>before</strong> you have required viper. Note that this variable cannot be set in your .viper file or changed after you have loaded viper, or rather it can but it has no effect.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/argandgahandapandpa.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/argandgahandapandpa.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/argandgahandapandpa.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/argandgahandapandpa.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/argandgahandapandpa.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/argandgahandapandpa.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/argandgahandapandpa.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/argandgahandapandpa.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/argandgahandapandpa.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/argandgahandapandpa.wordpress.com/175/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=175&subd=argandgahandapandpa&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://argandgahandapandpa.wordpress.com/2009/11/18/making-viper-mode-in-emacs-use-c-for-escape-rather-than-escape/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da1c6e03b2ed78782c80a244a985b2b1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Anon</media:title>
		</media:content>
	</item>
		<item>
		<title>viper-want-ctl-h broken when set in .viper</title>
		<link>http://argandgahandapandpa.wordpress.com/2009/11/18/viper-want-ctl-h-broken-when-set-in-viper/</link>
		<comments>http://argandgahandapandpa.wordpress.com/2009/11/18/viper-want-ctl-h-broken-when-set-in-viper/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 13:15:51 +0000</pubDate>
		<dc:creator>existentiality</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[viper]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://argandgahandapandpa.wordpress.com/2009/11/18/viper-want-ctl-h-broken-when-set-in-viper/</guid>
		<description><![CDATA[This happens in the emacs viper vim emulation mode shipped with ubuntu 9.10 in November 2009. 
There is a work around by setting viper-want-ctl-help-h in your emacs init file after viper has been imported.
This bug occurs because viper-set-expert-level which is called as part of loading viper tramples on various viper settings. However it does need [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=174&subd=argandgahandapandpa&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This happens in the emacs viper vim emulation mode shipped with ubuntu 9.10 in November 2009. </p>
<p>There is a work around by setting viper-want-ctl-help-h in your emacs init file after viper has been imported.</p>
<p>This bug occurs because viper-set-expert-level which is called as part of loading viper tramples on various viper settings. However it does need to set those settings which have not been overwritten in your .viper file.</p>
<p>As a workaround in viper one could do one of the following:</p>
<p> i) Make viper-set-expert-level only set those settings which are not already set if dont-change&#8230; is set to true<br />
 ii) Load the .viper file twice once after calling set-expert-level (hackish but it works)<br />
 iii) Do something crazy so as to have shadowed variables, where the set-expert-level only sets the value that is shadowed.</p>
<p>However, I am not going to change any of this at the moment. </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/argandgahandapandpa.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/argandgahandapandpa.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/argandgahandapandpa.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/argandgahandapandpa.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/argandgahandapandpa.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/argandgahandapandpa.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/argandgahandapandpa.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/argandgahandapandpa.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/argandgahandapandpa.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/argandgahandapandpa.wordpress.com/174/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=174&subd=argandgahandapandpa&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://argandgahandapandpa.wordpress.com/2009/11/18/viper-want-ctl-h-broken-when-set-in-viper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da1c6e03b2ed78782c80a244a985b2b1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Anon</media:title>
		</media:content>
	</item>
		<item>
		<title>Why might a set API be useful</title>
		<link>http://argandgahandapandpa.wordpress.com/2009/08/03/why-might-a-set-api-be-useful/</link>
		<comments>http://argandgahandapandpa.wordpress.com/2009/08/03/why-might-a-set-api-be-useful/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 17:02:43 +0000</pubDate>
		<dc:creator>existentiality</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://argandgahandapandpa.wordpress.com/?p=167</guid>
		<description><![CDATA[Why use a set api rather than a list API if one doesn&#8217;t care about performance
In most languages in built set classes have better performance than lists. But suppose one doesn&#8217;t care about performance &#8211; why would you use a set rather than a list.
Broadly speaking a set is distinguished from a list by the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=167&subd=argandgahandapandpa&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>Why use a set api rather than a list API if one doesn&#8217;t care about performance</strong></p>
<p>In most languages in built set classes have better performance than lists. But suppose one doesn&#8217;t care about performance &#8211; why would you use a set rather than a list.</p>
<p>Broadly speaking a set is distinguished from a list by the lack of </p>
<p>a) Ordering<br />
b) Duplication of elements.</p>
<p>How can these properties be useful. In a sense it isn&#8217;t true that sets don&#8217;t have an ordering, since in most languages you can iterate over the members of a set &#8211; rather they just don&#8217;t have a very good ordering. So this is not really of any use to us.</p>
<p>So the <strong>only thing that could be useful about a set api is that it allows one to avoid duplication of items</strong> without writing any code to do this. This will be useful for any problems in which you explicitly want to avoid duplication, examples of this include:</p>
<p>* Only wanting to email a number of people once<br />
* Only wanting to rerun tests once<br />
* Only wanting to list each result once (but having an algorithm that generates duplicates).</p>
<p><strong>This concept of avoiding duplication can be generalised </strong></p>
<p>A dictionary allows one to avoid duplication of parts of an object. That is, if we consider two objects to be near enough identical only parts of them match then we can use these parts as keys in a dictionary &#8211; and thereby avoid duplication.</p>
<p>In fact we can encapsulate this behaviour in an equivalence set &#8211; a collection with ensures uniqueness up to some equivalence function (if our elements are immutable we could use the following).</p>
<p>class EquivalenceSet(object):<br />
    def __init__(self, getRepr):<br />
         self.getRepr = getRepr # get representation of equivalence class<br />
         self.mapping = {}</p>
<p>    def add(self, el):<br />
          self.mapping[self.getRepr(el)] = el</p>
<p>    def __iter__(self, el):<br />
          return self.mapping.itervalues()</p>
<p>This assumes that out &#8220;uniqueness&#8221; can somehow be represented by a function such that f(x) = f(y) implies x and y are equivalent . However, sometimes we have more interesting notions of not &#8220;unique&#8221; for example if we are representing objects in a plane &#8211; two objects might only be considered &#8220;unique&#8221; if they do not intersect. If we are in this situation it may not be clear what we should do when elements are not unique.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/argandgahandapandpa.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/argandgahandapandpa.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/argandgahandapandpa.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/argandgahandapandpa.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/argandgahandapandpa.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/argandgahandapandpa.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/argandgahandapandpa.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/argandgahandapandpa.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/argandgahandapandpa.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/argandgahandapandpa.wordpress.com/167/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=167&subd=argandgahandapandpa&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://argandgahandapandpa.wordpress.com/2009/08/03/why-might-a-set-api-be-useful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da1c6e03b2ed78782c80a244a985b2b1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Anon</media:title>
		</media:content>
	</item>
		<item>
		<title>Javascript: keyCode versus charCode</title>
		<link>http://argandgahandapandpa.wordpress.com/2009/07/26/javascript-keycode-versus-charcode/</link>
		<comments>http://argandgahandapandpa.wordpress.com/2009/07/26/javascript-keycode-versus-charcode/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 23:35:47 +0000</pubDate>
		<dc:creator>existentiality</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[for the benefit of google]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://argandgahandapandpa.wordpress.com/2009/07/26/javascript-keycode-versus-charcode/</guid>
		<description><![CDATA[Javascript key press events have both a keyCode and a charCode property. These are mutually exclusive &#8211; whenever one is non-zero the other is zero.
Which one is set depends on the type of event: keydown and keyup events give one events with keyCode set (they produce corresponding character) whilst keypress events give one events with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=166&subd=argandgahandapandpa&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Javascript key press events have both a keyCode and a charCode property. These are mutually exclusive &#8211; whenever one is non-zero the other is zero.</p>
<p>Which one is set depends on the type of event: keydown and keyup events give one events with keyCode set (they produce corresponding character) whilst keypress events give one events with charCode set.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/argandgahandapandpa.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/argandgahandapandpa.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/argandgahandapandpa.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/argandgahandapandpa.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/argandgahandapandpa.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/argandgahandapandpa.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/argandgahandapandpa.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/argandgahandapandpa.wordpress.com/166/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/argandgahandapandpa.wordpress.com/166/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/argandgahandapandpa.wordpress.com/166/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=166&subd=argandgahandapandpa&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://argandgahandapandpa.wordpress.com/2009/07/26/javascript-keycode-versus-charcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da1c6e03b2ed78782c80a244a985b2b1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Anon</media:title>
		</media:content>
	</item>
		<item>
		<title>Automatically loading a truecrypt share at startup</title>
		<link>http://argandgahandapandpa.wordpress.com/2009/05/22/automatically-loading-a-truecrypt-share-at-startup/</link>
		<comments>http://argandgahandapandpa.wordpress.com/2009/05/22/automatically-loading-a-truecrypt-share-at-startup/#comments</comments>
		<pubDate>Fri, 22 May 2009 22:16:47 +0000</pubDate>
		<dc:creator>existentiality</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://argandgahandapandpa.wordpress.com/?p=163</guid>
		<description><![CDATA[I&#8217;m toying with the idea of moving all of my data into the cloud, or rather, keeping all of my data dropbox so that I can access if from 2 different machines and have those changes synced without thinking, and so that I&#8217;m less dependent on any single piece of hardwire.
However, although I want some [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=163&subd=argandgahandapandpa&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;m toying with the idea of moving all of my data into the cloud, or rather, keeping all of my data dropbox so that I can access if from 2 different machines and have those changes synced without thinking, and so that I&#8217;m less dependent on any single piece of hardwire.</p>
<p>However, although I want some data to be present on all the machines I use, I don&#8217;t want all data to be present on every machine I use, and I don&#8217;t think I can easily have several dropbox shares. </p>
<p>One solution is to keep some of the data in a truecrypt volume which is automatically mounted on some machines but not on others. </p>
<p>For this purpose I adapted the following bash init script from <a href="http://notes.lokorin.org/2007/1/9/mounting-truecrypt-partitions-on-boot">here</a>. This takes a truecrypt file, reads a password from disk and mounts the file in my home directory.  I&#8217;m suspicious that there might be problems with conflicts when dropbox updates the truecrypt file whilst it is already mounted&#8230; but we&#8217;ll see. (dropbox has version control so I should be moderately safe).</p>
<p>Note that this approach may place your volume password into the list of processes &#8211; so you might prefer not to use this on shared machines. Also, you probably would want to change the umask and the owner of the share.</p>
<pre>
#!/bin/bash
#
#   /etc/rc.d/init.d/truecrypt
#
# Mounts the /home partition with truecrypt.
#
# chkconfig: 2345 90 10
# description: Truecrypt

# processname: truecrypt

[ -x /usr/bin/truecrypt ] || (echo "truecrypt can't be found" ; exit 1)

RETVAL=0
prog="truecrypt"
desc="Truecrypt" 

start() {
   echo -n "Mounting encrypted volume..."
   uid=$(cat /etc/passwd | grep moment | cut -d ':' -f 3)
   truecrypt -t --fs-options='umask=000,user' --non-interactive VOLUMNE_FILE VOLUME_MOUNT_POINT -p "$(cat PASSWORD_FILE)"
   RETVAL=$?
   [ "$RETVAL" == "0" ] || (echo "FAIL" ; exit 1)
   echo "OK"
}

stop() {
   echo  -n  "Unmounting encrypted volume..."
   truecrypt -t -d /home/moment/cryptshare
   RETVAL=$?
   if [ "$RETVAL" == "0" ]; then
        echo "OK";
   else
      echo "FAIL";
   fi;
}

case "$1" in
  start)
   start
   ;;
  stop)
   stop
   ;;
  restart)
   stop
   start
   RETVAL=$?
   ;;
  condrestart)
        [ -e /var/lock/subsys/$prog ] &amp;&amp; restart
   RETVAL=$?
   ;;
  *)
   echo $"Usage: $0 {start|stop|restart|condrestart}"
   RETVAL=1
esac

exit $RETVAL
</pre>
<p>Not sure whether this is a good use of time&#8230;</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/argandgahandapandpa.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/argandgahandapandpa.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/argandgahandapandpa.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/argandgahandapandpa.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/argandgahandapandpa.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/argandgahandapandpa.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/argandgahandapandpa.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/argandgahandapandpa.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/argandgahandapandpa.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/argandgahandapandpa.wordpress.com/163/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=163&subd=argandgahandapandpa&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://argandgahandapandpa.wordpress.com/2009/05/22/automatically-loading-a-truecrypt-share-at-startup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da1c6e03b2ed78782c80a244a985b2b1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Anon</media:title>
		</media:content>
	</item>
		<item>
		<title>Reading files in factor</title>
		<link>http://argandgahandapandpa.wordpress.com/2009/04/10/reading-files-in-factor/</link>
		<comments>http://argandgahandapandpa.wordpress.com/2009/04/10/reading-files-in-factor/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 19:08:20 +0000</pubDate>
		<dc:creator>existentiality</dc:creator>
				<category><![CDATA[code samples]]></category>
		<category><![CDATA[factor]]></category>
		<category><![CDATA[for the benefit of google]]></category>
		<category><![CDATA[minimal code samples]]></category>

		<guid isPermaLink="false">http://argandgahandapandpa.wordpress.com/?p=154</guid>
		<description><![CDATA[Working code for the impatient
The following factor code reads and counts the number of words in the file &#8220;/etc/fstab&#8221;

USING: io.encodings.ascii io io.files prettyprint splitting sequences ;
"/etc/fstab" ascii file-contents " \n\t" split length .

See also
Official api docs.
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=154&subd=argandgahandapandpa&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>Working code for the impatient</strong></p>
<p>The following factor code reads and counts the number of words in the file &#8220;/etc/fstab&#8221;</p>
<pre>
USING: io.encodings.ascii io io.files prettyprint splitting sequences ;
"/etc/fstab" ascii file-contents " \n\t" split length .
</pre>
<p><strong>See also</strong></p>
<p>Official <a href="http://docs.factorcode.org/content/article-io.files.html">api docs</a>.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/argandgahandapandpa.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/argandgahandapandpa.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/argandgahandapandpa.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/argandgahandapandpa.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/argandgahandapandpa.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/argandgahandapandpa.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/argandgahandapandpa.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/argandgahandapandpa.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/argandgahandapandpa.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/argandgahandapandpa.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=154&subd=argandgahandapandpa&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://argandgahandapandpa.wordpress.com/2009/04/10/reading-files-in-factor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da1c6e03b2ed78782c80a244a985b2b1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Anon</media:title>
		</media:content>
	</item>
		<item>
		<title>De-nesting decorators in python</title>
		<link>http://argandgahandapandpa.wordpress.com/2009/04/06/de-nesting-decorators-in-python/</link>
		<comments>http://argandgahandapandpa.wordpress.com/2009/04/06/de-nesting-decorators-in-python/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 21:45:19 +0000</pubDate>
		<dc:creator>existentiality</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://argandgahandapandpa.wordpress.com/?p=151</guid>
		<description><![CDATA[Definitions of decorators are quite nested

def decorate(f):
    def patched(*args, **kwargs):
        # do stuff involving f
    return patched

About 25% I also forget to write the final &#8220;return patched&#8221;.
One way to work around this is to write a &#8216;denest decorator decorator&#8217; so you can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=151&subd=argandgahandapandpa&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Definitions of decorators are quite nested</p>
<pre>
def decorate(f):
    def patched(*args, **kwargs):
        # do stuff involving f
    return patched
</pre>
<p>About 25% I also forget to write the final &#8220;return patched&#8221;.</p>
<p>One way to work around this is to write a &#8216;denest decorator decorator&#8217; so you can write the following as an alternative to the above:</p>
<pre>
@denest
def decorate(f, *args, *kwargs):
    # do stuff involving f
</pre>
<p>This has the disadvantage that you can&#8217;t perform operations at the time of decoration &#8211; but it simplifies code slightly for the standard case (at the cost of making your code less idiomatic).</p>
<p>The denest decorator is defined like this:</p>
<pre>
def denest(func):
     def decorate(f):
           def patched(*args, **kwargs):
               return func(f, *args, **kwargs)
            return patched
     return decorate
</pre>
<p><b>Example usage:</b></p>
<p>A decorator that converts converts a function which could raise an Excpetion into a function which returns None on error.</p>
<pre>
@denest
def makeIntoTry(f, *args, **kwargs):
    try:
        return f(*args, **kwargs)
    except Exception:
        return None
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/argandgahandapandpa.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/argandgahandapandpa.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/argandgahandapandpa.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/argandgahandapandpa.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/argandgahandapandpa.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/argandgahandapandpa.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/argandgahandapandpa.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/argandgahandapandpa.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/argandgahandapandpa.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/argandgahandapandpa.wordpress.com/151/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=151&subd=argandgahandapandpa&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://argandgahandapandpa.wordpress.com/2009/04/06/de-nesting-decorators-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da1c6e03b2ed78782c80a244a985b2b1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Anon</media:title>
		</media:content>
	</item>
		<item>
		<title>Python generator to list decorator</title>
		<link>http://argandgahandapandpa.wordpress.com/2009/03/29/python-generator-to-list-decorator/</link>
		<comments>http://argandgahandapandpa.wordpress.com/2009/03/29/python-generator-to-list-decorator/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 15:42:19 +0000</pubDate>
		<dc:creator>existentiality</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[decorator]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[listify]]></category>
		<category><![CDATA[note for self]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://argandgahandapandpa.wordpress.com/?p=139</guid>
		<description><![CDATA[Python generators can be evil because of the implicit state. How many time have you written done this?

items = get_items()
print items
f(items, x)

It might prevent confusion if generators are only used when you need lazy iteration. 
However, creating a list, appending to it several times and then returning it is an effort &#8211; which is probably [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=139&subd=argandgahandapandpa&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Python generators can be evil because of the implicit state. How many time have you written done this?</p>
<pre>
items = get_items()
print items
f(items, x)
</pre>
<p>It might prevent confusion if generators are only used when you need lazy iteration. </p>
<p>However, creating a list, appending to it several times and then returning it is an effort &#8211; which is probably why I want to use generators when I don&#8217;t need to.</p>
<p>One workaround is to create a python generator to list decorator like so</p>
<pre>
def listify(gen):
    "Convert a generator into a function which returns a list"
    def patched(*args, **kwargs):
        return list(gen(*args, **kwargs))
    return patched

@listify
def f(x):
     for i in range(x):
        yield "item" + str(i)

assert f(5) == "item0 item1 item2 item3 item4".split()
</pre>
<p>One can also define a dictate decorator as follows</p>
<pre>
from functools import wraps

def dictate(func):
    @wraps(func)
    def patched(*args, **kwargs):
        return dict(*func(*args, **kwargs))
    return patched
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/argandgahandapandpa.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/argandgahandapandpa.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/argandgahandapandpa.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/argandgahandapandpa.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/argandgahandapandpa.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/argandgahandapandpa.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/argandgahandapandpa.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/argandgahandapandpa.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/argandgahandapandpa.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/argandgahandapandpa.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=139&subd=argandgahandapandpa&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://argandgahandapandpa.wordpress.com/2009/03/29/python-generator-to-list-decorator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da1c6e03b2ed78782c80a244a985b2b1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Anon</media:title>
		</media:content>
	</item>
		<item>
		<title>Automatically populating a gcal event with reminders</title>
		<link>http://argandgahandapandpa.wordpress.com/2009/03/22/automatically-populating-a-gcal-event-with-reminders/</link>
		<comments>http://argandgahandapandpa.wordpress.com/2009/03/22/automatically-populating-a-gcal-event-with-reminders/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 20:56:58 +0000</pubDate>
		<dc:creator>existentiality</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://argandgahandapandpa.wordpress.com/?p=133</guid>
		<description><![CDATA[I find it irritating to have to set reminders for google events by hand, so in the theme of efficient-over-effective here is a the urls.py of a django project which will create a new event in google calendar with several reminders and redirect you to a page for editing its details. If you have a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=133&subd=argandgahandapandpa&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I find it irritating to have to set reminders for google events by hand, so in the theme of efficient-over-effective here is a the <em>urls.py</em> of a django project which will create a new event in google calendar with several reminders and redirect you to a page for editing its details. If you have a virtual server you could host this project there. You can then bookmark this url on the machines you use.</p>
<p>A little (if any) adaptation would make this work on google app engine (and might even allow you to login without hard coding a password).</p>
<p>Alternatives would be to write a greasemonkey script for google reader or write a ubiquity command that does this and redirects you to the page &#8211; but both these things seem more difficult to debug.</p>
<pre>
from django.conf.urls.defaults import patterns
from django.http import HttpResponseRedirect

import atom
import datetime
from gdata.calendar import CalendarEventEntry, When, Reminder
from gdata.calendar.service import CalendarService

def create_reminder(req):
    S = CalendarService()
    S.email = "EMAIL@ADDRESS"
    S.password = "password1"
    S.ProgrammaticLogin()

    event = CalendarEventEntry()
<ol>
<li>starttime is manditory - tomorrow seems as good a day as any</li>
</ol>

    def make_google_dt(dt):
      return dt.strftime('%Y-%m-%dT%H:%M:%S.000Z')

    now = datetime.datetime.now()

    start_datetime = now + datetime.timedelta(days=1)
    start_time = make_google_dt(start_datetime)
    end_time = make_google_dt(start_datetime + datetime.timedelta(minutes=30))

    occurence = When(start_time=start_time, end_time=end_time)
    occurence.reminder = [
        Reminder(hours=3, extension_attributes={'method':'sms'}),
        Reminder(days=2, extension_attributes={'method':'email'}), 
<ol>
<li>to feel happily surprised but not panic</li>
</ol>

        Reminder(days=7, extension_attributes={'method':'email'}),
        Reminder(days=14, extension_attributes={'method':'email'}),
        ]
    event.when.append(occurence)

    new_event = S.InsertEvent(event, '/calendar/feeds/default/private/full')
    edit_link = new_event.GetHtmlLink().href
    return HttpResponseRedirect(edit_link)

urlpatterns = patterns('',
    (r'', create_reminder)
)
</pre>
<p>Note that this is a slighlty evil &#8211; insofar as a GET request is having side effects&#8230; but POST commands are slightly troublesome to book mark, and adding a layer of indirection slightly defeats the purpose. </p>
<p><b> Technical notes </b></p>
<ul>
<li> Underneath the python library this is constructing and xml command and sending this to a google webservice.</li>
<li>
The python library does really support email reminders. It does however support adding arbitrary attributes to the xml element representing the reminder:</p>
<pre>
Reminder(days=7, extension_attributes={'method':'email'})
</pre>
<p>this add method=&#8221;email&#8221; to the reminder tag. (One can also set method=sms).</p>
<p>This is not documented in the google python documentation. It is (I think) documented in the gdata plain xml documentation.
</li>
<li>
For a working reference implementation in javascript using plain xml see the <a href="http://userscripts.org/scripts/show/7676">gtd tickler</a> greasemonkey gmail plugin.
</li>
</ul>
<p><b> Useful references </b><br />
<a href="http://code.google.com/apis/calendar/docs/1.0/developers_guide_python.html"> Google calendar interface from python &lt;/a</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/argandgahandapandpa.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/argandgahandapandpa.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/argandgahandapandpa.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/argandgahandapandpa.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/argandgahandapandpa.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/argandgahandapandpa.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/argandgahandapandpa.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/argandgahandapandpa.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/argandgahandapandpa.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/argandgahandapandpa.wordpress.com/133/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=argandgahandapandpa.wordpress.com&blog=2356703&post=133&subd=argandgahandapandpa&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://argandgahandapandpa.wordpress.com/2009/03/22/automatically-populating-a-gcal-event-with-reminders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/da1c6e03b2ed78782c80a244a985b2b1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Anon</media:title>
		</media:content>
	</item>
	</channel>
</rss>