<?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>Gerard JP</title>
	<atom:link href="http://www.gerardjp.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gerardjp.com</link>
	<description>What&#039;s in my name?</description>
	<lastBuildDate>Tue, 24 Aug 2010 06:33:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Intelligente evolutie</title>
		<link>http://www.gerardjp.com/2010/08/16/intelligente-evolutie/</link>
		<comments>http://www.gerardjp.com/2010/08/16/intelligente-evolutie/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 12:22:24 +0000</pubDate>
		<dc:creator>Gerard</dc:creator>
				<category><![CDATA[Leven en wijsheid]]></category>
		<category><![CDATA[evolutie]]></category>
		<category><![CDATA[liefde]]></category>
		<category><![CDATA[mens]]></category>
		<category><![CDATA[yoga]]></category>

		<guid isPermaLink="false">http://www.gerardjp.com/?p=920</guid>
		<description><![CDATA[Ik wilde dit artikel eigenlijk &#8220;Macro evolutie&#8221; noemen, onder meer door een innerlijk proces wat me al langere tijd bezigt en ik beschouw als micro evolutie. Maar daar ik vind dat het niet alleen over de schaal gaat waarop evolutie plaats vindt maar ook over de mate van kwaliteit is het uiteindelijk &#8220;Intelligente evolutie&#8221; geworden. [...]]]></description>
			<content:encoded><![CDATA[<p>Ik wilde dit artikel eigenlijk &#8220;Macro evolutie&#8221; noemen, onder meer door een innerlijk proces wat me al langere tijd bezigt en ik beschouw als micro evolutie. Maar daar ik vind dat het niet alleen over de schaal gaat waarop evolutie plaats vindt maar ook over de mate van kwaliteit is het uiteindelijk &#8220;Intelligente evolutie&#8221; geworden.</p>
<p>Het is in feite een gevoel van gebrek aan kader voor het antwoord op de vraag: &#8220;Waar gaan we nou eigenlijk met z&#8217;n alle naar toe. Het bezigt me al veel langer maar het daadwerkelijk schrijven is uiteindelijk getriggerd door het artikel <a href="http://noorderlicht.vpro.nl/artikelen/42301588/">Groei door innovatie</a> op de <a href="http://noorderlicht.vpro.nl/">Noorderlicht website</a> van de VPRO.</p>
<p>Wat me trof in voornoemd artikel is de explosieve groei van bevolking door innovatie. Je hoort in Nederland politici, ooit begonnen door Pim Fortuyn, soms wel eens roepen dat het land vol zit. Tsja, de hele wereld zit vol als je eerder genoemd artikel leest. Ik moet bij dialogen van een dergelijk strekking altijd denken aan een ijzingwekkende maar zeer scherpe metafoor uit de film The Matrix. Daar wordt de mens(heid) vergeleken met een virus dat onophoudelijke alles verbruiken uit de omgeving waarin het leeft.</p>
<p><em>In his speech to Morpheus, he states that he tried to classify the human species, and realized that humans are &#8220;not actually mammals.&#8221; He went on to say, &#8220;Every mammal on this planet instinctively develops a natural equilibrium with the surrounding environment, but you humans do not. You move to an area and you multiply and multiply until every natural resource is consumed. And the only way you can survive is to spread to another area. There is another organism on this planet that follows the same pattern. Do you know what it is? A virus. Human beings are a disease, a cancer of this planet. You are a plague, and we are the cure.&#8221;</em></p>
<p>Toe gegeven; Hij is wat hard, maar daarom niet minder waar. We kunnen wel roepen maar de tijd is echt aangebroken dat we er wat aan gaan doen. Want met mondjes maat groene stroom invoeren red je het niet. En ik zie (te) veel mensen om me heen die gestaag door consumeren. Misschien helpt het als je voordat je iets aanschaft eens denkt: &#8220;Heb ik het echt nodig?&#8221;.</p>
<p>Voorts zou ik graag alle onderwerpen van een lagere emotionele intelligentie even overslaan. Je kent ze vast wel: vrijheid (van meningsuiting), mensenrechten, etc. Een heilig verworven goed, dat is zeker, maar nadenken en verder de toekomst inkijken dan ons eigen bestaan is de tijd wel rijp voor zo lijkt me. En het voorgaande wat dichter bij huis &#8230; &#8216;s avonds met je rond gegeten buik voor de TV hangen en roepen dat het beter moet. De tijd is aangebroken om los te weken van het metaforische bankstel.</p>
<p>De enige manier om ook maar enigzins vast te stellen hoe lang de ons gegeven natuurlijke bronnen van de planeet nog meegaan is mijnsinziens eerst de bevolkings aanwas stoppen. En dan zou ik om mee te beginnen de kinderbijslag afschaffen.</p>
<p>Als de aanwas gestabiliseerd is kunnen we gaan rekenen aan hoe lang alles nog mee gaat. Voorts had <a title="Mens en Spirit website" href="http://www.mensenspirit.nl/" target="_blank">Mens en Spirit</a> in hun partij programma een aardige staan &#8220;We willen daarnaast belasting op arbeid verlagen&#8221; en met belasting verhoging op luxe goederen e.d. gaan we dan best de goede kant uit.</p>
<p>Dus .. Politiek Den Haag .. stimuleer de mens tot zichzelf verbeteren. Denk ook aan het invoeren op lagere scholen van bijvoorbeeld Yoga (of een andere vorm van het kweken van zelfbewustheid) en het bereiden van gezonde voeding. Daar pluk je over een generatie of drie al de vruchten van. Jaja, het leven gaat veel verder dan alleen dat van ons.</p>
<p>Ik buig mezelf sinds kort, met de vrouw van mijn dromen, ook over het onderwerp pedagogiek en vanuit de combinatie &#8220;handelen op gevoel&#8221;, liefde en een intelligente visie is het (leven) geweldig om te doen.</p>
<p>Geen woorden maar daden!</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">
<h2>Groei door innovatie</h2>
</div>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.gerardjp.com/2010/08/16/intelligente-evolutie/&amp;t=Intelligente+evolutie" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Intelligente+evolutie+-+http://b2l.me/anvdqp&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.gerardjp.com/2010/08/16/intelligente-evolutie/&amp;title=Intelligente+evolutie" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.gerardjp.com/2010/08/16/intelligente-evolutie/&amp;title=Intelligente+evolutie" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.gerardjp.com/2010/08/16/intelligente-evolutie/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.gerardjp.com/2010/08/16/intelligente-evolutie/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.gerardjp.com/2010/08/16/intelligente-evolutie/&amp;title=Intelligente+evolutie" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.gerardjp.com/2010/08/16/intelligente-evolutie/&amp;title=Intelligente+evolutie" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.gerardjp.com/2010/08/16/intelligente-evolutie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTTP over SSH &#8230; The full Monty!</title>
		<link>http://www.gerardjp.com/2010/06/07/http-over-ssh-the-full-monty/</link>
		<comments>http://www.gerardjp.com/2010/06/07/http-over-ssh-the-full-monty/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 12:29:53 +0000</pubDate>
		<dc:creator>Gerard</dc:creator>
				<category><![CDATA[All ENGLISH articles]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.gerardjp.com/?p=1301</guid>
		<description><![CDATA[A utterly safe way to access websites over SSH]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking into this because I did not want to spend more money on extra IP addresses for SSL connects. But I do have several websites I want to access encrypted (that is .. not over plain HTTP).</p>
<p>There definitely are some articles (and forum threads) out there that come close, but this is how it&#8217;s done <img src='http://www.gerardjp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h1>Some predefs</h1>
<p>The goal is to be able to connect to multiple VirtualHost&#8217;s on an Apache webserver.</p>
<p>We have a localpc behind a NAT-ed internet connection (yourpc.locality.lan) and the aforementioned publicly accessible webserver on the net somewhere (yourserver.example.com).</p>
<p>I&#8217;m assuming you can already connect to your server via SSH, based on a pub/priv keypair.</p>
<h1>Local to remote</h1>
<p>There are some things that need to be set local AND remote to make sure that Apache knows to which (not publicly accessible) VirtualHost it must redirect your HTTP request. That is, make up a name and put it in your /etc/hosts file and have it resolve to 127.0.0.1. E.g:</p>
<pre>$ cat /etc/hosts
127.0.0.1 localhost

# For ssh tunneling
127.0.0.1 mysuperadminsite.locality.lan</pre>
<p><strong>Important! </strong>You need to put the &#8216;mysuperadminsite&#8217;  entry in your /etc/hosts file on your server as well. Otherwise it won&#8217;t work because Apache can&#8217;t figure out where this needs to go (more on apache config in a sec).</p>
<p>Then, the actual SSH tunnel command is this:</p>
<pre>ssh  -L 9002:mysuperadminsite.locality.lan:80 yourname@yourserver.example.com</pre>
<p>There are ofcourse nicer ways to fully hide/automate the SSH tunnel, but by doing it manually like this you are explicitly remembered that you&#8217;re in &#8216;admin-mode&#8217; <img src='http://www.gerardjp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h1>Apache trickery</h1>
<p>Ok, so how does Apache know where to go when your HTTP request hits the server side? As your mysuperadminsite request is resolved to 127.0.0.1 (on the server), apache needs this as a NameVirtualHost. So put this in your global Apache config somewhere.</p>
<pre># For admin work over SSH
NameVirtualHost 127.0.0.1:80</pre>
<p>Then you create an apache VirtualHost config with a setup like this.</p>
<pre>&lt;VirtualHost 127.0.0.1:80&gt;
	ServerName mysuperadminsite.locality.lan

	# Here you put your docroot, includes, logfile entries and whatever else you want.

&lt;/VirtualHost&gt;</pre>
<p>And so, apache resolves the request to 127.0.0.1 where, based on the X-Header (containing the mysuperadminsite name) sent by your browser, it actually finds a vhost to handle your request.</p>
<p>This is a very safe way to handle your secure access because the VirtualHost is only handled by apache when it comes in on your loopback interface. Moreover FQDN&#8217;s based on &#8220;locality.lan&#8221; are not resolvable in the outside world.</p>
<p>It does however require a second website instance. You could combine an externally accesible VirtualHost by starting your config with this.</p>
<pre>&lt;VirtualHost [external_ip]:80, 127.0.0.1:80&gt;
</pre>
<p>This way you don&#8217;t have to have a second VirtualHost config (and thus website instance) for management. But it&#8217;s easier to overlook going secure and thus have your passwords or whatever sniffed.</p>
<h1>Gotcha&#8217;s</h1>
<p>None that I know of, but feel free to point them out <img src='http://www.gerardjp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Safe computing!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.gerardjp.com/2010/06/07/http-over-ssh-the-full-monty/&amp;t=HTTP+over+SSH+...+The+full+Monty%21" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=HTTP+over+SSH+...+The+full+Monty%21+-+http://b2l.me/anvdxa&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.gerardjp.com/2010/06/07/http-over-ssh-the-full-monty/&amp;title=HTTP+over+SSH+...+The+full+Monty%21" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.gerardjp.com/2010/06/07/http-over-ssh-the-full-monty/&amp;title=HTTP+over+SSH+...+The+full+Monty%21" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.gerardjp.com/2010/06/07/http-over-ssh-the-full-monty/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.gerardjp.com/2010/06/07/http-over-ssh-the-full-monty/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.gerardjp.com/2010/06/07/http-over-ssh-the-full-monty/&amp;title=HTTP+over+SSH+...+The+full+Monty%21" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.gerardjp.com/2010/06/07/http-over-ssh-the-full-monty/&amp;title=HTTP+over+SSH+...+The+full+Monty%21" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.gerardjp.com/2010/06/07/http-over-ssh-the-full-monty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hemelse pindasaus in een hand omdraai</title>
		<link>http://www.gerardjp.com/2010/03/21/hemelse-pindsaus-in-een-hand-omdraai/</link>
		<comments>http://www.gerardjp.com/2010/03/21/hemelse-pindsaus-in-een-hand-omdraai/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 07:50:03 +0000</pubDate>
		<dc:creator>Gerard</dc:creator>
				<category><![CDATA[Recepten]]></category>
		<category><![CDATA[indonesisch]]></category>
		<category><![CDATA[pindasaus]]></category>
		<category><![CDATA[recept]]></category>
		<category><![CDATA[toko]]></category>

		<guid isPermaLink="false">http://www.gerardjp.com/?p=1246</guid>
		<description><![CDATA[Een hemels authentiek pindasaus recept, binnen een kwartierje op tafel.]]></description>
			<content:encoded><![CDATA[<p>Ik heb in mijn leven al dikwijls gerechten uit de Indonesische keuken mogen eten en maken. Zo horen er bij verschillende gerechten ook verschillende pindasauzen. Na lang zoeken, proberen en proeven heb ik uiteindelijk deze super-snel-klaar saus als heerlijk bestempeld. Hij doet het prima op Gado-Gado, maar heb je een BBQ kan je hem ook zo op tafel zetten.</p>
<h2>De ingredienten</h2>
<p>Bij de betere Toko&#8217;s allemaal wel te verkrijgen:</p>
<p style="text-align: center;"><a href="http://www.gerardjp.com/wp-content/uploads/2010/03/IMG_0682.jpg"><img class="aligncenter size-medium wp-image-1260" title="Zakje voor Petjel" src="http://www.gerardjp.com/wp-content/uploads/2010/03/IMG_0682-225x300.jpg" alt="" width="225" height="300" /></a>(Een zakje gemalen pinda&#8217;s met specerijen van 200 gr.)</p>
<p style="text-align: center;"><a href="http://www.gerardjp.com/wp-content/uploads/2010/03/IMG_0681.jpg"><img class="aligncenter size-medium wp-image-1259" title="Zakje voor Gado Gado" src="http://www.gerardjp.com/wp-content/uploads/2010/03/IMG_0681-225x300.jpg" alt="" width="225" height="300" /></a>(Een zakje gemalen pinda&#8217;s van 400 gr.)</p>
<p style="text-align: left;">Als gezegd, al velen soorten geprobeerd maar neem van me aan, een combinatie van voornoemde twee in een verhouding van 1 op 2 is smullen. En dan, om te beginnen i.p.v. alleen water &#8230;</p>
<p style="text-align: center;"><a href="http://www.gerardjp.com/wp-content/uploads/2010/03/IMG_0680.jpg"><img class="aligncenter size-medium wp-image-1258" title="Blikje kokos melk" src="http://www.gerardjp.com/wp-content/uploads/2010/03/IMG_0680-225x300.jpg" alt="" width="225" height="300" /></a>(Een blikje kokos melk van 400 ml.)</p>
<h2>Bereiding</h2>
<p>Tsja, ook niet veel over te zeggen. Oh, zorg dat je een liter water, net gekookt, bij de hand hebt want aan de kokosmelk alleen heb je niet genoeg.</p>
<p>Neem een middelgrote pan, en warm de kokosmelk op tot deze tegen de kook aanloopt.</p>
<p>Voeg er vervolgens 1/3 liter kokend water aan toe.</p>
<p>Toevoegen/roeren van de Petjel (groene zakje).</p>
<p>Toevoegen/roeren van de Gado-Gado (gele zakje).</p>
<p>Vervolgens (gekookt) water toevoegen/roeren tot hij op de gewenste dikte is.</p>
<p>En met roeren bedoel ik goed roeren &#8230; <img src='http://www.gerardjp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  D.w.z. tot de pindasaus  geen klontjes meer bevalt. Dan nog even op laag vuur laten staan zodat hij kan rusten. Het beste is een pan met een dikke bodem om aanbakken te voorkomen.</p>
<p>Belangrijk: Zorg dat je de saus niet te lang hoog laat staan want dan ga je de olie uit de pinda&#8217;s koken en kom er oranje gekleurde olie op je pindasaus te staan. Mocht dit toch het geval zijn, dan kan je dit weer door roeren, of deels afscheppen en weer wat gekookt water toevoegen.</p>
<p>Met wat brocolli en tauge op rijst krijg je dan zoiets:</p>
<p style="text-align: center;"><a href="http://www.gerardjp.com/wp-content/uploads/2010/03/IMG_0683.jpg"><img class="aligncenter size-medium wp-image-1266" title="IMG_0683" src="http://www.gerardjp.com/wp-content/uploads/2010/03/IMG_0683-300x225.jpg" alt="" width="300" height="225" /></a>(ik had toevallig nog wat atjar, maar met komkommer stukjes erbij kan ook)</p>
<p>Selamat Makan!</p>
<p>GrtzG</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.gerardjp.com/2010/03/21/hemelse-pindsaus-in-een-hand-omdraai/&amp;t=Hemelse+pindasaus+in+een+hand+omdraai" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Hemelse+pindasaus+in+een+hand+omdraai+-+http://b2l.me/anvdxb&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.gerardjp.com/2010/03/21/hemelse-pindsaus-in-een-hand-omdraai/&amp;title=Hemelse+pindasaus+in+een+hand+omdraai" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.gerardjp.com/2010/03/21/hemelse-pindsaus-in-een-hand-omdraai/&amp;title=Hemelse+pindasaus+in+een+hand+omdraai" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.gerardjp.com/2010/03/21/hemelse-pindsaus-in-een-hand-omdraai/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.gerardjp.com/2010/03/21/hemelse-pindsaus-in-een-hand-omdraai/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.gerardjp.com/2010/03/21/hemelse-pindsaus-in-een-hand-omdraai/&amp;title=Hemelse+pindasaus+in+een+hand+omdraai" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.gerardjp.com/2010/03/21/hemelse-pindsaus-in-een-hand-omdraai/&amp;title=Hemelse+pindasaus+in+een+hand+omdraai" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.gerardjp.com/2010/03/21/hemelse-pindsaus-in-een-hand-omdraai/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Django FormWizard best .. well .. useful practices</title>
		<link>http://www.gerardjp.com/2010/02/24/django-formwizard-best-well-useful-practices/</link>
		<comments>http://www.gerardjp.com/2010/02/24/django-formwizard-best-well-useful-practices/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 11:10:56 +0000</pubDate>
		<dc:creator>Gerard</dc:creator>
				<category><![CDATA[All ENGLISH articles]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[wizard]]></category>

		<guid isPermaLink="false">http://www.gerardjp.com/?p=1231</guid>
		<description><![CDATA[Django FormWizard usefulness: emulating decorators .. more to come]]></description>
			<content:encoded><![CDATA[<p><em>Edit</em>: After some re-writes of this post it is finally setup in a manor that is clean and failsafe.</p>
<p>After researching and setting up two FormWizards in Django I concluded some things that might be useful to others. Hence this post.</p>
<h2>Having userdata available throughout the wizard</h2>
<p>I&#8217;ve seen some solutions on the net for this but when you handle data from several models over different steps the best way to handle this is using Django&#8217;s session framework. In parse_params() in the beginning and end we repectively get/set data and store our data.</p>
<pre>def parse_params(self, request, *args, **kwargs):
    current_step = self.determine_step(request, *args, **kwargs)
    form = self.get_form(current_step, request.POST)

    # Pickup the dict from the users session or create a new one
    wizdata = request.session.get('wizdata') or {}

    # Your code goes here. E.g. set a value in the dict
    wizdata['some_key'] = 'Some value'

    # Store the possibly changed dict back in the users session.
    request.session['wizdata'] = wizdata
</pre>
<p>So whatever you do with the user data, it&#8217;s safe, and we can access it in any step throughout the wizardry.</p>
<pre>def render_template(self, request, form, previous_fields, step, context=None):
    wizdata = request.session.get('wizdata')

    # Your other code goes here. E.g. a conditional on previously set data.
    if wizdata.get('some_key'):
        # Do something with your data
        wizdata['some_key'] = 'Some other value'

    # And again, simply store the dict in the users session.
    request.session['wizdata'] = wizdata
</pre>
<p>You can imagine that in the parse_params() and the render_template() method you respectively have the &#8216;if current_step == &#8216; or &#8216;if step == &#8216; statements along the way. All having the wizdata dict available.</p>
<p>This also works in the done() method. Simply get the dict one last time from the user session.</p>
<pre>def done(self, request, form_list):
    wizdata = request.session.get('wizdata')

    # Other code here

    # Cleanup
    del request.session['wizdata']
</pre>
<p>Then, for tidyness, at the end of done() we remove the dict from the user session.</p>
<h3>Gotchas</h3>
<p>There can be stale data, in the form of our stored dicts, left behind when wizard sessions are not finished by the user. This also is true for the sessions itself. As stated in the <a title="The Django docs about sessions" href="http://docs.djangoproject.com/en/dev/topics/http/sessions/#clearing-the-session-table" target="_blank">The Django docs about sessions</a> you should clean up the sessions from time to time.</p>
<p>Anybody that has improvements, questions or compliments please drop me a line <img src='http://www.gerardjp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>GrtzG</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.gerardjp.com/2010/02/24/django-formwizard-best-well-useful-practices/&amp;t=Django+FormWizard+best+..+well+..+useful+practices" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Django+FormWizard+best+..+well+..+useful+practices+-+http://b2l.me/anvdxc&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.gerardjp.com/2010/02/24/django-formwizard-best-well-useful-practices/&amp;title=Django+FormWizard+best+..+well+..+useful+practices" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.gerardjp.com/2010/02/24/django-formwizard-best-well-useful-practices/&amp;title=Django+FormWizard+best+..+well+..+useful+practices" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.gerardjp.com/2010/02/24/django-formwizard-best-well-useful-practices/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.gerardjp.com/2010/02/24/django-formwizard-best-well-useful-practices/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.gerardjp.com/2010/02/24/django-formwizard-best-well-useful-practices/&amp;title=Django+FormWizard+best+..+well+..+useful+practices" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.gerardjp.com/2010/02/24/django-formwizard-best-well-useful-practices/&amp;title=Django+FormWizard+best+..+well+..+useful+practices" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.gerardjp.com/2010/02/24/django-formwizard-best-well-useful-practices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MP3 collection filesystem structure</title>
		<link>http://www.gerardjp.com/2010/01/19/mp3-collection-filesystem-structure/</link>
		<comments>http://www.gerardjp.com/2010/01/19/mp3-collection-filesystem-structure/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 14:07:48 +0000</pubDate>
		<dc:creator>Gerard</dc:creator>
				<category><![CDATA[All ENGLISH articles]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[clean]]></category>
		<category><![CDATA[filestructure]]></category>
		<category><![CDATA[mp3]]></category>

		<guid isPermaLink="false">http://www.gerardjp.com/?p=1191</guid>
		<description><![CDATA[A usable specification for naming conventions for MP3 collections. Coverart, track filenames, what to do? Well read this article :)]]></description>
			<content:encoded><![CDATA[<h2>The reason</h2>
<p>I recently <a title="Amarok kicked out the window. Hello Exaile!!" href="http://www.gerardjp.com/2010/01/04/amarok-kicked-out-the-window-hello-exaile/" target="_blank">moved away from amarok and started using Exaile</a> as my favorite audio player. I found out that Exaile automatically displays the cover art when it finds a &#8220;cover.jpg&#8221; in the album folder. Maybe I&#8217;ll start a &#8216;which-player-supports-what&#8217; post some day but don&#8217;t hold your breath <img src='http://www.gerardjp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I was very excited about this because my tast in music is &#8216;not mainstream&#8217; to say the least so all those cover fetcher tools leave a lot of gaps for my album art. Since I started to clean up a bit I wrote down the structure on a note to remember it once and for all. I thought I&#8217;d might as well publish it and so this post was born.</p>
<h2>Folder setup</h2>
<p>It&#8217;s all in folder &#8220;~/Music/&#8221; but that isn&#8217;t that important. The structure is set up as follows:</p>
<pre>Artist/Album/
             cover.jpg
             back.jpg
             info/              # For stuff like lyrics.txt, etc.
                  bookletX.jpg  # booklet images.
                  [back.jpg]    # if info/ exists this file moves here.</pre>
<p>If it&#8217;s a multiple disc album the CD directories are called &#8220;cd1&#8243;, &#8220;cd2&#8243;, so smalls and no spaces. Then the info directory can stay on album-top level, but I place a copy of cover.jpg in all cdX directories so Exaile displays them.</p>
<p>Then if the album is a compilation it&#8217;s placed in this directory (got this from iTunes <img src='http://www.gerardjp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<pre>~/Music/Compilations/</pre>
<p>You can find your Artists tag based because your player indexes those anyway. Assuming you use the tracks artist and not &#8220;Various artists&#8221;.</p>
<h2>Track file naming</h2>
<p>Then for naming the MP3 files themselves. When it&#8217;s a track in a full album:</p>
<pre>01 - Trackname.jpg</pre>
<p>When the track is in an album which is a compilation of various artists:</p>
<pre>01 - Artist - Trackname.jpg</pre>
<p>I noticed,when I used XMBC that it displays the tracks with &#8220;01. Trackname&#8221; even when naming them as above so that is at least understood without ambiguity.</p>
<p>When the track is just a single song:</p>
<pre>Artist - Trackname.jpg</pre>
<p>I have some old cassettes and MD&#8217;s I converted to MP3 in the past which have a Compilation suffix with &#8220;MD&#8221;, &#8220;AC&#8221;, &#8220;LP&#8221; at the end:</p>
<pre>Trilok Gurtu - African Fantasy - Crazy Saints - Compilation MD.mp3</pre>
<h2>TAGs</h2>
<p>Not to much hassle there. The only thing significant is when it&#8217;s a 1-pass MP3 of a full album the track title get&#8217;s some extra information. A full album suffix between brackets and a &#8220;cd1&#8243; addition when it&#8217;s a multiple CD album.</p>
<pre>Logical Progression cd1 (Full album)</pre>
<h2>Geeky</h2>
<p>I think the subject of this post is totally geeky anyway but nevertheless .. Currently in the tags all words get first caps but with words being between brackets like the aformentioned (Full album) only the first word get&#8217;s capitalized. (Although I&#8217;m not sure yet what to do when it&#8217;s a subtitle or name).</p>
<pre>Logical Progression cd1 (Full album)</pre>
<p>I think that covers most of it for now. Hope it&#8217;s helpfull to anyone going bonkers over there MP3 collections.</p>
<p>Suggestions are welcome ofcourse.</p>
<p>GrtzG.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.gerardjp.com/2010/01/19/mp3-collection-filesystem-structure/&amp;t=MP3+collection+filesystem+structure" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=MP3+collection+filesystem+structure+-+http://b2l.me/anvdxd&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.gerardjp.com/2010/01/19/mp3-collection-filesystem-structure/&amp;title=MP3+collection+filesystem+structure" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.gerardjp.com/2010/01/19/mp3-collection-filesystem-structure/&amp;title=MP3+collection+filesystem+structure" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.gerardjp.com/2010/01/19/mp3-collection-filesystem-structure/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.gerardjp.com/2010/01/19/mp3-collection-filesystem-structure/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.gerardjp.com/2010/01/19/mp3-collection-filesystem-structure/&amp;title=MP3+collection+filesystem+structure" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.gerardjp.com/2010/01/19/mp3-collection-filesystem-structure/&amp;title=MP3+collection+filesystem+structure" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.gerardjp.com/2010/01/19/mp3-collection-filesystem-structure/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Amarok kicked out the window. Hello Exaile!!</title>
		<link>http://www.gerardjp.com/2010/01/04/amarok-kicked-out-the-window-hello-exaile/</link>
		<comments>http://www.gerardjp.com/2010/01/04/amarok-kicked-out-the-window-hello-exaile/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 14:57:58 +0000</pubDate>
		<dc:creator>Gerard</dc:creator>
				<category><![CDATA[All ENGLISH articles]]></category>
		<category><![CDATA[Diepe zucht]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[exaile]]></category>
		<category><![CDATA[player]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.gerardjp.com/?p=1165</guid>
		<description><![CDATA[My god, what happend to Amarok. It used to be a great player. The latest version turned into a -non-intuitive-non-flexible-interface- audio player. As Brian says it very eloquently in Songbird vs. Amarok: How not to design a GUI, and currently working on interface design myself. Amarok .. WTF? After reading the Middle pane thread on [...]]]></description>
			<content:encoded><![CDATA[<p>My god, what happend to Amarok. It used to be a great player. The latest version turned into a -non-intuitive-non-flexible-interface- audio player.</p>
<p>As Brian says it very eloquently in <a href="http://briancarper.net/blog/songbird-vs-amarok-how-not-to-design-a-gui" target="_blank">Songbird vs. Amarok: How not to design a GUI</a>, and currently working on interface design myself. Amarok .. WTF?</p>
<p>After reading the <a href="http://forum.kde.org/viewtopic.php?f=121&amp;t=73880" target="_blank">Middle pane thread</a> on the KDE forums I was baffled. Why not add customizable (drag &#8216;n drop) pane widgetry layout? And for the available widgets to fill that middle pane &#8230;</p>
<ul>
<li><em>Wiki info</em> &#8211; How about a browser?!?!</li>
<li><em>Track info</em> &#8211; That&#8217;s already above the playlist.</li>
<li><em>Album info</em> &#8211; With file/folder view you can see what albums you have with one mouse click. (as was Amaroks strong point of critisism once towards iTunes).</li>
<li><em>Lyrics</em> &#8211; Do you think I&#8217;m studying lyrics while I&#8217;m working?</li>
</ul>
<p>And some other fun features:</p>
<ul>
<li>The control buttons &#8211; Way to big, and worse the size is not adjustable. People are not born with visual impairments by default you know.</li>
<li>After upgrading Amarok it decides to hang at 62% every time when it tries to scan my audio collection.</li>
</ul>
<p>I heard a KDE member speak at a dutch conference not to long ago about how KDE has clean code and isn&#8217;t to bloated. Now I know why.</p>
<h1>Exaile</h1>
<p>Looking for that smooth flexible, clean player? then <a href="http://www.exaile.org/" target="_blank">Exaile is the new big thing</a>. It&#8217;s written in Python, supports OSD-notify out of the box. Supports plugins (and then some!). And ofcourse also the usuals like systray support, album cover fetching .. the works.</p>
<p>Props to the developers of Exaile!!</p>
<p>And for Amarok .. I am outta here!</p>
<p>GrtzG</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.gerardjp.com/2010/01/04/amarok-kicked-out-the-window-hello-exaile/&amp;t=Amarok+kicked+out+the+window.+Hello+Exaile%21%21" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Amarok+kicked+out+the+window.+Hello+Exaile%21%21+-+http://b2l.me/anvdxf&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.gerardjp.com/2010/01/04/amarok-kicked-out-the-window-hello-exaile/&amp;title=Amarok+kicked+out+the+window.+Hello+Exaile%21%21" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.gerardjp.com/2010/01/04/amarok-kicked-out-the-window-hello-exaile/&amp;title=Amarok+kicked+out+the+window.+Hello+Exaile%21%21" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.gerardjp.com/2010/01/04/amarok-kicked-out-the-window-hello-exaile/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.gerardjp.com/2010/01/04/amarok-kicked-out-the-window-hello-exaile/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.gerardjp.com/2010/01/04/amarok-kicked-out-the-window-hello-exaile/&amp;title=Amarok+kicked+out+the+window.+Hello+Exaile%21%21" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.gerardjp.com/2010/01/04/amarok-kicked-out-the-window-hello-exaile/&amp;title=Amarok+kicked+out+the+window.+Hello+Exaile%21%21" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.gerardjp.com/2010/01/04/amarok-kicked-out-the-window-hello-exaile/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Reis en bestemming</title>
		<link>http://www.gerardjp.com/2009/12/24/reis-en-bestemming/</link>
		<comments>http://www.gerardjp.com/2009/12/24/reis-en-bestemming/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 14:08:12 +0000</pubDate>
		<dc:creator>Gerard</dc:creator>
				<category><![CDATA[Leven en wijsheid]]></category>
		<category><![CDATA[leven]]></category>
		<category><![CDATA[vergankelijk]]></category>
		<category><![CDATA[zijn]]></category>

		<guid isPermaLink="false">http://www.gerardjp.com/?p=1163</guid>
		<description><![CDATA[Je bent onderweg, ergens naar toe in de drukke stad. Je ziet alle mensen druk met hun ding. Alles waait voorbij als herfst bladeren op de wind. Ik ben wel onderweg maar eigenlijk ben ik er al. Ik zie de klaarheid van dingen. Hier is waar ik hoor te zijn. - GP - Share this [...]]]></description>
			<content:encoded><![CDATA[<p>Je bent onderweg, ergens naar toe in de drukke stad. Je ziet alle mensen druk met hun ding. Alles waait voorbij als herfst bladeren op de wind. Ik ben wel onderweg maar eigenlijk ben ik er al. Ik zie de klaarheid van dingen. Hier is waar ik hoor te zijn.</p>
<p>- GP -</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.gerardjp.com/2009/12/24/reis-en-bestemming/&amp;t=Reis+en+bestemming" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Reis+en+bestemming+-+http://b2l.me/anvdxg&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.gerardjp.com/2009/12/24/reis-en-bestemming/&amp;title=Reis+en+bestemming" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.gerardjp.com/2009/12/24/reis-en-bestemming/&amp;title=Reis+en+bestemming" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.gerardjp.com/2009/12/24/reis-en-bestemming/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.gerardjp.com/2009/12/24/reis-en-bestemming/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.gerardjp.com/2009/12/24/reis-en-bestemming/&amp;title=Reis+en+bestemming" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.gerardjp.com/2009/12/24/reis-en-bestemming/&amp;title=Reis+en+bestemming" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.gerardjp.com/2009/12/24/reis-en-bestemming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django: get distinct field selection</title>
		<link>http://www.gerardjp.com/2009/12/16/django-get-distinct-field-selection/</link>
		<comments>http://www.gerardjp.com/2009/12/16/django-get-distinct-field-selection/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 13:11:55 +0000</pubDate>
		<dc:creator>Gerard</dc:creator>
				<category><![CDATA[All ENGLISH articles]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.gerardjp.com/?p=1131</guid>
		<description><![CDATA[A function for Django that is a simple and safe solution to get a distinct (group by) field selection from a model.]]></description>
			<content:encoded><![CDATA[<p>I recently have been dinging around in <a href="http://www.djangoproject.com/" target="_blank">Django</a>&#8216;s <a href="http://en.wikipedia.org/wiki/Object-relational_mapping" target="_blank">ORM</a> because I needed a certain &#8216;fields &#8230; group by&#8217; selection. I was very impressed by the logic that the Django developers put in there. Especially the joins and aggregations that have been released with version 1.1. However, after a hours of testing and googling, I was not able to solve my problem with it. I needed a distinct selection like this:</p>
<pre>SELECT id, name FROM myapp_model WHERE owner_id='1' GROUP BY name;</pre>
<p>This would have been (easily) possible except for the WHERE clause on ownership that screwed me. Since the SQL statement was that simple I decided to write a bypass function that get&#8217;s the data straight from the database. It&#8217;s readonly access and I dont do anything more with it then create a list of links. Even more so, from a <a href="http://en.wikipedia.org/wiki/KISS_principle" target="_blank">KISS</a> point of view this code is easier to read back after several months.</p>
<p>And for reusability I turned it in to a function. It takes the model and the distinct field, and for my purpose the needed ownership as parameter:</p>
<pre>from django.db import connection

def get_latest_objects(model_name=None, distinct_field=None, user_id=None):
    """ Get lastest distinct selection (as tuples) of a given model
    """
    model_name = model_name.lower()
    query = ("select id,%(distinct_field)s from myapp_%(model_name)s "
                "where owner_id='%(user_id)s' "
                "group by %(distinct_field)s;") % {
                    'model_name': model_name,
                    'distinct_field': distinct_field,
                    'user_id': user_id,
                    }
    cursor = connection.cursor()
    cursor.execute(query)</pre>
<p>There&#8217;s not much to it, I just hope it helps you to avoid &#8216;the hard way&#8217;. And it helps to keeps your view methods more readable because you dont need anything more then this:</p>
<pre>latest_objects = get_latest_objects(model_name='MyModel',
                        distinct_field='name',
                        user_id=request.user.id)</pre>
<p>What is returned (latest_objects) is a list of tuples that you can unpack in your templates straight away. Note that there&#8217;s no error checking in there, because I know what I&#8217;m doing <img src='http://www.gerardjp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Besides, worst case you get back an empty list and possible errors are caught when you write your tests. You do write those don&#8217;t you?</p>
<p>Grtz Gerard.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.gerardjp.com/2009/12/16/django-get-distinct-field-selection/&amp;t=Django%3A+get+distinct+field+selection+" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Django%3A+get+distinct+field+selection++-+http://b2l.me/anvdxj&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.gerardjp.com/2009/12/16/django-get-distinct-field-selection/&amp;title=Django%3A+get+distinct+field+selection+" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.gerardjp.com/2009/12/16/django-get-distinct-field-selection/&amp;title=Django%3A+get+distinct+field+selection+" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.gerardjp.com/2009/12/16/django-get-distinct-field-selection/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.gerardjp.com/2009/12/16/django-get-distinct-field-selection/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.gerardjp.com/2009/12/16/django-get-distinct-field-selection/&amp;title=Django%3A+get+distinct+field+selection+" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.gerardjp.com/2009/12/16/django-get-distinct-field-selection/&amp;title=Django%3A+get+distinct+field+selection+" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.gerardjp.com/2009/12/16/django-get-distinct-field-selection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Het antwoord op de Goudengids (en telefoonboek)</title>
		<link>http://www.gerardjp.com/2009/10/29/het-antwoord-op-de-goudengids-en-telefoonboek/</link>
		<comments>http://www.gerardjp.com/2009/10/29/het-antwoord-op-de-goudengids-en-telefoonboek/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 10:55:37 +0000</pubDate>
		<dc:creator>Gerard</dc:creator>
				<category><![CDATA[Diepe zucht]]></category>
		<category><![CDATA[Diversen]]></category>
		<category><![CDATA[burgerinitiatief]]></category>
		<category><![CDATA[goudengids]]></category>
		<category><![CDATA[oplossing]]></category>

		<guid isPermaLink="false">http://www.gerardjp.com/?p=1090</guid>
		<description><![CDATA[Lees het artikel even uit want onderaan staat waar je de gids kwijt kan. Al is het alleen maar om een statement te maken! Je kent het vast wel, de bezorging van de ongevraagde Goudengids/Telefoonboek. Typisch zo&#8217;n actie van &#8216;we vinden geld belangrijker dan milieu&#8217;. Politiek en de &#8216;Captains of Industry&#8217; hoef je niet te [...]]]></description>
			<content:encoded><![CDATA[<p><em>Lees het artikel even uit want onderaan staat waar je de gids kwijt kan. Al is het alleen maar om een statement te maken!</em></p>
<p>Je kent het vast wel, de bezorging van de ongevraagde Goudengids/Telefoonboek. Typisch zo&#8217;n actie van &#8216;we vinden geld belangrijker dan milieu&#8217;. Politiek en de &#8216;Captains of Industry&#8217; hoef je niet te vragen, want daar is geen land mee te bezeilen. Nou dan doen we het gewoon zelf.</p>
<p style="text-align: center;"><a href="http://www.gerardjp.com/wp-content/uploads/2009/10/IMG_0428.JPG"><img class="alignnone size-medium wp-image-1091" title="IMG_0428" src="http://www.gerardjp.com/wp-content/uploads/2009/10/IMG_0428-300x225.jpg" alt="IMG_0428" width="300" height="225" /></a></p>
<p style="text-align: center;"><strong>Het euvel in kwestie</strong></p>
<p>De initiatiefnemer, die er voor zorgde dat de exemplaren in ons trappenhuis te vinden waren had nog een leuke actie. Ik kreeg een kaartje in de bus waarmee ik kosteloos een uitgebreide versie kon bestellen met daarop een antwoordnummer. He da&#8217;s mooi, dan sturen we de hele stapel terug. Mijn medebewoners vonden het een prima initiatief. Dus ben ik vandaag met mijn lieftallige buurvrouw even naar het postkantoor geweest. Ergo &#8230;</p>
<p><strong>Wil je van de goudengids af</strong>? Gooi hem niet in de papierbak maar ga <strong>naar het postkantoor</strong> en geef hem af <strong>geadresseerd aan</strong>:</p>
<h2 style="text-align: center;">De Telefoongids BV<br />
Antw. nummer 46490<br />
1060 WD  Amsterdam</h2>
<p>En als je van de komende exemplaren af wilt kan je uiteraard hier terecht: <a title="www.stopdetelefoongids.nl" href="http://www.stopdetelefoongids.nl/" target="_blank">www.stopdetelefoongids.nl</a></p>
<p>Of stuur het ingevulde formulier <a title="Opzeggen recht op De Telefoongids &amp; Gouden Gids" href="http://www.gerardjp.com/wp-content/uploads/2009/10/Opzeggen-recht-op-De-Telefoongids-Gouden-Gids.pdf" target="_blank">Opzeggen recht op De Telefoongids &amp; Gouden Gids</a> op (Met dank aan  een andere lieftallige buurvrouw).</p>
<p>(Milieu) bewuste Groeten!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.gerardjp.com/2009/10/29/het-antwoord-op-de-goudengids-en-telefoonboek/&amp;t=Het+antwoord+op+de+Goudengids+%28en+telefoonboek%29" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Het+antwoord+op+de+Goudengids+%28en+telefoonboek%29+-+http://b2l.me/anvdxm&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.gerardjp.com/2009/10/29/het-antwoord-op-de-goudengids-en-telefoonboek/&amp;title=Het+antwoord+op+de+Goudengids+%28en+telefoonboek%29" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.gerardjp.com/2009/10/29/het-antwoord-op-de-goudengids-en-telefoonboek/&amp;title=Het+antwoord+op+de+Goudengids+%28en+telefoonboek%29" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.gerardjp.com/2009/10/29/het-antwoord-op-de-goudengids-en-telefoonboek/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.gerardjp.com/2009/10/29/het-antwoord-op-de-goudengids-en-telefoonboek/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.gerardjp.com/2009/10/29/het-antwoord-op-de-goudengids-en-telefoonboek/&amp;title=Het+antwoord+op+de+Goudengids+%28en+telefoonboek%29" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.gerardjp.com/2009/10/29/het-antwoord-op-de-goudengids-en-telefoonboek/&amp;title=Het+antwoord+op+de+Goudengids+%28en+telefoonboek%29" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.gerardjp.com/2009/10/29/het-antwoord-op-de-goudengids-en-telefoonboek/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Django: QueryScreener, a record level ownership development auditor</title>
		<link>http://www.gerardjp.com/2009/10/26/django-queryscreener-a-record-level-ownership-development-auditor/</link>
		<comments>http://www.gerardjp.com/2009/10/26/django-queryscreener-a-record-level-ownership-development-auditor/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 16:41:12 +0000</pubDate>
		<dc:creator>Gerard</dc:creator>
				<category><![CDATA[All ENGLISH articles]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.gerardjp.com/?p=1049</guid>
		<description><![CDATA[QueryScreener is a middleware development tool that helps to avoid unwanted data disclosure once you go into production. It monitors queries to the models and warns you when queries are executed that lack a ownership clause. ]]></description>
			<content:encoded><![CDATA[<p>During the development stage of a Django app I&#8217;m working on I was exploring how to best implement rowlevel user ownerships. There are several ways to overwrite methods on <a title="Object Managers" href="http://docs.djangoproject.com/en/dev/topics/db/managers/" target="_blank">object managers</a> and even the Django admin interface is properly configurable to take a ownership from &#8220;request.user&#8221;.</p>
<p>But since wrongfull data disclosure is absolutely unacceptable I was still afraid that I would miss something somewhere. A nice example I ran into was populating a dropdown list in a form, where all records were visible instead of only those owned by the logged in user.</p>
<p>That got me thinking and eventually I wrote this small but sweet piece of <a title="Middleware" href="http://docs.djangoproject.com/en/dev/topics/http/middleware/" target="_blank">middleware</a>. Further elaboration below the code.</p>
<pre class="python" name="code">from django.db import connection
import re

"""
QueryScreener is a middleware development tool. This tool helps to avoid
unwanted data disclosure once you go into production.

It monitors queries to the models in your model_list and warns you when queries
are executed that do not contain a ownership where clause. And thus can be a
potential data disclosure hazard.

It requires a owner attribute in your model definition, e.g:

    owner = models.ForeignKey(User, editable=False)

Edit the 'model_list' below for what models should be monitored. And add
QueryScreener to MIDDLEWARE_CLASSES in you settings.py

Note: This can/should only be used while running Django's testserver command
with e.g: ./manage.py runserver 192.168.1.81:8000
"""

class QueryScreener(object):

    model_list = ['myapp_customer', 'myapp_order', 'myapp_product']

    def process_view(self, request, view_func, view_args, view_kwargs):
        if len(connection.queries) &gt; 0:
            query_parse(connection.queries, self.model_list, 'process_view')

    def process_response(self, request, response):
        if len(connection.queries) &gt; 0:
            query_parse(connection.queries, self.model_list, 'process_response')
        return response

def query_parse(self, model_list, caller_process):

    for query in connection.queries:
        for modelname in model_list:
            modelstring = 'FROM `'+modelname

            if re.search(modelstring, query['sql']) and not \
                re.search(r'^SELECT.\(1\).AS', query['sql']):

                reg = re.compile(r'^SELECT.*WHERE.*owner.*(ORDER BY.*)?$',
                                    re.DOTALL)

                if not reg.search(query['sql']):
                    print ('&lt;&lt;&lt; WARNING &gt;&gt;&gt; Query execution without ownership '
                            'clause, called from "' + caller_process + '"')
                    print query['sql']

            if re.search(r'^SELECT.\(1\).AS.`a`.FROM.*WHERE.*$', query['sql']):
                print ('&lt;&lt;&lt; Django Farted &gt;&gt;&gt;')
#                print query['sql']</pre>
<p><em>Update1: The &#8216;ORDER BY&#8217; in the regex needs to be optional.</em><br />
<em>Update2: Django does a &#8216;try update&#8217; in save_base() without owner (seperated the select statement)<br />
</em></p>
<p>The comment in the code above sums up how to get it working. What it does is print a warning and the query in question that does not respect ownership. If enabled while developing just keep track of your console output for:</p>
<pre>&lt;&lt;&lt; WARNING &gt;&gt;&gt; Query execution without ownership clause, called from "process_response"</pre>
<p>Should you  have suggestion, criticism, or words of admiration then please, do tell me <img src='http://www.gerardjp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>GrtzG</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.gerardjp.com/2009/10/26/django-queryscreener-a-record-level-ownership-development-auditor/&amp;t=Django%3A+QueryScreener%2C+a+record+level+ownership+development+auditor+" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Django%3A+QueryScreener%2C+a+record+level+ownership+development+auditor++-+http://b2l.me/anvdxn&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.gerardjp.com/2009/10/26/django-queryscreener-a-record-level-ownership-development-auditor/&amp;title=Django%3A+QueryScreener%2C+a+record+level+ownership+development+auditor+" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.gerardjp.com/2009/10/26/django-queryscreener-a-record-level-ownership-development-auditor/&amp;title=Django%3A+QueryScreener%2C+a+record+level+ownership+development+auditor+" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.gerardjp.com/2009/10/26/django-queryscreener-a-record-level-ownership-development-auditor/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.gerardjp.com/2009/10/26/django-queryscreener-a-record-level-ownership-development-auditor/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.gerardjp.com/2009/10/26/django-queryscreener-a-record-level-ownership-development-auditor/&amp;title=Django%3A+QueryScreener%2C+a+record+level+ownership+development+auditor+" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.gerardjp.com/2009/10/26/django-queryscreener-a-record-level-ownership-development-auditor/&amp;title=Django%3A+QueryScreener%2C+a+record+level+ownership+development+auditor+" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.gerardjp.com/2009/10/26/django-queryscreener-a-record-level-ownership-development-auditor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
