<?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/"
	>

<channel>
	<title>Nicksda</title>
	<atom:link href="http://nicksda.apotomo.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://nicksda.apotomo.de</link>
	<description>Nick Sutterer's private library.</description>
	<pubDate>Mon, 28 Jun 2010 10:57:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>I don&#8217;t get form_tag</title>
		<link>http://nicksda.apotomo.de/2010/04/i-dont-get-form_tag/</link>
		<comments>http://nicksda.apotomo.de/2010/04/i-dont-get-form_tag/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 15:59:39 +0000</pubDate>
		<dc:creator>nick</dc:creator>
		
		<category><![CDATA[Rails+Magic = me angry]]></category>

		<guid isPermaLink="false">http://nicksda.apotomo.de/?p=215</guid>
		<description><![CDATA[Ok, so I call something like

html_options = &#123;
  :onSubmit =&#62; &#34;new Ajax.Request(\\\&#34;/barn/render_event_response\\\&#34;)&#34;
&#125;
&#160;
form_tag&#40;&#34;barn&#34;, html_options&#41;

Can you see my well-escaped JavaScript?
However, I get

&#34;&#60;form action=\&#34;/barn/render_event_response\&#34; method=\&#34;post\&#34; 
  onsubmit=\&#34;new Ajax.Request(\\&#38;quot;/barn/render_event_response\\&#38;quot;)\&#34;

Why does Rails &#38;quot; my JavaScript? Can anybody help?
]]></description>
			<content:encoded><![CDATA[<p>Ok, so I call something like</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;">html_options = <span style="color:#006600; font-weight:bold;">&#123;</span>
  <span style="color:#ff3333; font-weight:bold;">:onSubmit</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;new Ajax.Request(<span style="color:#000099;">\\</span><span style="color:#000099;">\&quot;</span>/barn/render_event_response<span style="color:#000099;">\\</span><span style="color:#000099;">\&quot;</span>)&quot;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
form_tag<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;barn&quot;</span>, html_options<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>Can you see my <strong>well-escaped JavaScript</strong>?</p>
<p>However, I get</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#996600;">&quot;&lt;form action=<span style="color:#000099;">\&quot;</span>/barn/render_event_response<span style="color:#000099;">\&quot;</span> method=<span style="color:#000099;">\&quot;</span>post<span style="color:#000099;">\&quot;</span> 
  onsubmit=<span style="color:#000099;">\&quot;</span>new Ajax.Request(<span style="color:#000099;">\\</span>&amp;quot;/barn/render_event_response<span style="color:#000099;">\\</span>&amp;quot;)<span style="color:#000099;">\&quot;</span></span></pre></div></div>

<p>Why does Rails <strong>&amp;quot;</strong> my JavaScript? Can anybody help?</p>
]]></content:encoded>
			<wfw:commentRss>http://nicksda.apotomo.de/2010/04/i-dont-get-form_tag/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Releasing with Jeweler</title>
		<link>http://nicksda.apotomo.de/2010/04/releasing-with-jeweler/</link>
		<comments>http://nicksda.apotomo.de/2010/04/releasing-with-jeweler/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 12:19:02 +0000</pubDate>
		<dc:creator>nick</dc:creator>
		
		<category><![CDATA[Git]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://nicksda.apotomo.de/?p=208</guid>
		<description><![CDATA[I love jeweler for releasing my gems, however I tend to forget how it is working, so here&#8217;s my release workflow.
1. Bump and Commit
Bump the version (usually in lib/a_perfect_gem/version.rb) and git commit my latest changes 
2. Doublecheck
git status to check if my working tree is clean

git status
# On branch master
nothing to commit &#40;working directory clean&#41;

Otherwise [...]]]></description>
			<content:encoded><![CDATA[<p>I love <a href="http://github.com/technicalpickles/jeweler">jeweler</a> for releasing my gems, however I tend to forget how it is working, so here&#8217;s my release workflow.</p>
<h3>1. Bump and Commit</h3>
<p>Bump the version (usually in <code>lib/a_perfect_gem/version.rb</code>) <strong>and</strong> <code>git commit</code> my latest changes </p>
<h3>2. Doublecheck</h3>
<p><code>git status</code> to check if my working tree is <strong>clean</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">git status
<span style="color: #666666; font-style: italic;"># On branch master</span>
nothing to commit <span style="color: #7a0874; font-weight: bold;">&#40;</span>working directory clean<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Otherwise jeweler will complain</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">$ rake release
rake aborted<span style="color: #000000; font-weight: bold;">!</span>
Hey buddy, try committing them files first</pre></div></div>

<h3>3. Release</h3>
<p>Finally do</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">$ rake release</pre></div></div>

<p>which will</p>
<ul>
<li>tag the commit with <code>"v#{A_PERFECT_GEM::VERSION}"</code></li>
<li>push the commit(s) to origin</li>
<li>push the tag to origin</li>
<li>build the gem</li>
<li>push the gem to gemcutter</li>
</ul>
<p>Props to [technicalpickles].</p>
]]></content:encoded>
			<wfw:commentRss>http://nicksda.apotomo.de/2010/04/releasing-with-jeweler/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rails::Generator destroys Namespaces</title>
		<link>http://nicksda.apotomo.de/2010/03/railsgenerator-destroys-namespaces/</link>
		<comments>http://nicksda.apotomo.de/2010/03/railsgenerator-destroys-namespaces/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 14:42:36 +0000</pubDate>
		<dc:creator>nick</dc:creator>
		
		<category><![CDATA[Rails+Magic = me angry]]></category>

		<guid isPermaLink="false">http://nicksda.apotomo.de/?p=197</guid>
		<description><![CDATA[The cool thing is that Rails&#8217; script/generator script can be invoked via an API call

Rails::Generator::Scripts::Generate.new.run&#40;%w&#40;controller blog&#41;, :destination =&#62; '/tmp'&#41;

so you can create assets in your code, or test the generator.
Where is my JavascriptGenerator?
The bad thing is, that after you used Rails::Generator, you can&#8217;t rely on autoloading anymore, at least for classes ending with Generator.
When trying [...]]]></description>
			<content:encoded><![CDATA[<p>The cool thing is that Rails&#8217; <code>script/generator</code> script can be invoked <strong>via an API</strong> call</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">Rails::<span style="color:#CC00FF; font-weight:bold;">Generator</span>::Scripts::Generate</span>.<span style="color:#9900CC;">new</span>.<span style="color:#9900CC;">run</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>controller blog<span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#ff3333; font-weight:bold;">:destination</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'/tmp'</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>so you can create assets in your code, or test the generator.</p>
<h3>Where is my JavascriptGenerator?</h3>
<p>The bad thing is, that after you used <code>Rails::Generator</code>, you can&#8217;t rely on autoloading anymore, at least for classes ending with <strong><code>Generator</code></strong>.</p>
<p>When trying to use my own class <code>JavascriptGenerator</code> (which has <strong>nothing</strong> to do with Rails at all) I got</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">JavascriptGenerator::Base</span>.<span style="color:#9900CC;">new</span> <span style="color:#008000; font-style:italic;"># NO rails...</span></pre></div></div>

<p><code>Rails::Generator::GeneratorError: Couldn't find 'javascript' generator</code></p>
<p>which is really annoying. That&#8217;s Rails &#8220;magic&#8221; again (somewhere in rails/generator/&#8230;):</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#CC00FF; font-weight:bold;">Object</span>
  <span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#0000FF; font-weight:bold;">self</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> lookup_missing_generator<span style="color:#006600; font-weight:bold;">&#40;</span>class_id<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> md = <span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#CC00FF; font-weight:bold;">Generator</span>$<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span>class_id.<span style="color:#9900CC;">to_s</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        name = md.<span style="color:#9900CC;">captures</span>.<span style="color:#9900CC;">first</span>.<span style="color:#9900CC;">demodulize</span>.<span style="color:#9900CC;">underscore</span>
        <span style="color:#6666ff; font-weight:bold;">Rails::<span style="color:#CC00FF; font-weight:bold;">Generator</span>::Base</span>.<span style="color:#9900CC;">lookup</span><span style="color:#006600; font-weight:bold;">&#40;</span>name<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">klass</span>
      <span style="color:#9966CC; font-weight:bold;">else</span>
        const_missing_before_generators<span style="color:#006600; font-weight:bold;">&#40;</span>class_id<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>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">unless</span> respond_to?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:const_missing_before_generators</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      alias_method <span style="color:#ff3333; font-weight:bold;">:const_missing_before_generators</span>, <span style="color:#ff3333; font-weight:bold;">:const_missing</span>
      alias_method <span style="color:#ff3333; font-weight:bold;">:const_missing</span>, <span style="color:#ff3333; font-weight:bold;">:lookup_missing_generator</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>That&#8217;s a typical example how Rails assumes things automatically that you don&#8217;t expect.</p>
<p>I personally think that <strong>extending <code>Object</code> should be allowed to non-magicians only</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nicksda.apotomo.de/2010/03/railsgenerator-destroys-namespaces/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Running Ruby 1.9.1 with RVM on Ubuntu karmic</title>
		<link>http://nicksda.apotomo.de/2010/03/running-ruby-191-with-rvm-on-ubuntu-karmic/</link>
		<comments>http://nicksda.apotomo.de/2010/03/running-ruby-191-with-rvm-on-ubuntu-karmic/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 15:58:55 +0000</pubDate>
		<dc:creator>nick</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nicksda.apotomo.de/?p=179</guid>
		<description><![CDATA[It&#8217;s finally time to try out things with Ruby 1.9 - people start complaining that my libs don&#8217;t run with 1.9. Sorry for that. I&#8217;m still sticking to &#8220;Never touch a running system!&#8221;, so why should I use Ruby 1.9 when 1.8 works great?
RVM
First I discovered rvm which is a great tool for hosting different [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s finally time to try out things with Ruby 1.9 - people start complaining that my libs don&#8217;t run with 1.9. Sorry for that. I&#8217;m still sticking to &#8220;Never touch a running system!&#8221;, so why should I use Ruby 1.9 when 1.8 works great?</p>
<h3>RVM</h3>
<p>First I discovered <a href="http://rvm.beginrescueend.com">rvm</a> which is a great tool for hosting different Ruby versions in your shell and <strong>switching environments on the fly</strong>.</p>
<p>That&#8217;s</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> rvm</pre></div></div>

<p>Now go and install Ruby 1.9.1 (couldn&#8217;t get 1.9.2 working)</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&gt;</span> rvm <span style="color: #c20cb9; font-weight: bold;">install</span> 1.9.1</pre></div></div>

<p>This will install Ruby 1.9.1 in your home directory, which is awesomely cool.</p>
<p>Switching to the new ruby/gems is nothing more than</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&gt;</span> rvm use 1.9.1</pre></div></div>

<h3>Running Rails</h3>
<p>Things start getting shitty now. When trying to run Rails with ruby 1.9 I got something</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">no such <span style="color: #c20cb9; font-weight: bold;">file</span> to load <span style="color: #660033;">--</span> openssl</pre></div></div>

<p>rvm <a href="http://rvm.beginrescueend.com/packages/openssl/">explains</a> to install the <em>package</em> openssl. That doesn&#8217;t work for me</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">$ rvm package <span style="color: #c20cb9; font-weight: bold;">install</span> openssl
Package <span style="color: #ff0000;">'openssl'</span> is unknown.
Usage: <span style="color: #ff0000;">'rvm package {install,uninstall} {openssl,zlib,readline,iconv,ncurses}'</span></pre></div></div>

<p>which is&#8230; <em>strange</em>.</p>
<hr /></hr>
<p>Note: Wayne <strong>fixed that in the rvm release <a href="http://github.com/wayneeseguin/rvm/commit/4325281e2fcd041e565cf01df9384f718512da6f">0.1.24</a></strong> - so the rest of this article is useless. Thanks, cowboy!</p>
<hr /></hr>
<p>
Following the great directions <a href="http://cjohansen.no/en/ruby/ruby_version_manager_ubuntu_and_openssl">here</a> didn&#8217;t help either, although it&#8217;s a good post.</p>
<p>At some point <code>make</code> failed with</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">error: ruby<span style="color: #000000; font-weight: bold;">/</span>io.h: No such <span style="color: #c20cb9; font-weight: bold;">file</span> or directory</pre></div></div>

<h3>The solution</h3>
<p>I finally ended up fixing it with</p>

<div class="wp_syntax"><div class="code"><pre class="bash 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> libopenssl-ruby1.9.1
$ <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>1.9.1<span style="color: #000000; font-weight: bold;">/</span>i486-linux<span style="color: #000000; font-weight: bold;">/</span>openssl.so ~<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>rubies<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.1-p378<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>1.9.1<span style="color: #000000; font-weight: bold;">/</span>i686-linux<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-R</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>1.9.1<span style="color: #000000; font-weight: bold;">/</span>openssl<span style="color: #000000; font-weight: bold;">*</span> ~<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>rubies<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.1-p378<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>1.9.1<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>and the shit&#8217;s working.</p>
<h3>Installing gems</h3>
<p>rvm provides some decent way to install gems, it works like</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">$ rvm 1.9.2 gem <span style="color: #c20cb9; font-weight: bold;">install</span> cells <span style="color: #660033;">--no-ri</span> <span style="color: #660033;">--no-rdoc</span></pre></div></div>

<p>When running ruby 1.8.7 be sure to install <code>sqlite3-ruby</code>, not <code>sqlite3</code>. The latter version is only for 1.9 and will throw arbitrary</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">NameError: uninitialized constant Encoding</pre></div></div>

<p>Hope that helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://nicksda.apotomo.de/2010/03/running-ruby-191-with-rvm-on-ubuntu-karmic/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Skype complains &#8220;can&#8217;t write to file&#8221; when receiving upload</title>
		<link>http://nicksda.apotomo.de/2010/01/skype-complains-cant-write-to-file-when-receiving-upload/</link>
		<comments>http://nicksda.apotomo.de/2010/01/skype-complains-cant-write-to-file-when-receiving-upload/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 14:28:40 +0000</pubDate>
		<dc:creator>nick</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://nicksda.apotomo.de/?p=175</guid>
		<description><![CDATA[When a friend tried to upload some files via Skype to my PC it kept failing, Skype 2.1.0.47 for Ubuntu complained &#8220;can&#8217;t write to file&#8221; as soon as I accepted the upload.
Here&#8217;s the solution:
First, I created a world-writable directory

mkdir /home/nick/skype-uploads
chmod 777 /home/nick/skype-uploads

I opened the File Transfer dialog, clicked the sprocked icon and selected Change Default [...]]]></description>
			<content:encoded><![CDATA[<p>When a friend tried to upload some files via Skype to my PC it kept failing, Skype 2.1.0.47 for Ubuntu complained &#8220;can&#8217;t write to file&#8221; as soon as I accepted the upload.</p>
<p>Here&#8217;s the solution:</p>
<p>First, I created a world-writable directory</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>skype-uploads
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">777</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>nick<span style="color: #000000; font-weight: bold;">/</span>skype-uploads</pre></div></div>

<p>I opened the <code>File Transfer</code> dialog, clicked the sprocked icon and selected <code>Change Default Download Directory...</code>. After setting that directory to my fresh <code>skype-uploads</code> dir uploads worked!</p>
]]></content:encoded>
			<wfw:commentRss>http://nicksda.apotomo.de/2010/01/skype-complains-cant-write-to-file-when-receiving-upload/feed/</wfw:commentRss>
		</item>
		<item>
		<title>OpenOffice Impress doesn&#8217;t show videos on Ubuntu</title>
		<link>http://nicksda.apotomo.de/2010/01/openoffice-impress-doesnt-show-videos-on-ubuntu/</link>
		<comments>http://nicksda.apotomo.de/2010/01/openoffice-impress-doesnt-show-videos-on-ubuntu/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 17:54:49 +0000</pubDate>
		<dc:creator>nick</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://nicksda.apotomo.de/?p=171</guid>
		<description><![CDATA[After copying a presentation from my laptop to my desktop box (which&#8217;s running OpenOffice.org 3.1.1) the embedded AVI videos didn&#8217;t show up anymore. It turned out that the JRE was missing gstreamer.
The solution

sudo apt-get install ubuntu-restricted-extras

]]></description>
			<content:encoded><![CDATA[<p>After copying a presentation from my laptop to my desktop box (which&#8217;s running OpenOffice.org 3.1.1) the embedded AVI videos didn&#8217;t show up anymore. It turned out that the JRE was missing <code>gstreamer</code>.</p>
<h3>The solution</h3>

<div class="wp_syntax"><div class="code"><pre class="bash 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> ubuntu-restricted-extras</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://nicksda.apotomo.de/2010/01/openoffice-impress-doesnt-show-videos-on-ubuntu/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Perl CGI Scripts are cached after switching to mod_perl</title>
		<link>http://nicksda.apotomo.de/2009/12/perl-cgi-scripts-are-cached-after-switching-to-mod_perl/</link>
		<comments>http://nicksda.apotomo.de/2009/12/perl-cgi-scripts-are-cached-after-switching-to-mod_perl/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 12:56:33 +0000</pubDate>
		<dc:creator>nick</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://nicksda.apotomo.de/?p=168</guid>
		<description><![CDATA[I recently had to port a very old perl project to a new server, which is running mod_perl- that made me some headache as I didn&#8217;t know anything about that environment.
Pages with dynamic form input from CGI::param suddenly seemed to be &#8220;cached&#8221;, the script did process old variables and emitted wrong output. After diggin&#8217; into [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to port a very old perl project to a new server, which is running mod_perl- that made me some headache as I didn&#8217;t know anything about that environment.</p>
<p>Pages with dynamic form input from <code>CGI::param</code> suddenly seemed to be &#8220;cached&#8221;, the script did process old variables and emitted wrong output. After diggin&#8217; into mod_perl with <a href="http://perl.apache.org/docs/1.0/guide/porting.html">this great article</a> the solution was quite easy.</p>
<p>mod_perl somehow keeps a persistent process environment, thus restoring variables declared with <code>my</code>. As I didn&#8217;t want to rewrite the whole thing I simply changed lines like</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">=</span> param<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;type&quot;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>to</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #000066;">local</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">=</span> param<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;type&quot;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>and everything works fine and &#8220;uncached&#8221;. I know there are several pitfalls with <code>local</code> again, anyway, I&#8217;m not into mod_perl, things seem to work and a 10-years old medieval project&#8217;s running again.</p>
]]></content:encoded>
			<wfw:commentRss>http://nicksda.apotomo.de/2009/12/perl-cgi-scripts-are-cached-after-switching-to-mod_perl/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Painless text-editing with Scribes 0.4 on Ubuntu</title>
		<link>http://nicksda.apotomo.de/2009/05/painless-text-editing-with-scribes-04-on-ubuntu/</link>
		<comments>http://nicksda.apotomo.de/2009/05/painless-text-editing-with-scribes-04-on-ubuntu/#comments</comments>
		<pubDate>Fri, 08 May 2009 21:55:32 +0000</pubDate>
		<dc:creator>nick</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://nicksda.apotomo.de/?p=130</guid>
		<description><![CDATA[Colleagues keep laughing at me.
It seems that I missed the point in a programmer&#8217;s life where he faces a shimmering light at the end of the dark terminal tunnel, where he suddently gets enlightened&#8230; and switches to eclipse or Textmate.
Being an IDE-reject I&#8217;m used to work with bare-bones text editors, which support syntax-coloring, a bright [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Colleagues keep laughing at me.<br />
It seems that I missed the point in a programmer&#8217;s life where he faces a shimmering light at the end of the dark terminal tunnel, where he suddently gets enlightened&#8230; and switches to eclipse or Textmate.</p></blockquote>
<p>Being an <strong>IDE-reject</strong> I&#8217;m used to work with bare-bones text editors, which support syntax-coloring, a <em>bright</em> background and a few well-established keyboard shortcuts like Cmd+c Cmd+v.</p>
<p>That&#8217;s all I need.</p>
<p>Ever since I can remember I disliked IDEs and how they suppressed my way of organizing files, tools and minds. And they are slow.</p>
<p>The last 4 years I worked with <a href="http://www.nedit.org/">nedit</a> and my own small file-browser <a href="http://sourceforge.net/projects/kebap/">kebap</a>. Two weeks ago me and my colleague Felix discovered <a href="http://scribes.sourceforge.net/">scribes</a>, a text-editor for Linux written in Python. Dozens of text-editor came and went away in my life, but for some reasons I really like scribes. Some of its key features I already love are</p>
<ul>
<li><strong>streamlined workflows</strong> with a simple and clean UI</li>
<li><strong>jump to files</strong> with the F9 file-dialog by typing their name</li>
<li><strong>code templates</strong> which can be triggered while typing</li>
<li><strong>character pair completion</strong> -yeah i hate to close a bracket and move back the cursor by hand</li>
<li><strong>word completion</strong> while typing remembers phrases you typed, like long function names and cryptic variables</li>
<li><strong>sufficient syntax-coloring</strong> for Ruby and PHP (well that could be better)</li>
</ul>
<p>I really was distracted by the tab-less UI first. &#8220;What a mess!&#8221; came to my mind. A couple of days later I was conviced that the <a href="http://mystilleef.blogspot.com/2006/10/no-tabs-why.html">arrogant attitude</a> of scribes is&#8230; cool.<br />
It&#8217;s useless to organize your docs in tabs, the more docs you open, the sooner you forget which tabpanel holds the code file you&#8217;re looking for. So why not let the F9 file browser keep track of all those files?</p>
<p>Today I noticed that <strong>I had 46 opened scribes documents</strong> - each in a separate window - while programming at work. Since I simply hit F9 and type in a few characters to jump to the file I completely forgot the &#8220;need&#8221; for MDIs, tabs, project managers and other &#8220;tools&#8221;.</p>
<p>  Enough praising, let&#8217;s hit the keyboard.</p>
<h3>Installing scribes 0.4-dev on Ubuntu Jaunty</h3>
<p>The 0.3 version shipped with Ubuntu has some bugs, so I recommend the 0.4 version which is almost stable.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;">sudo apt<span style="color:#006600; font-weight:bold;">-</span>get install bzr libglib2.0<span style="color:#006600; font-weight:bold;">-</span>dev gnome<span style="color:#006600; font-weight:bold;">-</span>common
bzr branch lp:scribes
cd scribes<span style="color:#006600; font-weight:bold;">/</span>
.<span style="color:#006600; font-weight:bold;">/</span>autogen.<span style="color:#9900CC;">sh</span>
make
sudo make install</pre></div></div>

<p>When starting scribes in a terminal, you might get a python exception bitching about<br />
<code>ImportError: No module named gtksourceview2</code></p>
<p>Well, just do</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;">sudo apt<span style="color:#006600; font-weight:bold;">-</span>get install python<span style="color:#006600; font-weight:bold;">-</span>gtksourceview2 python<span style="color:#006600; font-weight:bold;">-</span>gnome2<span style="color:#006600; font-weight:bold;">-</span>desktop<span style="color:#006600; font-weight:bold;">-</span>dev python<span style="color:#006600; font-weight:bold;">-</span>gnome2<span style="color:#006600; font-weight:bold;">-</span>extras<span style="color:#006600; font-weight:bold;">-</span>dev</pre></div></div>

<p>and have fun experiencing a smart, but not too smart editor. Thanks, mystilleef!</p>
]]></content:encoded>
			<wfw:commentRss>http://nicksda.apotomo.de/2009/05/painless-text-editing-with-scribes-04-on-ubuntu/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Running Xubuntu/intrepid on my IBM X31 laptop</title>
		<link>http://nicksda.apotomo.de/2009/03/running-xubuntu-intrepid-on-my-ibm-x31-laptop/</link>
		<comments>http://nicksda.apotomo.de/2009/03/running-xubuntu-intrepid-on-my-ibm-x31-laptop/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 00:58:10 +0000</pubDate>
		<dc:creator>nick</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nicksda.apotomo.de/?p=100</guid>
		<description><![CDATA[After more than a year of marriage my X31 laptop and gutsy had to break up again. I had to upgrade my linux distribution due to some very old, outdated packages. As usual: problems after upgrading. Did I notice that I really hate to upgrade things?
Well, here are some directions which should ease your jump [...]]]></description>
			<content:encoded><![CDATA[<p>After more than a year of marriage my X31 laptop and gutsy had to break up again. I had to upgrade my linux distribution due to some very old, outdated packages. As usual: problems after upgrading. Did I notice that I really hate to upgrade things?<br />
Well, here are some directions which should ease your jump to intrepid.</p>
<p>My current kernel: 2.6.27-11-generic.</p>
<h3>Hibernate and suspend</h3>
<p>One reason I sticked to gutsy was a working hibernate/suspend setup. With intrepid</p>
<ul>
<li>booting for resume crashed after suspend (black screen)</li>
<li>hibernation crashed and left a blinking caps lock LED</li>
</ul>
<p>Well I found out this was my PCMCIA WiFi card- a D-Link DWL-G630. If unplugged, suspend and hibernate seemed to work. All you need to do to fix it is configuring gnome-power-manager correctly (which is the default Ubuntu hibernation subsystem). It needs to unload the kernel module for the WiFi card.</p>
<p>Create the file <code>/etc/pm/config.d/modules</code> if it does not exist already and fill in the line</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;">SUSPEND_MODULES=<span style="color:#996600;">&quot;rt61pci&quot;</span></pre></div></div>

<h3>Wireless and WPA2 encryption</h3>
<p>Ok, so don&#8217;t waste your time trying to log into a WPA2 encrypted wireless network with the built-in Cisco Aironet Wireless 802.11b. <strong>The <code>airo</code> driver in the current kernel only supports WEP.</strong> That sucks. Go and get that D-Link card, it works great.<br />
Anyway, the Aironet still is enabled and sometimes confuses network-manager.</p>
<p>Besides, it is completely nonsense to have two active antennas next to your balls, so switch off the built-in.</p>
<p>The <code>Fn+F5</code> key doesn&#8217;t turn off the beast. We have to use the force again. Instruct modprobe to no longer load the kernel module by editing <code>/etc/modprobe.d/blacklist</code> and add the line</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;">blacklist airo</pre></div></div>

<h3>Flash for Firefox</h3>
<p>Even the Flash installation is nothing more than</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;">sudo apt<span style="color:#006600; font-weight:bold;">-</span>get install flashplugin<span style="color:#006600; font-weight:bold;">-</span>nonfree</pre></div></div>

<p>Don&#8217;t forget to restart your browser- now you can watch p&#8230; eeeer play free flash games again.</p>
<h3>Ruby on Rails</h3>
<p>Install the ruby interpreter and necessary tools with</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;">sudo apt<span style="color:#006600; font-weight:bold;">-</span>get install ruby1.8 ruby1.8<span style="color:#006600; font-weight:bold;">-</span>dev memcached 
  libopenssl<span style="color:#006600; font-weight:bold;">-</span>ruby1.8 libmysqlclient15<span style="color:#006600; font-weight:bold;">-</span>dev</pre></div></div>

<p>but do not install <code>gem</code> using <code>apt-get</code> since it will mess up things. Browse to <a href="http://rubyforge.org/frs/?group_id=126">http://rubyforge.org/frs/?group_id=126</a> and get the newest <code>rubygems</code> package, unpack it and install it with</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;">cd rubygems<span style="color:#006600; font-weight:bold;">-</span>1.3.1
sudo setup.<span style="color:#9900CC;">rb</span>
sudo mv <span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>bin<span style="color:#006600; font-weight:bold;">/</span>gem1.8 <span style="color:#006600; font-weight:bold;">/</span>usr<span style="color:#006600; font-weight:bold;">/</span>bin<span style="color:#006600; font-weight:bold;">/</span>gem</pre></div></div>

<p>Then install necessary gems</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;">sudo gem install rake rdoc memcache<span style="color:#006600; font-weight:bold;">-</span>client system_timer 
  rails mysql</pre></div></div>

<h3>Ok, Ubuntu rocks again</h3>
<p>Retrospectively I have to admit this was the easiest upgrade ever. I could manage the hibernate issue quite quickly (with some help of my buddy Felix). Everything else worked out-of-the-box. Big props and thanks to the (X)ubuntu team!</p>
]]></content:encoded>
			<wfw:commentRss>http://nicksda.apotomo.de/2009/03/running-xubuntu-intrepid-on-my-ibm-x31-laptop/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Receiving Pingbacks on Rails sites</title>
		<link>http://nicksda.apotomo.de/2008/12/receiving-pingbacks-on-rails-sites/</link>
		<comments>http://nicksda.apotomo.de/2008/12/receiving-pingbacks-on-rails-sites/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 22:21:30 +0000</pubDate>
		<dc:creator>nick</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nicksda.localhost/?p=10</guid>
		<description><![CDATA[If you&#8217;ve never heard of pingbacks before, you&#8217;re out. Go home.
Ok, pingbacks are this mysterical feature when you write on your blog A and refer to some article on blog B. After you publish your article on blog A, something happens behind the curtain. Suddenly there&#8217;s a new comment on the blog B article you [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve never heard of <em>pingbacks</em> before, you&#8217;re out. Go home.</p>
<p>Ok, pingbacks are this mysterical feature when you write on your blog A and refer to some article on blog B. After you publish your article on blog A, something happens behind the curtain. Suddenly there&#8217;s a new comment on the blog B article you cited in your text, and this comment <em>links back</em> to your article on your blog A. That&#8217;s called a <strong>pingback</strong>.</p>
<p>Whereas <em>sending</em> a pingback is just a modest effort by fireing some small XML-RPC request, <em>receiving</em> is quite a bunch of work. A pingback&#8217;able site needs to</p>
<ul>
<li>provide an XML-RPC capable server to receive pings</li>
<li>check the refering site&#8217;s article for the link to us</li>
<li>excerpt a piece of content from this refering article on blog A</li>
<li>store the extracted content with the link on the pinged page, maybe as a comment</li>
</ul>
<p>Fortunately, there&#8217;s already a Rails plugin to handle this tedious task, namely <a href="http://github.com/apotonick/pingback_engine/tree">pingback_engine</a> which I wrote as a christmas gift for my friends on the net.</p>
<h3>Receiving Pingbacks with pingback_engine</h3>
<p>To make our Rails app pingback&#8217;able we need to install the engine, setup the server url propagation and then hook in a method for processing incoming pings. That is awesomely easy.</p>
<p><strong>Installation</strong></p>
<p>Inside the rails app directory install the engine, and a needed gem.</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">script<span style="color: #000000; font-weight: bold;">/</span>plugin <span style="color: #c20cb9; font-weight: bold;">install</span> git:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>apotonick<span style="color: #000000; font-weight: bold;">/</span>pingback_engine.git
gem <span style="color: #c20cb9; font-weight: bold;">install</span> hpricot</pre></div></div>

<p>Your Rails app is now capable of receiving pingbacks via XML-RPC.</p>
<p><strong>Propagating the server for auto-discovery</strong></p>
<p>However, if a blog links to you, this blog will usually scan your page to discover the XML-RPC pingback server. What a pingback&#8217;able page should do to propagate this url is described in the <a href="http://hixie.ch/specs/pingback/pingback#TOC2">pingback specification</a>.</p>
<p>It roughly says, to define a pingback-enabled page</p>
<ul>
<li> either return a <code>X-Pingback</code> HTTP header</li>
<li> or provide a special link element in the page HTML header</li>
<li> or do both!</li>
</ul>
<p>In our example, we&#8217;re on the safe side by providing both. I instruct my blog controller to send an <code>X-Pingback</code> header by calling <code>set_xpingback_header</code> in the action that shows my articles.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># file: app/controllers/blog_controller.rb</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> BlogController
    <span style="color:#9966CC; font-weight:bold;">include</span> PingbackHelper
    helper <span style="color:#ff3333; font-weight:bold;">:pingback</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> article
      set_xpingback_header
      <span style="color:#008000; font-style:italic;"># ...</span></pre></div></div>

<p>This will send the respective header with the correct url as soon as some blog tries to auto-discover the address for your XML-RPC pingback server.</p>
<p>Additionally, we provide a special <code>&lt;link ..&gt;</code> element in our application layout so the XML-RPC address is visible everywhere in the app.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"># file: app/views/layouts/application.html.erb
&nbsp;
      ...
      &lt;%= pingback_link_tag %&gt;</pre></div></div>

<p>Now other blogs will find your pingback server if some article links to your site.</p>
<p><strong>Processing an incoming pingback</strong><br />
The only thing we have to implement is the pingback processing method. It&#8217;s currently put at the bottom of the rails environment file. Of course I could just delegate to another class method in some model, but for demonstration purpose it&#8217;s all in one file.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
</pre></td><td class="code"><pre class="ruby ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># file: config/environment.rb.</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># ...</span>
Pingback.<span style="color:#9900CC;">save_callback</span> <span style="color:#9966CC; font-weight:bold;">do</span> |ping|
    comment = ArticleComment.<span style="color:#9900CC;">new</span>
    comment.<span style="color:#9900CC;">author</span>     = ping.<span style="color:#9900CC;">title</span>
    comment.<span style="color:#9900CC;">author_url</span> = ping.<span style="color:#9900CC;">source_uri</span>
    comment.<span style="color:#9900CC;">text</span>       = ping.<span style="color:#9900CC;">content</span>
    comment.<span style="color:#9900CC;">created_at</span> = ping.<span style="color:#9900CC;">time</span>
&nbsp;
    referenced_article = Article.<span style="color:#9900CC;">find_by_url</span><span style="color:#006600; font-weight:bold;">&#40;</span>ping.<span style="color:#9900CC;">target_uri</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">if</span> referenced_article
      comment.<span style="color:#9900CC;">article_id</span> = referenced_article.<span style="color:#9900CC;">id</span>
      comment.<span style="color:#9900CC;">save</span>
&nbsp;
      ping.<span style="color:#9900CC;">reply_ok</span> <span style="color:#008000; font-style:italic;"># report success.</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      <span style="color:#008000; font-style:italic;"># report error:</span>
      ping.<span style="color:#9900CC;">reply_target_uri_does_not_accept_posts</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Easy. Into the block to <code>Pingback.save_callback</code> we get a <code>ping</code> instance, which is enough to process, check and store the incoming pingback.<br />
I just</p>
<ul>
<li> create an <code>ArticleComment</code> instance, which is an ActiveRecord-derived class and represents comments in my blog (line 22)</li>
<li> assign -or map- values from <code>ping</code> to the <code>comment</code></li>
<li> check the ping if it really points to an article in my blog</li>
<li> decide the incoming ping is invalid and discard it (line 37)</li>
<li> or save the comment in my blog and report success  (line 34)</li>
</ul>
<p>Anyway, all we have to do now is to login to some blog (recent Wordpress blogs work great) and publish an article that links to a pingback&#8217;able page on our Rails site. The blog will send us all the information we need to receive the ping, and the pingback_engine will almost do the rest!</p>
<p><strong>Testing manually</strong><br />
For debugging or testing purposes you can also use a test script shipped with the plugin. All you need is your set up rails site and a HTML page accessable on some webserver. The HTML page must link to a pingback-enabled page on your rails site.</p>
<p>By firing</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">pingback_engine $<span style="color: #000000; font-weight: bold;">&gt;</span> script<span style="color: #000000; font-weight: bold;">/</span>send_pingback.rb http:<span style="color: #000000; font-weight: bold;">//</span>site.com<span style="color: #000000; font-weight: bold;">/</span>page_linking_to_us.html http:<span style="color: #000000; font-weight: bold;">//</span>my.rails.site.com<span style="color: #000000; font-weight: bold;">/</span>article-<span style="color: #000000;">31</span></pre></div></div>

<p>you can issue an XML-RPC pingback on the local server and debug things.</p>
<p>However, it should all work as it is shipped, so have fun when making your Rails site pingback&#8217;able!</p>
]]></content:encoded>
			<wfw:commentRss>http://nicksda.apotomo.de/2008/12/receiving-pingbacks-on-rails-sites/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
