<?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>Moserei</title>
	<atom:link href="http://moserei.de/index.php/feed" rel="self" type="application/rss+xml" />
	<link>http://moserei.de</link>
	<description></description>
	<lastBuildDate>Tue, 06 Jul 2010 16:18:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Find GnuPG revocation certificate on unmountable partition</title>
		<link>http://moserei.de/index.php/216/find-gnupg-revocation-certificate-on-unmountable-partition</link>
		<comments>http://moserei.de/index.php/216/find-gnupg-revocation-certificate-on-unmountable-partition#comments</comments>
		<pubDate>Tue, 06 Jul 2010 16:18:37 +0000</pubDate>
		<dc:creator>Moser</dc:creator>
				<category><![CDATA[computer stuff]]></category>
		<category><![CDATA[gnupg]]></category>
		<category><![CDATA[restore file]]></category>
		<category><![CDATA[scalpel]]></category>

		<guid isPermaLink="false">http://moserei.de/?p=216</guid>
		<description><![CDATA[When you encounter a hard disk crash like I did recently (my fault &#8211; dropped my laptop), one of the most important files to restore is your GnuPG private key ring or at least a revocation certificate for your public key(s). I did not have any backup  . But at least I had created [...]]]></description>
			<content:encoded><![CDATA[<p>When you encounter a hard disk crash like I did recently (my fault &#8211; dropped my laptop), one of the most important files to restore is your GnuPG private key ring or at least a revocation certificate for your public key(s). I did not have any backup <img src='http://moserei.de/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> . But at least I had created a revocation certificate, which was now hidden somewhere on my unmountable partition.<br />
<a href="https://help.ubuntu.com/community/DataRecovery#Scalpel">Scalpel</a>, a file carving tool, helped me out.<br />
There is a Ubuntu package (and I believe there should be packages for most distributions):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> scalpel</pre></div></div>

<p>It&#8217;s configuration is in /etc/scalpel/scalpel.conf. It offers some GPG related rules, but none for a revocation certificate. I used these rules:</p>
<pre lang="">
revoc	y	100000	-----BEGIN\040PGP\040PUBLIC\040KEY\040BLOCK-----\x0aVersion:\040GnuPG\040v1.4.10\040(GNU/Linux)\x0aComment:\040A\040revocation\040certificate\040should\040follow
revoc	y	100000	-----BEGIN\040PGP\040PUBLIC\040KEY\040BLOCK-----\x0aVersion:\040GnuPG\040v1.4.9\040(GNU/Linux)\x0aComment:\040A\040revocation\040certificate\040should\040follow
revoc	y	100000	-----BEGIN\040PGP\040PUBLIC\040KEY\040BLOCK-----\x0aVersion:\040GnuPG\040v1.4.8\040(GNU/Linux)\x0aComment:\040A\040revocation\040certificate\040should\040follow
</pre>
<p>I wasn&#8217;t quite sure which version of GPG I had installed at the time I created the keys, so I created rules for all possible versions. (See <a href="http://manpages.ubuntu.com/manpages/lucid/man1/scalpel.1.html">manpage</a> for syntax explanation.)<br />
It took about 2 hours to scan the image of my 250 GB hard drive and scalpel successfully restored my revocation certificate.<br />
I also tried some of the supplied rules but I think they are not suitable for restoring files from an image of a whole hard drive. (Most of them just look for two bytes that mark the beginning of the file.)</p>
]]></content:encoded>
			<wfw:commentRss>http://moserei.de/index.php/216/find-gnupg-revocation-certificate-on-unmountable-partition/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>slow, slower, activerecord-jdbcsqlite3-adapter</title>
		<link>http://moserei.de/index.php/201/slow-slower-activerecord-jdbcsqlite3-adapter</link>
		<comments>http://moserei.de/index.php/201/slow-slower-activerecord-jdbcsqlite3-adapter#comments</comments>
		<pubDate>Tue, 09 Feb 2010 15:05:42 +0000</pubDate>
		<dc:creator>Moser</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://moserei.de/?p=201</guid>
		<description><![CDATA[I did a little performance test to find out which database to use in a JRuby desktop application. To have a comparison value I also ran the test (insert, find+update, destroy each 500 times) with MRI and the native sqlite3 driver. It revealed that the jdbcsqlite3 adapter is really sloooooooooow:
$ ruby test.rb sqlite3

   [...]]]></description>
			<content:encoded><![CDATA[<p>I did a little performance test to find out which database to use in a JRuby desktop application. To have a comparison value I also ran the test (insert, find+update, destroy each 500 times) with MRI and the native sqlite3 driver. It revealed that the jdbcsqlite3 adapter is really sloooooooooow:</p>
<pre>$ ruby test.rb sqlite3

                 user     system   total     real
insert           0.4500   0.0900   0.5400 (  7.303116)
find and update  0.4900   0.1400   0.6300 (  6.984390)
destroy          0.3300   0.1100   0.4400 (  7.261199)

$ jruby test.rb jdbcsqlite3

                 user     system   total     real
insert          17.2500   0.0000  17.2500 ( 17.250000)
find and update 16.3270   0.0000  16.3270 ( 16.327000)
destroy         15.0900   0.0000  15.0900 ( 15.089000)

$ jruby test.rb h2

                 user     system   total     real
insert           1.9320   0.0000   1.9320 (  1.932000)
find and update  0.7800   0.0000   0.7800 (  0.780000)
destroy          0.3180   0.0000   0.3180 (  0.318000)
</pre>
<p>That&#8217;s what I call an easy decision.</p>
<p>My setup can be downloaded <a href="http://moserei.de/files/ruby/h2_vs_sqlite3.zip">here</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://moserei.de/index.php/201/slow-slower-activerecord-jdbcsqlite3-adapter/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Difference between do-end and {} blocks</title>
		<link>http://moserei.de/index.php/190/difference-between-do-end-and-curly-blocks</link>
		<comments>http://moserei.de/index.php/190/difference-between-do-end-and-curly-blocks#comments</comments>
		<pubDate>Sun, 07 Feb 2010 12:44:41 +0000</pubDate>
		<dc:creator>Moser</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[block precedence]]></category>
		<category><![CDATA[curly]]></category>
		<category><![CDATA[do end]]></category>

		<guid isPermaLink="false">http://moserei.de/?p=190</guid>
		<description><![CDATA[There is a important difference between the two block syntaxes in Ruby: Their precedence.
Consider following code:

def method1&#40;*args&#41;
  puts &#34;method1 got a block&#34; if block_given?
end
&#160;
def method2&#40;*args&#41;
  puts &#34;method2 got a block&#34; if block_given?
end
&#160;
method1 method2 do
end
&#160;
method1 method2 &#123;
&#125;

You would expect both method calls to produce the same result, wouldn&#8217;t you?
Output:

method1 got a block
method2 got a [...]]]></description>
			<content:encoded><![CDATA[<p>There is a important difference between the two block syntaxes in Ruby: Their precedence.<br />
Consider following code:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> method1<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>args<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;method1 got a block&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> block_given?
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> method2<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>args<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;method2 got a block&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> block_given?
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
method1 method2 <span style="color:#9966CC; font-weight:bold;">do</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
method1 method2 <span style="color:#006600; font-weight:bold;">&#123;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>You would expect both method calls to produce the same result, wouldn&#8217;t you?<br />
Output:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">method1 got a block
method2 got a block</pre></div></div>

<p>Obviously the do-end block is passed to the first method in the expression while the {} block is passed to the method called directly before it.<br />
Another example shows that the assignment does not count as a method call here:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#[...]</span>
<span style="color:#9966CC; font-weight:bold;">class</span> Foo
  <span style="color:#9966CC; font-weight:bold;">def</span> bar=<span style="color:#006600; font-weight:bold;">&#40;</span>o<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Foo#bar= got a block&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> block_given?
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
foo = Foo.<span style="color:#9900CC;">new</span>
&nbsp;
foo.<span style="color:#9900CC;">bar</span> = method1 method2 <span style="color:#9966CC; font-weight:bold;">do</span>
<span style="color:#9966CC; font-weight:bold;">end</span> 
<span style="color:#008000; font-style:italic;">#method1 got a block</span>
&nbsp;
foo.<span style="color:#9900CC;">bar</span> = method1 method2 <span style="color:#006600; font-weight:bold;">&#123;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span> 
<span style="color:#008000; font-style:italic;">#method2 got a block</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://moserei.de/index.php/190/difference-between-do-end-and-curly-blocks/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accessing DeviceKit with DBus and Python</title>
		<link>http://moserei.de/index.php/179/accessing-devicekit-with-dbus-and-python</link>
		<comments>http://moserei.de/index.php/179/accessing-devicekit-with-dbus-and-python#comments</comments>
		<pubDate>Fri, 08 Jan 2010 01:23:44 +0000</pubDate>
		<dc:creator>Moser</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[dbus]]></category>
		<category><![CDATA[devicekit]]></category>
		<category><![CDATA[devicekit-disks]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://moserei.de/?p=179</guid>
		<description><![CDATA[Under the impression of loosing some really important data because of a damaged partition table on a USB flash drive I am developing a backup strategy for my system.
I know myself and so I decided that I need to automate this. While trying to figure out how one can run a script as soon as [...]]]></description>
			<content:encoded><![CDATA[<p>Under the impression of loosing some really important data because of a damaged partition table on a USB flash drive I am developing a backup strategy for my system.<br />
I know myself and so I decided that I need to automate this. While trying to figure out how one can run a script as soon as a specific drive is mounted, I came across <a href="http://en.wikipedia.org/wiki/DeviceKit">DeviceKit</a>. It&#8217;s the planned <a href="http://www.freedesktop.org/wiki/Software/hal">replacement of HAL</a> and is used in Ubuntu Karmic. Udev is not an option for me, because I don&#8217;t want to mess around with mounting myself (and I hate running stuff as root&#8230;).<br />
So here is what I found out about using DBus and DeviceKit in Python:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> dbus
&nbsp;
bus = dbus.<span style="color: black;">SystemBus</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
proxy = bus.<span style="color: black;">get_object</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;org.freedesktop.DeviceKit.Disks&quot;</span>, 
                       <span style="color: #483d8b;">&quot;/org/freedesktop/DeviceKit/Disks&quot;</span><span style="color: black;">&#41;</span>
iface = dbus.<span style="color: black;">Interface</span><span style="color: black;">&#40;</span>proxy, <span style="color: #483d8b;">&quot;org.freedesktop.DeviceKit.Disks&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;">#enumerates all devices</span>
<span style="color: #ff7700;font-weight:bold;">print</span> iface.<span style="color: black;">EnumerateDevices</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#gets the device kit path of a specific device</span>
path = iface.<span style="color: black;">FindDeviceByDeviceFile</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/dev/sdc1&quot;</span><span style="color: black;">&#41;</span> 
<span style="color: #808080; font-style: italic;">#= &quot;/org/freedesktop/DeviceKit/Disks/devices/sdc&quot;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#gets an object representing the device specified by the path</span>
device = bus.<span style="color: black;">get_object</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;org.freedesktop.DeviceKit.Disks&quot;</span>, path<span style="color: black;">&#41;</span> 
&nbsp;
<span style="color: #808080; font-style: italic;">#prints some XML that shows you the available methods, signals and properties</span>
<span style="color: #ff7700;font-weight:bold;">print</span> device.<span style="color: black;">Introspect</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#gets a proxy for getting properties</span>
device_prop = dbus.<span style="color: black;">Interface</span><span style="color: black;">&#40;</span>device, <span style="color: #483d8b;">&quot;org.freedesktop.DBus.Properties&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#you need to specify an interface (properties could be ambiguous)</span>
<span style="color: #ff7700;font-weight:bold;">print</span> device_prop.<span style="color: black;">Get</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;org.freedesktop.DeviceKit.Disks.Device&quot;</span>, <span style="color: #483d8b;">&quot;device-mount-paths&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#gets a proxy you can call methods on</span>
device_iface = dbus.<span style="color: black;">Interface</span><span style="color: black;">&#40;</span>device, <span style="color: #483d8b;">&quot;org.freedesktop.DeviceKit.Disks.Device&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#unmounts the partition</span>
device_iface.<span style="color: black;">FilesystemUnmount</span><span style="color: black;">&#40;</span>dbus.<span style="color: black;">Array</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>, <span style="color: #483d8b;">'s'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>The DBus API of DeviceKit is documented <a href="http://hal.freedesktop.org/docs/DeviceKit-disks/ref-dbus.html">here</a>.<br />
Now we want to be notified when a drive is mounted:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> dbus
<span style="color: #ff7700;font-weight:bold;">import</span> gobject
<span style="color: #ff7700;font-weight:bold;">from</span> dbus.<span style="color: black;">mainloop</span>.<span style="color: black;">glib</span> <span style="color: #ff7700;font-weight:bold;">import</span> DBusGMainLoop
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> device_added_callback<span style="color: black;">&#40;</span>device<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Device %s was added'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>device<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> device_changed_callback<span style="color: black;">&#40;</span>device<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Device %s was changed'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>device<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#must be done before connecting to DBus</span>
DBusGMainLoop<span style="color: black;">&#40;</span>set_as_default=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
&nbsp;
bus = dbus.<span style="color: black;">SystemBus</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
proxy = bus.<span style="color: black;">get_object</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;org.freedesktop.DeviceKit.Disks&quot;</span>, 
                       <span style="color: #483d8b;">&quot;/org/freedesktop/DeviceKit/Disks&quot;</span><span style="color: black;">&#41;</span>
iface = dbus.<span style="color: black;">Interface</span><span style="color: black;">&#40;</span>proxy, <span style="color: #483d8b;">&quot;org.freedesktop.DeviceKit.Disks&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#addes two signal listeners</span>
iface.<span style="color: black;">connect_to_signal</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'DeviceAdded'</span>, device_added_callback<span style="color: black;">&#41;</span>
iface.<span style="color: black;">connect_to_signal</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'DeviceChanged'</span>, device_changed_callback<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#start the main loop</span>
mainloop = gobject.<span style="color: black;">MainLoop</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
mainloop.<span style="color: black;">run</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>A typical output when a flash drive is plugged in looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Device <span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>DeviceKit<span style="color: #000000; font-weight: bold;">/</span>Disks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>sdc was added
Device <span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>DeviceKit<span style="color: #000000; font-weight: bold;">/</span>Disks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>sdc1 was added
Device <span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>freedesktop<span style="color: #000000; font-weight: bold;">/</span>DeviceKit<span style="color: #000000; font-weight: bold;">/</span>Disks<span style="color: #000000; font-weight: bold;">/</span>devices<span style="color: #000000; font-weight: bold;">/</span>sdc1 was changed</pre></div></div>

<p>With this knowledge I&#8217;m currently working on a little python script that runs in background and executes a shell script when a file system is mounted. I&#8217;ll post it, when it&#8217;s finished <img src='http://moserei.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://moserei.de/index.php/179/accessing-devicekit-with-dbus-and-python/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sequel single table inheritance</title>
		<link>http://moserei.de/index.php/164/sequel-single-table-inheritance</link>
		<comments>http://moserei.de/index.php/164/sequel-single-table-inheritance#comments</comments>
		<pubDate>Tue, 20 Oct 2009 22:08:24 +0000</pubDate>
		<dc:creator>Moser</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[sequel]]></category>
		<category><![CDATA[single table inheritance]]></category>
		<category><![CDATA[sti]]></category>

		<guid isPermaLink="false">http://moserei.de/?p=164</guid>
		<description><![CDATA[Sequel&#8217;s STI is not so well documented as ActiveRecord&#8217;s is. Because it cost me about 20 minutes to find out about it&#8217;s syntax, I post a little example.

class A &#60; Sequel::Model
  plugin :single_table_inheritance, :object_type
end
&#160;
class B &#60; A
end

The second argument is the name of the column to be used to store the class name in [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sequel.rubyforge.org/">Sequel</a>&#8217;s STI is not so well documented as ActiveRecord&#8217;s is. Because it cost me about 20 minutes to find out about it&#8217;s syntax, I post a little example.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> A <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">Sequel::Model</span>
  plugin <span style="color:#ff3333; font-weight:bold;">:single_table_inheritance</span>, <span style="color:#ff3333; font-weight:bold;">:object_type</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> B <span style="color:#006600; font-weight:bold;">&lt;</span> A
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>The second argument is the name of the column to be used to store the class name in DB. Don&#8217;t use &#8216;type&#8217; here, it collides with Ruby&#8217;s Object#type.<br />
This works with version 3.5.0 and should work with any version >= 2.12.0.</p>
]]></content:encoded>
			<wfw:commentRss>http://moserei.de/index.php/164/sequel-single-table-inheritance/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Monkeybars &#8211; Little bug</title>
		<link>http://moserei.de/index.php/149/monkeybars-little-bug</link>
		<comments>http://moserei.de/index.php/149/monkeybars-little-bug#comments</comments>
		<pubDate>Thu, 10 Sep 2009 19:31:22 +0000</pubDate>
		<dc:creator>Moser</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[monkeybars]]></category>

		<guid isPermaLink="false">http://moserei.de/?p=149</guid>
		<description><![CDATA[For a little side project I am currently evaluating different ways of GUI programming using Ruby. Monkeybars is one of the most interesting candidates. There is a really good article about it, if you want to learn more.
Version 1.0.4 has a little, but annoying bug: If you generate a new application skeleton it won&#8217;t compile/run:

manifest.rb:32:in [...]]]></description>
			<content:encoded><![CDATA[<p>For a little side project I am currently evaluating different ways of GUI programming using Ruby. <a href="http://monkeybars.rubyforge.org/">Monkeybars</a> is one of the most interesting candidates. There is a really good <a href="http://www.ibm.com/developerworks/library/j-monkeybars/index.html">article</a> about it, if you want to learn more.<br />
Version 1.0.4 has a little, but annoying bug: If you generate a new application skeleton it won&#8217;t compile/run:</p>
<pre>
manifest.rb:32:in `require': no such file to load -- monkeybars (LoadError)
	from manifest.rb:32
	from manifest.rb:21:in `require'
	from main.rb:21
</pre>
<p>To fix it, you got to change line 21 of manifest.rb:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">add_to_classpath <span style="color:#996600;">'../lib/java/monkeybars-1.0.2.jar'</span>
<span style="color:#008000; font-style:italic;">#to</span>
add_to_classpath <span style="color:#996600;">'../lib/java/monkeybars-1.0.4.jar'</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://moserei.de/index.php/149/monkeybars-little-bug/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>First time &gt; 500 km</title>
		<link>http://moserei.de/index.php/134/first-time-500-km</link>
		<comments>http://moserei.de/index.php/134/first-time-500-km#comments</comments>
		<pubDate>Thu, 13 Aug 2009 16:11:07 +0000</pubDate>
		<dc:creator>Moser</dc:creator>
				<category><![CDATA[soaring]]></category>

		<guid isPermaLink="false">http://moserei.de/?p=134</guid>
		<description><![CDATA[On last Wednesday I had to write my last test for this semester. As the long term soaring forecast looked quite good I decided to skip the party on the evening and to drive home (i.e. the airfield) instead. The weather report for Thursday promised us good but blue (no clouds that mark the upper [...]]]></description>
			<content:encoded><![CDATA[<p>On last Wednesday I had to write my last test for this semester. As the long term soaring forecast looked quite good I decided to skip the party on the evening and to drive home (i.e. the airfield) instead. The weather report for Thursday promised us good but blue (no <a href="http://en.wikipedia.org/wiki/Cumulus_cloud">clouds</a> that mark the upper ends of thermals) conditions. I don&#8217;t really like flying on blue days as you can never be sure if there is still thermal activity where you are heading, but I was quite motivated because I did not fly cross country for nearly two months.<br />
On Thursday morning Daniel and I assembled the <a href="http://en.wikipedia.org/wiki/Schempp-Hirth_Ventus_2">Ventus 2cx</a> [Thanks btw <img src='http://moserei.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> ] and I put in 58 liters of water ballast.<br />
At 11 AM me and some of our guests from Hamburg were ready for tow. Fortunately the weather forecast was not entirely correct: We already saw some clouds develop.</p>
<p>At 11.47 AM (local) I released the tow rope a little north western of Cham in about 700 m AGL (above ground level). My first thermal wasn&#8217;t good (or I just did not get it the right way). So I proceeded a little further north, lost some more height and found myself in weak, narrow thermal. I decided to drop my water ballast which probably was wrong. Afterwards the thermal improved and I could fly on to the north. Within the first hour I seldom was higher than 1000 m AGL. When I passed Weiden the altitude of the cloud base and the thermals&#8217; strength improved and I got faster. The Fichtelgebirge provided me with some strong lift and soon I passed Kulmbach. </p>
<p><a href="http://www.zooomr.com/photos/moser/7959501/" title="Sonneberg"><img src="http://static.zooomr.com/images/7959501_91fc592428.jpg" width="500" height="375" alt="Sonneberg" /></a><br />
<em>Sonneberg</em></p>
<p>Overhead Sonneberg I entered the Thuringian Forest. Some kilometers before Suhl I turned back southward. All in all I had to thermal too much for my taste on the first leg.</p>
<p><a href="http://www.zooomr.com/photos/moser/7959516/" title="Bridge"><img src="http://static.zooomr.com/images/7959516_1f4f74a60c.jpg" width="500" height="375" alt="New Railway bridge" /></a><br />
<em>Bridge construction site on the <a href="http://en.wikipedia.org/wiki/Nuremberg%E2%80%93Erfurt_high-speed_railway#Ebensfeld.E2.80.93Erfurt_new_line">Nuremberg–Erfurt high-speed railway</a></em></p>
<p>On the way back south I did a better job and did not thermal much until I was south of Tirschenreuth. A <a href="http://www.onlinecontest.org/olc-2.0/gliding/flightinfo.html?dsId=1004623">Janus</a> joined me in close formation for some 40 Km. In order to stretch the flight a little I went on to the south east of Cham and turned near Bischofsmais.</p>
<p>From there I planned my final glide which was quite tight and got tighter due to some strong downdrafts in the area where I turned. But I was lucky and hit some thermals on the glide home. The second one was quite strong and I decided to gain any height I could get in order to make some extra kilometers. I again passed Cham and flew on to the north west. I could use some calm evening thermals, turned at Neunburg vorm Wald for the last time and went home fast.</p>
<p>With a distance of 529 Km and a duration of 6 hours and 37 minutes this was my farthest and longest flight. Because of the high amount of traffic and the sometimes rough thermals I only took a few pictures today.</p>
<p>Here is the flight on the <a href="http://www.onlinecontest.org/olc-2.0/gliding/flightinfo.html?flightId=-257703970">OLC</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://moserei.de/index.php/134/first-time-500-km/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>xkcd rocks</title>
		<link>http://moserei.de/index.php/127/xkcd-rocks</link>
		<comments>http://moserei.de/index.php/127/xkcd-rocks#comments</comments>
		<pubDate>Mon, 20 Jul 2009 06:39:30 +0000</pubDate>
		<dc:creator>Moser</dc:creator>
				<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://moserei.de/?p=127</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><a href="http://xkcd.com/612/"><img src="http://imgs.xkcd.com/comics/estimation.png" alt="Estimation (xkcd)" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://moserei.de/index.php/127/xkcd-rocks/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>massage passing as means of coordination</title>
		<link>http://moserei.de/index.php/125/massage-passing-as-means-of-coordination</link>
		<comments>http://moserei.de/index.php/125/massage-passing-as-means-of-coordination#comments</comments>
		<pubDate>Wed, 01 Jul 2009 15:29:51 +0000</pubDate>
		<dc:creator>Moser</dc:creator>
				<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://moserei.de/?p=125</guid>
		<description><![CDATA[A nice quote found on the slides of our distributed systems lecture:
massage passing as means of coordination
One should try massaging each other to improve a team&#8217;s coordination.  
]]></description>
			<content:encoded><![CDATA[<p>A nice quote found on the slides of our distributed systems lecture:</p>
<blockquote><p>massage passing as means of coordination</p></blockquote>
<p>One should try massaging each other to improve a team&#8217;s coordination. <img src='http://moserei.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://moserei.de/index.php/125/massage-passing-as-means-of-coordination/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActiveRecord: write_attribute and UTC conversion</title>
		<link>http://moserei.de/index.php/113/activerecord-write_attribute-and-utc-conversion</link>
		<comments>http://moserei.de/index.php/113/activerecord-write_attribute-and-utc-conversion#comments</comments>
		<pubDate>Tue, 23 Jun 2009 12:28:46 +0000</pubDate>
		<dc:creator>Moser</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[utc]]></category>
		<category><![CDATA[write_attribute]]></category>

		<guid isPermaLink="false">http://moserei.de/?p=113</guid>
		<description><![CDATA[A little gotcha with custom setters for datetime attributes is, that when setting an attribute through &#8216;write_attribute&#8217; it is not converted to UTC (or whatever else your default time zone is).
This problem can easily be reproduced:

./script/generate model Thing a:datetime b:datetime

My model:

class Thing &#60; ActiveRecord::Base
  def b=&#40;d&#41;
    write_attribute&#40;:b, d&#41;
  end
end

My tests:

require [...]]]></description>
			<content:encoded><![CDATA[<p>A little gotcha with custom setters for datetime attributes is, that when setting an attribute through &#8216;write_attribute&#8217; it is not converted to UTC (or whatever else your default time zone is).<br />
This problem can easily be reproduced:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>script<span style="color: #000000; font-weight: bold;">/</span>generate model Thing a:datetime b:datetime</pre></div></div>

<p>My model:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Thing <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> b=<span style="color:#006600; font-weight:bold;">&#40;</span>d<span style="color:#006600; font-weight:bold;">&#41;</span>
    write_attribute<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:b</span>, d<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>My tests:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'test_helper'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> ThingTest <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveSupport::TestCase</span>
  test <span style="color:#996600;">&quot;a and b&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    d = <span style="color:#CC00FF; font-weight:bold;">DateTime</span>.<span style="color:#9900CC;">now</span>
    t = Thing.<span style="color:#9900CC;">new</span>
    t.<span style="color:#9900CC;">a</span> = d
    t.<span style="color:#9900CC;">b</span> = d
    t.<span style="color:#9900CC;">save</span>
    assert_equal t.<span style="color:#9900CC;">a</span>, t.<span style="color:#9900CC;">b</span>
    t.<span style="color:#9900CC;">reload</span>
    assert_equal t.<span style="color:#9900CC;">a</span>, t.<span style="color:#9900CC;">b</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>The second assertion will fail. Is this intended or a bug?<br />
Quick fix:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#9966CC; font-weight:bold;">def</span> b=<span style="color:#006600; font-weight:bold;">&#40;</span>d<span style="color:#006600; font-weight:bold;">&#41;</span>
    d = d.<span style="color:#9900CC;">utc</span>
    write_attribute<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:b</span>, d<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://moserei.de/index.php/113/activerecord-write_attribute-and-utc-conversion/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
