<?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>dead fish &#187; Tips</title>
	<atom:link href="http://www.thomaskeller.biz/blog/category/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thomaskeller.biz/blog</link>
	<description>only dead fish swim with the stream</description>
	<lastBuildDate>Tue, 27 Sep 2011 22:59:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Debugging with MacPorts PHP binaries and Eclipse PDT 3.0</title>
		<link>http://www.thomaskeller.biz/blog/2011/09/27/debugging-with-macports-php-binaries-and-eclipse-pdt-3-0/</link>
		<comments>http://www.thomaskeller.biz/blog/2011/09/27/debugging-with-macports-php-binaries-and-eclipse-pdt-3-0/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 23:55:10 +0000</pubDate>
		<dc:creator>Thomas Keller</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[MacPorts]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.thomaskeller.biz/blog/?p=1087</guid>
		<description><![CDATA[You know the times, when things should really go fast and easy, but you fall from one nightmare into another? Tonight was such a night&#8230; but lets start from the beginning. To debug PHP you usually install the excellent XDebug and so did I with the port command sudo port install php5-xdebug. After that php [...]]]></description>
			<content:encoded><![CDATA[<p>You know the times, when things should really go fast and easy, but you fall from one nightmare into another? Tonight was such a night&#8230; but lets start from the beginning.</p>

<p>To debug PHP you usually install the excellent <a href="http://xdebug.org/">XDebug</a> and so did I with the port command <code>sudo port install php5-xdebug</code>. After that <code>php -v</code> greeted me friendly on the command line already:</p>

<pre><code>PHP 5.3.8 (cli) (built: Sep 22 2011 11:42:56) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
  with Xdebug v2.1.1, Copyright (c) 2002-2011, by Derick Rethans
</code></pre>

<p>Eclipse Indigo and Eclipse PDT 3 was already installed, so I thought it should be easy to set up the XDebug debugging option in Eclipse. Under &#8220;PHP > PHP Executables&#8221; I therefor selected <code>/opt/local/bin/php</code> as my CLI version and selected &#8220;xdebug&#8221; as debugging option.</p>

<p>A first test however showed me that the execution of a test script did not load any module into the PHP interpreter beforehand (for reasons I could only guess, because Eclipse error log kept quite). Looking at the output of <code>phpinfo()</code> from my test script and <code>php -i</code> from command line showed me the difference: The PHP option &#8220;Scan this dir for additional .ini files&#8221; was empty when PHP ran inside Eclipse, but was properly set when PHP ran from command line (or in an Apache context).</p>

<p>Asking aunt Google brought up <a href="https://bugs.php.net/bug.php?id=45114">this issue</a> that shed some light into my darkness: The directory where additional modules reside is configured as a compile time option in PHP and defaults to <code>/opt/local/var/db/php5</code> on MacPorts and exactly this can be overridden by either calling PHP with <code>-n -c</code> options or by setting the <code>PHP_INI_SCAN_DIR</code> environment variable.</p>

<p>Having no access to the actual PHP call from inside Eclipse I tried to go down the environment route, but that did not lead to any success. While the variable was recognized as it should on the normal command line (e.g. <code>PHP_INI_SCAN_DIR= php -i</code> disabled the load of additional modules), in Eclipse&#8217; run configuration dialog, in the section environment variables, this was not recognized at all. I tried a little harder and configured the variable inside <code>~/.MacOSX/environment.plist</code>, logged out and in again, restarted Eclipse obviously, but had no luck either.</p>

<p>The only viable solution I came up with was to place all the single <code>extension=</code> and <code>zend_extension=</code> entries directly into my <code>php.ini</code> and disable the individual <code>module.ini</code> files altogether. At least I can now run and debug properly, but this solution is of course far from being ideal &#8211; as soon as I add a new PHP module or want to remove an existing, I have to remember to edit the <code>php.ini</code> myself.</p>

<p>By the way, I also tried to use Zend&#8217;s debugger (and PDT plugin) as an alternative. <a href="http://www.85qm.de/archives/727-Zend-Debugger-for-PHP-5.3.html">While somebody else</a> already ranted about that the Zend guys have been unable to provide the Zend Debugger for PHP 5.3 as a standalone download (which hasn&#8217;t changed to date), PHP 5.2 debugging worked nicely with <a href="http://www.zend.com/en/community/pdt">the old Zend PDT plugin</a>.</p>

<p>Of course, none of my needed PHP modules were loaded and I really needed PHP 5.3 support, so I had to follow the same route the other guy did and downloaded all of the ZendServer glory (a 137MB download, yay) just to get the right <code>ZendDebugger.so</code>. After extracting the <code>.pax.gz</code> archive from the installer package I quickly found it underneath <code>usr/local/zend/lib/debugger/php-5.3.x/</code>, copied it to my extension directory and added an ini file to load that one instead, just to find out shortly afterwards that the Zend binary was <code>i386</code> only and MacPorts of course compiled everything nicely as <code>x86_64</code> &#8211; php was of course unable to load such a module.</p>

<p>Well, the moral of the story is &#8211; go for Xdebug and don&#8217;t loose the track. And, let us all hope that Eclipse PDT is developed further, so the remaining glitches like the one above are fixed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomaskeller.biz/blog/2011/09/27/debugging-with-macports-php-binaries-and-eclipse-pdt-3-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exception chaining in Java</title>
		<link>http://www.thomaskeller.biz/blog/2011/07/25/exception-chaining-in-java/</link>
		<comments>http://www.thomaskeller.biz/blog/2011/07/25/exception-chaining-in-java/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 10:58:31 +0000</pubDate>
		<dc:creator>Thomas Keller</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.thomaskeller.biz/blog/?p=1078</guid>
		<description><![CDATA[If you catch and rethrow exceptions in Java, you probably know about exception chaining already: You simply give the exception you &#8220;wrap&#8221; as second argument to your Exception like this try { ... } catch (Exception e) { throw new CustomException("something went wrong", e); } and if you look at the stack trace of the [...]]]></description>
			<content:encoded><![CDATA[<p>If you catch and rethrow exceptions in Java, you probably know about exception chaining already: You simply give the exception you &#8220;wrap&#8221; as second argument to your Exception like this</p>

<pre><code>try { ... }
catch (Exception e) {
  throw new CustomException("something went wrong", e);
}
</code></pre>

<p>and if you look at the stack trace of the newly thrown exception, the original one is listed as &#8220;Caused by:&#8221;. Now today I had the rather &#8220;usual&#8221; use case of cleanup up a failing action and the cleanup itself was able to throw as well. So I had two causing exceptions and I wanted to conserve both of them, including their complete cause chain, in a new exception. Consider the following example:</p>

<pre><code>try { ... }
catch (Exception e1) {
  try { ... }
  catch (Exception e2) {
     // how to transport e1 and e2 in a new exception here?!
  }
  throw e1;
}
</code></pre>

<p>My idea here was to somehow tack the exception chain of <code>e1</code> onto the exception chain of <code>e2</code>, but Java offered no solution for this. So I hunted for my own one:</p>

<pre><code>public static class ChainedException extends Exception {
  public ChainedException(String msg, Throwable cause) {
    super(msg, cause);
  }
  public void appendRootCause(Throwable cause) {
    Throwable parent = this;
    while (parent.getCause() != null) {
      parent = parent.getCause();
    }
    parent.initCause(cause);
  }
}
</code></pre>

<p>Now I only had to base the exceptions I actually want to chain on <code>ChainedException</code> and was able to do this (in fact I based all of them on this class):</p>

<pre><code>try { ... }
catch (ChainedException e1) {
  try { ... }
  catch (ChainedException e2) {
    e2.appendRootCause(e1);
    throw new ChainedException("cleanup failed", e2);
  }
  throw e1;
}
</code></pre>

<p>Try it out yourself &#8211; you&#8217;ll see the trace of <code>e1</code> at the bottom of the cause chain of <code>e2</code>. Quite nice, eh?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomaskeller.biz/blog/2011/07/25/exception-chaining-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Access the Android menu in VirtualBox on a Mac host</title>
		<link>http://www.thomaskeller.biz/blog/2011/07/13/access-the-android-menu-in-virtualbox-on-a-mac-host/</link>
		<comments>http://www.thomaskeller.biz/blog/2011/07/13/access-the-android-menu-in-virtualbox-on-a-mac-host/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 14:56:47 +0000</pubDate>
		<dc:creator>Thomas Keller</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Free Software]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.thomaskeller.biz/blog/?p=1067</guid>
		<description><![CDATA[If you&#8217;re desperately trying to get the Menu button in an Android x86 installation working under VirtualBox on a Mac OS X host &#8211; whose keyboard of course doesn&#8217;t have this &#8220;context&#8221; / &#8220;menu&#8221; key Windows keyboards have on the right &#8211; you might find the touch-only-device mode in Android x86 handy: Click on the [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re desperately trying to get the <code>Menu</code> button in an <a href="http://www.android-x86.org">Android x86</a> installation working under <a href="http://www.virtualbox.org">VirtualBox</a> on a Mac OS X host &#8211; whose keyboard of course doesn&#8217;t have this &#8220;context&#8221; / &#8220;menu&#8221; key Windows keyboards have on the right &#8211; you might find the touch-only-device mode in Android x86 handy:</p>

<ol>
<li>Click on the clock in the status bar to enable / disable this mode altogether</li>
<li>A swipe from the left to the right emulates the <code>Menu</code> button function</li>
<li>A swipe from right to left emulates the <code>Back</code> button function</li>
<li>Simply clicking on the status bar brings you to the <code>Home</code> screen</li>
</ol>

<p>(<a href="http://www.android-x86.org/documents/touch-only-device-howto">Source</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomaskeller.biz/blog/2011/07/13/access-the-android-menu-in-virtualbox-on-a-mac-host/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ACLs on Mac OS X</title>
		<link>http://www.thomaskeller.biz/blog/2011/06/04/acls-on-mac-os-x/</link>
		<comments>http://www.thomaskeller.biz/blog/2011/06/04/acls-on-mac-os-x/#comments</comments>
		<pubDate>Sat, 04 Jun 2011 22:55:37 +0000</pubDate>
		<dc:creator>Thomas Keller</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.thomaskeller.biz/blog/?p=1040</guid>
		<description><![CDATA[This is a short follow-up of an earlier post where I explained how one can set ACLs on FreeBSD. Today now I&#8217;ll do the same on another BSD variant, namely Mac OS X, and guess what, the guys from Cupertino implemented ACL management in a completely different manner. The first thing to notice is that [...]]]></description>
			<content:encoded><![CDATA[<p>This is a short follow-up of <a title="ACLs on a jailed ZFS volume with FreeBSD" href="http://www.thomaskeller.biz/blog/2010/08/30/acls-on-a-jailed-zfs-volume-with-freebsd/">an earlier post</a> where I explained how one can set ACLs on FreeBSD. Today now I&#8217;ll do the same on another BSD variant, namely Mac OS X, and guess what, the guys from Cupertino implemented ACL management in a completely different manner.</p>

<p>The first thing to notice is that starting with Mac OS X 10.6 (Snow Leopard) ACLs are always enabled and cannot be disabled as in earlier versions. All ACL commands are baked into the <code>chmod</code> command and parsed from a string you give it with the &#8216;+a&#8217; option. The basic syntax here is</p>

<pre><code>$ chmod (+|-|=)a#? '&lt;user&gt; (allow|deny) &lt;list-of-permissions&gt;'
</code></pre>

<p>Since there is no <code>setfacl</code> on Mac OS X, there is no <code>getfacl</code> either, so ACLs are instead queried by the special option <code>-e</code> of <code>ls</code>:</p>

<pre><code>$ ls -le .
[...]
-rw-r--r--+ 1 john users  175  5 Jun 00:23 foo
0: user:dave allow write
</code></pre>

<p>Permissions include the usual <code>read</code>, <code>write</code>, <code>delete</code>, <code>add_file</code>, and <code>add_subdirectory</code> as well as more exotic ones like <code>{read,write}extattr</code>, <code>{read,write}writesecurity</code> and <code>chown</code>. (Read up <code>chmod</code>&#8216;s man page what these are for.)</p>

<p>There are, however, two more important ones to notice, namely <code>file_inherit</code> and <code>directory_inherit</code>. These two let you spread your permissions nicely to sub objects and thus let you for example set up a directory, in which a pool of users is allowed to access, modify and delete each other&#8217;s files:</p>

<pre><code>$ chmod +a 'john allow read,write,delete,add_file,add_subdirectory,file_inherit,directory_inherit' /data
$ chmod +a 'dave allow read,write,delete,add_file,add_subdirectory,file_inherit,directory_inherit' /data
</code></pre>

<p>The above example gives <code>john</code> and <code>dave</code> inherited read, write and delete permissions to all file objects underneath <code>/data</code>.</p>

<p>Since ACLs are executed in order, they can also be set in an ordered manner. <code>chmod</code> has the <code>+a#</code> option for that, where <code>#</code> is the position into which the ACL should be added. Similarily, existing ACLs can be edited with <code>=a#</code>, where again <code>#</code> marks the position of the ACL to edit, and deleted with <code>-a#</code>.</p>

<p>Finally, if one wants to get rid of all ACLs of a specific node,  <code>chmod -N &lt;path&gt;</code> will do the job.</p>

<p>Thats it, have fun playing with ACLs on Mac OS X!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomaskeller.biz/blog/2011/06/04/acls-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>SQLite to MySQL</title>
		<link>http://www.thomaskeller.biz/blog/2011/05/26/sqlite-to-mysql/</link>
		<comments>http://www.thomaskeller.biz/blog/2011/05/26/sqlite-to-mysql/#comments</comments>
		<pubDate>Thu, 26 May 2011 12:18:47 +0000</pubDate>
		<dc:creator>Thomas Keller</dc:creator>
				<category><![CDATA[Free Software]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.thomaskeller.biz/blog/?p=1036</guid>
		<description><![CDATA[Migrating a database dump from SQLite to MySQL can be somewhat of a hassle. After various trials I came up with the following that worked for me quite well: echo .dump &#124; sqlite3 mydb.db &#124;\ egrep -v "\b(BEGIN TRANSACTION&#124;COMMIT&#124;PRAGMA&#124;sqlite_sequence)\b" &#124;\ perl -pe 's/^([^'\''"]*)"([^"]+)"/\1`\2`/' &#124;\ perl -pe 's/\bautoincrement\b/auto_increment/' &#124;\ mysql -uroot mydb The most important line [...]]]></description>
			<content:encoded><![CDATA[<p>Migrating a database dump from SQLite to MySQL can be somewhat of a hassle. After various trials I came up with the following that worked for me quite well:</p>

<pre><code>echo .dump | sqlite3 mydb.db |\
  egrep -v "\b(BEGIN TRANSACTION|COMMIT|PRAGMA|sqlite_sequence)\b" |\
  perl -pe 's/^([^'\''"]*)"([^"]+)"/\1`\2`/' |\
  perl -pe 's/\bautoincrement\b/auto_increment/' |\
  mysql -uroot mydb
</code></pre>

<p>The most important line is probably line 3: SQLite encapsulates all table and column names in double quotes and this is not understood by MySQL, so we&#8217;re replacing them with backticks. One must be careful here, though, because data INSERTs might also contain double quotes and to avoid having these wrongly replaced as well we only replace them until we encounter the first single quote (these are used in SQLite to encapsulate strings).</p>

<p>Line 3 might also have to be called several times in a row in case multi-column indexes are part of the schema as well, as it will only replace the very first, but no subsequent matches. (I couldn&#8217;t get zero-width lookbehind to work properly to remedy this problem; help is welcome.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomaskeller.biz/blog/2011/05/26/sqlite-to-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Search and replace multiple lines across many files</title>
		<link>http://www.thomaskeller.biz/blog/2010/08/11/search-and-replace-multiple-lines-across-many-files/</link>
		<comments>http://www.thomaskeller.biz/blog/2010/08/11/search-and-replace-multiple-lines-across-many-files/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 11:57:10 +0000</pubDate>
		<dc:creator>Thomas Keller</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.thomaskeller.biz/blog/?p=765</guid>
		<description><![CDATA[sed is usually my favourite tool to search and replace things from the command line, but sometimes Perl&#8217;s regexes are far more convenient to use. Recently I found out another reason why Perls -pi -e is superior over plain sed: when you want to change multiple lines in a document! Imagine you have hundreds of [...]]]></description>
			<content:encoded><![CDATA[<p>sed is usually my favourite tool to search and replace things from the command line, but sometimes Perl&#8217;s regexes are far more convenient to use. Recently I found out another reason why Perls <code>-pi -e</code> is superior over plain sed: when you want to change multiple lines in a document!</p>

<p>Imagine you have hundreds of source code files where somebody once had the great idea to add a <strong><em>version</em></strong> property into each class:</p>

<div class="geshi no java"><ol><li class="li1"><div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> Foo</div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">static</span> <span class="kw2">final</span> <span class="kw3">String</span> ___version___ = <span class="st0">&quot;$Version:$&quot;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="co1">// other stuff</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></div>

<p>With Perl the line in question is easy to remove:</p>

<div class="geshi no bash"><ol><li class="li1"><div class="de1">$ <span class="kw1">for</span> <span class="kw2">file</span> <span class="kw1">in</span> $<span class="br0">&#40;</span><span class="kw2">find</span> . -name <span class="st0">&quot;*.java&quot;</span><span class="br0">&#41;</span>; <span class="kw1">do</span> \</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="kw2">cp</span> <span class="re1">$file</span> <span class="re1">$file</span>.bkp; <span class="kw2">perl</span> -pi -e \</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="st0">&quot;s/<span class="es0">\s</span>*public.+___version___.+<span class="es0">\n</span>//g&quot;</span> \</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sy0">&lt;</span> <span class="re1">$file</span>.bkp <span class="sy0">&gt;</span> <span class="re1">$file</span>; <span class="kw2">rm</span> <span class="re1">$file</span>.bkp; <span class="kw1">done</span></div></li></ol></div>

<p>But, there is one problem: Perl processes each line of the file separately when it slurps in the file, which results in unwanted empty lines:</p>

<div class="geshi no java"><ol><li class="li1"><div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> Foo</div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; </div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="co1">// other stuff</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></div>

<p>Then I stumbled upon <a href="http://www.debian-administration.org/articles/298">this article</a> and the solution is to set a special input separator to let Perl slurp in the file as a whole:</p>

<div class="geshi no bash"><ol><li class="li1"><div class="de1">$ <span class="kw1">for</span> <span class="kw2">file</span> <span class="kw1">in</span> $<span class="br0">&#40;</span><span class="kw2">find</span> . -name <span class="st0">&quot;*.java&quot;</span><span class="br0">&#41;</span>; <span class="kw1">do</span> \</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="kw2">cp</span> <span class="re1">$file</span> <span class="re1">$file</span>.bkp; <span class="kw2">perl</span> -p0777i -e \</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;<span class="st0">&quot;s/<span class="es0">\s</span>*public.+___version___.+<span class="es0">\n</span>(<span class="es0">\s</span>*<span class="es0">\n</span>)*/<span class="es0">\n</span>/g&quot;</span> \</div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp;<span class="sy0">&lt;</span> <span class="re1">$file</span>.bkp <span class="sy0">&gt;</span> <span class="re1">$file</span>; <span class="kw2">rm</span> <span class="re1">$file</span>.bkp; <span class="kw1">done</span></div></li></ol></div>

<p>and voila, we get what we want:</p>

<div class="geshi no java"><ol><li class="li1"><div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> Foo</div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="co1">// other stuff</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></div>

<p>Digging a little deeper what <code>-0777</code> actually means leads us to <code>perlrun(1)</code>:</p>

<blockquote>
The special value 00 will cause Perl to slurp files in paragraph mode. The value 0777 will cause Perl to slurp files whole because there is no legal byte with that value.
</blockquote>

<p>Another day saved &#8211; thanks to Perl!</p>

<p>And while we&#8217;re at it, have a look at Rakudo Star, the best Perl 6 compiler which was released just recently. Perl 6 is in my humble opinion one of the well-designed languages I&#8217;ve came across so far, so if you find some time, go over and read the last <a href="http://perl6advent.wordpress.com/2009/12/01/day-1-getting-rakudo/">christmas special</a>, its really worth it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomaskeller.biz/blog/2010/08/11/search-and-replace-multiple-lines-across-many-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tip: Enforce specific key usage for a single SSH connection</title>
		<link>http://www.thomaskeller.biz/blog/2010/02/04/tip-enforce-specific-key-usage-for-a-single-ssh-connection/</link>
		<comments>http://www.thomaskeller.biz/blog/2010/02/04/tip-enforce-specific-key-usage-for-a-single-ssh-connection/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 09:46:32 +0000</pubDate>
		<dc:creator>Thomas Keller</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.thomaskeller.biz/blog/?p=544</guid>
		<description><![CDATA[In case you have to access a very restricted SSH server which only accepts a single key (ie. the one which is set up in ~/.ssh/authorized_keys) and otherwise fails, its the easiest to set the specific key in your local ~/.ssh/config file as follows: Host very.secure.server IdentityFile ~/.ssh/id_dsa IdentitiesOnly true The second entry, IdentitiesOnly, forces [...]]]></description>
			<content:encoded><![CDATA[<p>In case you have to access a very restricted SSH server which only accepts a single key (ie. the one which is set up in <code>~/.ssh/authorized_keys</code>) and otherwise fails, its the easiest to set the specific key in your local <code>~/.ssh/config</code> file as follows:</p>

<p><pre>
Host very.secure.server
    IdentityFile ~/.ssh/id_dsa
    IdentitiesOnly true
</pre></p>

<p>The second entry, <code>IdentitiesOnly</code>, forces SSH to only use known identity files and not look for more available identities f.e. from a running <code>ssh_agent</code> instance (which are always tried in first instance as it seems).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomaskeller.biz/blog/2010/02/04/tip-enforce-specific-key-usage-for-a-single-ssh-connection/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tip: Logging with Symfony &gt;= 1.2</title>
		<link>http://www.thomaskeller.biz/blog/2010/01/25/tip-logging-with-symfony-1-2/</link>
		<comments>http://www.thomaskeller.biz/blog/2010/01/25/tip-logging-with-symfony-1-2/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 15:00:31 +0000</pubDate>
		<dc:creator>Thomas Keller</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.thomaskeller.biz/blog/?p=529</guid>
		<description><![CDATA[Imagine you have a business method in your model which needs to be accessed by two environments: once from a symfony task and once from the web. So far so good, now what if this business method should be able to log contents somewhere visibly, in case of the command line task to console and [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine you have a business method in your model which needs to be accessed by two environments: once from a symfony task and once from the web. So far so good, now what if this business method should be able to log contents somewhere visibly, in case of the command line task to console and to a file and in case of the web application to the default logging mechanisms used there?</p>

<p>Getting the logger in web context is easy, all you have to do is</p>

<div class="geshi no php"><ol><li class="li1"><div class="de1"><span class="re1">$logger</span> <span class="sy0">=</span> sfContext<span class="sy0">::</span><span class="me2">getInstance</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">-&gt;</span><span class="me1">getLogger</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li></ol></div>

<p>but its a little harder to do for the command line task.</p>

<p>By default no symfony context is created for a command line task and even if it is created, the above call returns an instance of <code>sfNoLogger</code>. Logging in command applications happens through the <code>sfTask::logSection()</code> method, which basically throws an event at the created dispatcher in <code>SYMFONYDIR/lib/command/cli.php</code>. There you can also see that an instance of <code>sfCommandLogger</code> is created, but there is no way to get your fingers at this instance, because its purely local.</p>

<p>So what can we do? Parametricizing the business method with the <code>sfTask</code> instance and using the <code>logSection()</code> is obviously no solution, because this would break in web context where no such sfTask instance exists&#8230;</p>

<p>My solution was a bit more straight forward &#8211; I simply decided to not use the task-supplied logging schema at all, but created my own logger like this:</p>

<div class="geshi no php"><ol><li class="li1"><div class="de1"><span class="re1">$dispatcher</span> <span class="sy0">=</span> <span class="kw2">new</span> sfEventDispatcher<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="re1">$logger</span> <span class="sy0">=</span> <span class="kw2">new</span> sfAggregateLogger<span class="br0">&#40;</span><span class="re1">$dispatcher</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="re1">$logger</span><span class="sy0">-&gt;</span><span class="me1">addLogger</span><span class="br0">&#40;</span><span class="kw2">new</span> sfCommandLogger<span class="br0">&#40;</span><span class="re1">$dispatcher</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="co1">// optionally add another file logger</span></div></li>
<li class="li1"><div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span><span class="re1">$logToFile</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="re1">$logger</span><span class="sy0">-&gt;</span><span class="me1">addLogger</span><span class="br0">&#40;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">new</span> sfFileLogger<span class="br0">&#40;</span><span class="re1">$this</span><span class="sy0">-&gt;</span><span class="me1">dispatcher</span><span class="sy0">,</span> <span class="sy0">&#8230;</span><span class="br0">&#41;</span></div></li>
<li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">;</span></div></li>
<li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></div>

<p>Hope this helps somebody.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomaskeller.biz/blog/2010/01/25/tip-logging-with-symfony-1-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Configure Thunderbird 3&#8242;s indexing behaviour</title>
		<link>http://www.thomaskeller.biz/blog/2009/12/24/configure-thunderbird-3s-indexing-behaviour/</link>
		<comments>http://www.thomaskeller.biz/blog/2009/12/24/configure-thunderbird-3s-indexing-behaviour/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 23:01:26 +0000</pubDate>
		<dc:creator>Thomas Keller</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.thomaskeller.biz/blog/?p=510</guid>
		<description><![CDATA[The current version of Thunderbird comes with a terrific global search functionality, but sometimes its cumbersome to watch it reindex the email history if something corrupted the database or to get emails in the search results which you&#8217;re absolutely not interested in (commit messages, f.e.). Unfortunately Thunderbird 3 has only a global option to enable [...]]]></description>
			<content:encoded><![CDATA[<p>The current version of Thunderbird comes with a terrific global search functionality, but sometimes its cumbersome to watch it reindex the email history if something corrupted the database or to get emails in the search results which you&#8217;re absolutely not interested in (commit messages, f.e.).</p>

<p>Unfortunately Thunderbird 3 has only a global option to enable / disable the search database and the indexer, but a smart guy has filled this gap with his extension <a href="https://addons.mozilla.org/en-US/thunderbird/addon/9873">GlodaQuilla</a>. After you&#8217;ve installed it you can configure so-called &#8220;inherited properties&#8221; for every account</p>

<p><a href="http://www.thomaskeller.biz/blog/wp-content/uploads/2009/12/account-properties.gif"><img src="http://www.thomaskeller.biz/blog/wp-content/uploads/2009/12/account-properties-450x171.gif" alt="" title="account-properties" width="450" height="171" class="aligncenter size-medium wp-image-512" /></a></p>

<p>&#8230; and every folder, easily overridable simply by toggling the &#8220;inherit&#8221; option:</p>

<p><a href="http://www.thomaskeller.biz/blog/wp-content/uploads/2009/12/folder-properties.gif"><img src="http://www.thomaskeller.biz/blog/wp-content/uploads/2009/12/folder-properties-450x264.gif" alt="" title="folder-properties" width="450" height="264" class="aligncenter size-medium wp-image-513" /></a></p>

<p>I&#8217;d prefer that the Thunderbird guys would build this right into the product itself, but until that has been done this add-on is a life saver!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomaskeller.biz/blog/2009/12/24/configure-thunderbird-3s-indexing-behaviour/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tip: Ctrl-R with zsh in GNU screen</title>
		<link>http://www.thomaskeller.biz/blog/2009/12/18/tip-ctrl-r-with-zsh-in-gnu-screen/</link>
		<comments>http://www.thomaskeller.biz/blog/2009/12/18/tip-ctrl-r-with-zsh-in-gnu-screen/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 12:34:42 +0000</pubDate>
		<dc:creator>Thomas Keller</dc:creator>
				<category><![CDATA[Debian/Ubuntu Administration]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.thomaskeller.biz/blog/?p=502</guid>
		<description><![CDATA[If you can&#8217;t search the history with zsh in GNU screen, check if Ctrl-R is issued at all through your terminal, ie. by $ cat ^R If this works, append the following keybinding to your ~/.zshrc: bindkey '^R' history-incremental-search-backward (Source)]]></description>
			<content:encoded><![CDATA[<p>If you can&#8217;t search the history with zsh in GNU screen, check if <code>Ctrl-R</code> is issued at all through your terminal, ie. by</p>

<p><pre>
$ cat
^R
</pre></p>

<p>If this works, append the following keybinding to your <code>~/.zshrc</code>:</p>

<p><pre>
bindkey '^R' history-incremental-search-backward
</pre></p>

<p><small>(<a href="http://bbs.archlinux.org/viewtopic.php?id=52173">Source</a>)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thomaskeller.biz/blog/2009/12/18/tip-ctrl-r-with-zsh-in-gnu-screen/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

