<?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>Code That Matters &#187; henke</title>
	<atom:link href="http://www.codethatmatters.com/author/henke/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codethatmatters.com</link>
	<description>Pylons, rails, jQuery and other stuff that matters</description>
	<lastBuildDate>Sat, 16 Jul 2011 10:57:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Git autocomplete in Mac OS X</title>
		<link>http://www.codethatmatters.com/2010/01/git-autocomplete-in-mac-os-x/</link>
		<comments>http://www.codethatmatters.com/2010/01/git-autocomplete-in-mac-os-x/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 08:23:32 +0000</pubDate>
		<dc:creator>henke</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[autocomplete]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://www.codethatmatters.com/?p=121</guid>
		<description><![CDATA[I always liked that my  Git installations on Unix and Linux comes with the contrib/complete/git-completion.bash script activated or easily activated. But its harder if you use the pre-built binaries for Mac OS X.
To get autocompletion to work on Mac OS X when installing the pre-built binaries do this.
UPDATE: Instead of step 1 and 2 [...]]]></description>
			<content:encoded><![CDATA[<p>I always liked that my  Git installations on Unix and Linux comes with the contrib/complete/git-completion.bash script activated or easily activated. But its harder if you use the pre-built binaries for Mac OS X.</p>
<p>To get autocompletion to work on Mac OS X when installing the pre-built binaries do this.<br />
<strong>UPDATE:</strong> Instead of step 1 and 2 below you can get the completion script directly from Github. <em>Thanks to Fredric.</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">curl http:<span class="sy0">//</span>github.com<span class="sy0">/</span>git<span class="sy0">/</span>git<span class="sy0">/</span>raw<span class="sy0">/</span>master<span class="sy0">/</span>contrib<span class="sy0">/</span>completion<span class="sy0">/</span>git-completion.bash <span class="re5">-O</span></pre></div></div>

<p><strong>UPDATE: 2011-01-03</strong> All github.com url are now https. <em>Thanks to Julio</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">curl https:<span class="sy0">//</span>github.com<span class="sy0">/</span>git<span class="sy0">/</span>git<span class="sy0">/</span>raw<span class="sy0">/</span>master<span class="sy0">/</span>contrib<span class="sy0">/</span>completion<span class="sy0">/</span>git-completion.bash <span class="re5">-O</span></pre></div></div>

<p><strong>UPDATE: 2011-07-15</strong> Added -L option to allow for curl to handle redirects.<em>Thanks to michaelyoung</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">curl https:<span class="sy0">//</span>github.com<span class="sy0">/</span>git<span class="sy0">/</span>git<span class="sy0">/</span>raw<span class="sy0">/</span>master<span class="sy0">/</span>contrib<span class="sy0">/</span>completion<span class="sy0">/</span>git-completion.bash <span class="re5">-OL</span></pre></div></div>

<p>1. Download the Git source from  <a href="http://git-scm.com/">git-scm.com</a>.<br />
2. Unpack and copy the completion script git-completion.bash found in contrib/completion to your home directory.</p>
<p>3. Add the following to your ~/.profile or ~/.bash_profile</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span class="kw3">source</span> ~<span class="sy0">/</span>git-completion.bash
&nbsp;
<span class="kw3">alias</span> <span class="re2">gco</span>=<span class="st_h">'git co'</span>
<span class="kw3">alias</span> <span class="re2">gci</span>=<span class="st_h">'git ci'</span>
<span class="kw3">alias</span> <span class="re2">grb</span>=<span class="st_h">'git rb'</span></pre></div></div>

<p>4. Add the following to your ~/.gitconfig</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span class="br0">&#91;</span><span class="kw3">alias</span><span class="br0">&#93;</span>
<span class="kw2">co</span> = checkout
ci = commit
rb = rebase</pre></div></div>

<p>Restart Terminal and start Tabbin&#8217;!</p>
<p>More Git tips that I found usefull can be found on Tim Dysinger&#8217;s blog <a href="http://dysinger.net/2007/12/30/installing-git-on-mac-os-x-105-leopard">http://dysinger.net/2007/12/30/installing-git-on-mac-os-x-105-leopard</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codethatmatters.com/2010/01/git-autocomplete-in-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Redirect to previous url after delete</title>
		<link>http://www.codethatmatters.com/2009/10/redirect-to-previous-url-after-delete/</link>
		<comments>http://www.codethatmatters.com/2009/10/redirect-to-previous-url-after-delete/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 14:03:31 +0000</pubDate>
		<dc:creator>henke</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[pylons]]></category>
		<category><![CDATA[request]]></category>

		<guid isPermaLink="false">http://www.codethatmatters.com/?p=92</guid>
		<description><![CDATA[Ever wondered how you can easily redirect a user to the previous url? I.e after a users clicks a delete link or some other action you can use the more common url.current() because that points to the delete action. Instead use request.header REFERER like this:
UPDATE: New way of doing this in pylons 1.0 as redirect_to [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wondered how you can easily redirect a user to the previous url? I.e after a users clicks a delete link or some other action you can use the more common url.current() because that points to the delete action. Instead use request.header REFERER like this:<br />
UPDATE: New way of doing this in pylons 1.0 as redirect_to is replaced by redirect. <em>Thanks to DB for pointing that out!</em></p>
<p>(This is a Pylons example)</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">redirect<span class="br0">&#40;</span>url<span class="br0">&#40;</span>request.<span class="me1">referer</span><span class="br0">&#41;</span><span class="br0">&#41;</span></pre></div></div>

<p>Done!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codethatmatters.com/2009/10/redirect-to-previous-url-after-delete/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Unicode in Mako using Pylons</title>
		<link>http://www.codethatmatters.com/2009/10/unicode-in-mako-using-pylons/</link>
		<comments>http://www.codethatmatters.com/2009/10/unicode-in-mako-using-pylons/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 07:18:02 +0000</pubDate>
		<dc:creator>henke</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[mako]]></category>
		<category><![CDATA[pylons]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://www.codethatmatters.com/?p=72</guid>
		<description><![CDATA[Small post regarding unicode support in mako. I learned yesterday that mako not only has input and output encoding options but also an default_filter encoding. In the environment.py file, in your Pylons config folder, you need all these three to be sure that everything is enoded as unicode. Remember though that the default_filters argument can [...]]]></description>
			<content:encoded><![CDATA[<p>Small post regarding unicode support in mako. I learned yesterday that mako not only has input and output encoding options but also an default_filter encoding. In the environment.py file, in your Pylons config folder, you need all these three to be sure that everything is enoded as unicode. Remember though that the default_filters argument can have big impact on performance.</p>
<p><em>(If someone knows the configuration files for other frameworks, please write a comment about it and I&#8217;ll add it to the post)</em></p>
<p>Please read the Mako unicode chapter <a href="http://www.makotemplates.org/docs/unicode.html">here</a> if you want the gory details.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span class="co1">#environment.py</span>
 config<span class="br0">&#91;</span><span class="st0">'pylons.app_globals'</span><span class="br0">&#93;</span>.<span class="me1">mako_lookup</span> = TemplateLookup<span class="br0">&#40;</span>
        input_encoding=<span class="st0">'utf-8'</span>, 
        output_encoding=<span class="st0">'utf-8'</span>, 
        default_filters=<span class="br0">&#91;</span><span class="st0">'decode.utf8'</span><span class="br0">&#93;</span> <span class="br0">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.codethatmatters.com/2009/10/unicode-in-mako-using-pylons/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Serving images directly from database</title>
		<link>http://www.codethatmatters.com/2009/10/serving-images-directly-from-database/</link>
		<comments>http://www.codethatmatters.com/2009/10/serving-images-directly-from-database/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 08:54:13 +0000</pubDate>
		<dc:creator>henke</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[pylons]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.codethatmatters.com/?p=26</guid>
		<description><![CDATA[Even though storing images in the database have its advantages/disadvantages, here is a small guide for those who want to store them in the database and serve them directly to the browser without having to generate a file first. This examples is based on the amazing web framework pylons. 
In this example I want to [...]]]></description>
			<content:encoded><![CDATA[<p>Even though storing images in the database have its advantages/disadvantages, here is a small guide for those who want to store them in the database and serve them directly to the browser without having to generate a file first. This examples is based on the amazing web framework <a href="http://www.pylonshq.com">pylons</a>. </p>
<p>In this example I want to serve small product images from my product controller.</p>
<p>In the product.py controller I have this method</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span class="kw1">def</span> show_image<span class="br0">&#40;</span><span class="kw2">self</span>, <span class="kw2">id</span>, name<span class="br0">&#41;</span>:
    response.<span class="me1">headers</span><span class="br0">&#91;</span><span class="st0">'Content-type'</span><span class="br0">&#93;</span> = <span class="st0">'image/png'</span>
    response.<span class="me1">headers</span><span class="br0">&#91;</span><span class="st0">'Cache-Control'</span><span class="br0">&#93;</span> = <span class="st0">'max-age=14400'</span>
    response.<span class="me1">headers</span><span class="br0">&#91;</span><span class="st0">'Pragma'</span><span class="br0">&#93;</span> = <span class="st0">''</span>
    product = Product.<span class="me1">get_by</span><span class="br0">&#40;</span><span class="kw2">id</span>=<span class="kw2">id</span><span class="br0">&#41;</span>
    <span class="kw1">return</span> product.<span class="me1">image</span></pre></div></div>

<p>Then in my mako template I have</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span class="sc3"><span class="re1">&lt;img</span> <span class="re0">src</span>=<span class="st0">&quot;url(controller='product', action='show_image', id='${c.product.id}', name='c.product.image_name')&quot;</span><span class="re2">/&gt;</span></span></pre></div></div>

<p>which will generate</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span class="sc3"><span class="re1">&lt;img</span> <span class="re0">src</span>=<span class="st0">&quot;/product/show_image/1/super-glue.png&quot;</span><span class="re2">/&gt;</span></span></pre></div></div>

<p>So whats happening is that when the page is loading the image tag, the show_image() function is called which fetches the image data from the database and returns the image data buffer to the template. The key for this to work is to set the appropriate headers so that the page know that the data returned is image/png through the Content-type. The name argument is just used to set a name for the image file on the connecting client so that the cached file will have a correct name.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codethatmatters.com/2009/10/serving-images-directly-from-database/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

