<?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>Hauru</title>
	<atom:link href="http://hauru.eu/feed/" rel="self" type="application/rss+xml" />
	<link>http://hauru.eu</link>
	<description>Personal techblog by Tomek Paczkowski</description>
	<lastBuildDate>Wed, 07 Apr 2010 22:49:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Gedit rewrap plugin</title>
		<link>http://hauru.eu/2010/04/07/gedit-rewrap-plugin/</link>
		<comments>http://hauru.eu/2010/04/07/gedit-rewrap-plugin/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 22:49:14 +0000</pubDate>
		<dc:creator>oinopion</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://hauru.eu/?p=145</guid>
		<description><![CDATA[Ola is writing her dissertation in LaTeX using gedit (GNOME Text Editor). Gedit is nice, but it can&#8217;t do hard wrap, not to mention text reformatting. Now she has lots of extremely long lines. As vim has both mentioned features (gq) I don&#8217;t have this problem, but I decided to help her, knowing that gedit [...]]]></description>
			<content:encoded><![CDATA[<p>Ola is writing her dissertation in LaTeX using <a rel="external" href="http://www.gedit.org">gedit</a> (GNOME Text Editor). Gedit is nice, but it can&#8217;t do hard wrap, not to mention text reformatting. Now she has lots of extremely long lines. </p>
<p>As vim has both mentioned features (gq) I don&#8217;t have this problem, but I decided to help her, knowing that gedit supports python plugins. Two hours of browsing documentation and, lo and behold, rewrap plugin is finished. You can see it on bitbucket: <a href="http://bitbucket.org/oinopion/gedit-rewrap-plugin/">http://bitbucket.org/oinopion/gedit-rewrap-plugin/</a></p>
<p>I know that there probably is something similar (and probably better) done already, but it&#8217;s great fun to hack for your girlfriend!</p>
]]></content:encoded>
			<wfw:commentRss>http://hauru.eu/2010/04/07/gedit-rewrap-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enter Tasklight</title>
		<link>http://hauru.eu/2010/03/26/enter-tasklight/</link>
		<comments>http://hauru.eu/2010/03/26/enter-tasklight/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 21:14:16 +0000</pubDate>
		<dc:creator>oinopion</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://hauru.eu/?p=130</guid>
		<description><![CDATA[My time at University of the West of Scotland is about to end shortly. In two weeks I will submit my project along with lengthy dissertation for assessment. This is honours year project and should be a real-world web-application of considerable complexity including integration with some proprietary APIs. My project, Tasklight, is lightweight task management [...]]]></description>
			<content:encoded><![CDATA[<p>My time at <a href="http://uws.ac.uk">University of the West of Scotland</a> is about to end shortly. In two weeks I will submit my project along with lengthy dissertation for assessment. This is honours year project and should be a real-world web-application of considerable complexity including integration with some proprietary APIs.</p>
<p>My project, Tasklight, is lightweight task management system. It&#8217;s running on <a href="http://code.google.com/appengine/">Google App Engine</a> (Python runtime). It is build with libraries such as <a href="http://werkzeug.pocoo.org/">Werkzeug</a>, <a href="http://jinja.pocoo.org/2/">Jinja2</a>, <a href="http://wtforms.simplecodes.com/">wtforms</a> and <a href="http://jquery.com/">jQuery</a>.</p>
<p>Tasklight is fairly complete, in terms of university project. So that is why I&#8217;m announcing public beta testing. If you feel like trashing my little, cute Python app than go to: <a href="http://tasklight.appspot.com">Tasklight</a> log in with your Google Account and &#8230; well, test it!</p>
<div style="margin: 10px; text-align: center">
<a href="http://tasklight.appspot.com"><img src="http://hauru.eu/wp-content/uploads/2010/03/task_big.png" alt="Tasklight logo" title="Tasklight logo" width="287" height="52" class="size-full wp-image-136"/></a></div>
<p>PS: Any feedback can go here or to <a href="http://hauru.uservoice.com/forums/48185-tasklight">uservoice forum</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://hauru.eu/2010/03/26/enter-tasklight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python&#8217;s Augmented Assignments</title>
		<link>http://hauru.eu/2010/02/15/python-augmented-assignments/</link>
		<comments>http://hauru.eu/2010/02/15/python-augmented-assignments/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 19:12:20 +0000</pubDate>
		<dc:creator>oinopion</dc:creator>
				<category><![CDATA[Techblog]]></category>
		<category><![CDATA[py-jutsu]]></category>

		<guid isPermaLink="false">http://hauru.eu/?p=123</guid>
		<description><![CDATA[Everyone knows that in Python variables are just references and passing such reference to function effectively copies value of the reference to functions local scope, hence any assignment within function has no effect on original variable. Knowing that, this took me by surprise: >>> def add_eggs(foo): ... foo += ['eggs'] ... >>> spam = ['spam'] [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone knows that in Python variables are just references and passing such reference to function effectively copies value of the reference to functions local scope, hence any assignment within function has no effect on original variable. Knowing that, this took me by surprise:</p>
<pre><code>
>>> def add_eggs(foo):
...     foo += ['eggs']
...
>>> spam = ['spam']
>>> add_eggs(spam)
>>> print spam
['spam', 'eggs']
</code></pre>
<p>This seemed to me as an error in Python interpreter, but after checking language reference I discovered it&#8217;s not; it&#8217;s intended behaviour (emphasis is mine): </p>
<blockquote><p>
An augmented assignment expression like <tt>x += 1</tt> can be rewritten as <tt>x = x + 1</tt> to achieve a similar, but <strong>not exactly equal effect</strong>. In the augmented version, <tt>x</tt> is only evaluated once.  Also, when possible, <strong>the actual operation is performed in-place</strong>, meaning that rather than creating a new object and assigning that to the target, <strong>the old object is modified</strong> instead.
</p></blockquote>
<p>Quoted after: <a href="http://docs.python.org/reference/simple_stmts.html#augmented-assignment-statements">python docs</a></p>
]]></content:encoded>
			<wfw:commentRss>http://hauru.eu/2010/02/15/python-augmented-assignments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Equality is not always sufficient</title>
		<link>http://hauru.eu/2009/11/22/equality-is-not-always-sufficient/</link>
		<comments>http://hauru.eu/2009/11/22/equality-is-not-always-sufficient/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 23:59:57 +0000</pubDate>
		<dc:creator>oinopion</dc:creator>
				<category><![CDATA[Techblog]]></category>
		<category><![CDATA[craftsmanship]]></category>
		<category><![CDATA[py-jutsu]]></category>

		<guid isPermaLink="false">http://hauru.eu/?p=103</guid>
		<description><![CDATA[I&#8217;ve just got hit by one of really typical errors while writing simple value type in Python. Consider following code: class Simple(object): def __init__(self, val): self.val = val def __eq__(self, other): return self.val == other.val The class Simple overrides equality operator delegating it to it&#8217;s value. Seems dead simple and easy for the first time. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just got hit by one of really typical errors while writing simple value type in Python. Consider following code:</p>
<pre><code>class Simple(object):
    def __init__(self, val):
        self.val = val
    def __eq__(self, other):
        return self.val == other.val
</code></pre>
<p>The class <code>Simple</code> overrides equality operator delegating it to it&#8217;s value. Seems dead simple and easy for the first time. But not quite so. What will following snippet print?</p>
<pre><code>a, b = Simple(3), Simple(3)
set_a, set_b = set([a]), set([b])
print 'a == b: ', a == b
print 'set_a == set_b', set_a == set_b
</code></pre>
<p>You&#8217;ve guessed it: <code>True</code>, <code>False</code>. This is because two sets may be equal only if all elements <strong>hashes</strong> are equal. So I thought I will fix it with this:</p>
<pre><code>class Hashimple(object):
    def __init__(self, val):
        self.val = val
    def __eq__(self, other):
        return self.val == other.val
    def __hash__(self):
        return (self.val * 5) + 7
</code></pre>
<p>Seems better, but look at this snippet and guess once more:</p>
<pre><code>a, b = Hashimple(3), Hashimple(3)
set_a, set_b = set([a]), set([b])
print 'Hashimple'
print 'a == b: ', a == b
print 'set_a == set_b', set_a == set_b
print 'a != b', a != b
</code></pre>
<p><code>True</code>, <code>True</code>, <code>True</code>?!? Well, Python will not imply that <code>a&nbsp;!=&nbsp;b</code> , not even when <code>a&nbsp;==&nbsp;b</code>.</p>
<p>This bug has been made thousands times by thousands of coders, it occurs not only in Python, but also in various other languages (Java, Ruby), it&#8217;s been described in lots of books, but I just keep forgetting about it. Maybe writing a blog post will help me remember?</p>
<p>Docs: <a href="http://docs.python.org/reference/datamodel.html#object.__eq__"><code>__eq__</code></a>, <a href="http://docs.python.org/reference/datamodel.html#object.__hash__"><code>__hash__</code></a></p>
]]></content:encoded>
			<wfw:commentRss>http://hauru.eu/2009/11/22/equality-is-not-always-sufficient/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Idea about Expires header</title>
		<link>http://hauru.eu/2009/10/18/idea-about-expires-header/</link>
		<comments>http://hauru.eu/2009/10/18/idea-about-expires-header/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 18:43:55 +0000</pubDate>
		<dc:creator>oinopion</dc:creator>
				<category><![CDATA[Techblog]]></category>

		<guid isPermaLink="false">http://hauru.eu/?p=72</guid>
		<description><![CDATA[Since the Steve Sounder&#8217;s High Performance Web Sites everyone knows to set far future Expires header on their static assets. What he didn&#8217;t say was how to deal with the file changes. You can&#8217;t instruct browser to download the file so you actually have to change the file&#8217;s URL. Ruby on Rails handles this by [...]]]></description>
			<content:encoded><![CDATA[<p>Since the Steve Sounder&#8217;s <a href="http://http://stevesouders.com/hpws/">High Performance Web Sites</a> everyone knows to set <a href="http://developer.yahoo.com/performance/rules.html#expires">far future <code>Expires</code></a> header on their static assets. What he didn&#8217;t say was how to deal with the file changes. You can&#8217;t instruct browser to download the file so you actually have to change the file&#8217;s URL. </p>
<p><em>Ruby on Rails</em> handles this by automatically adding file&#8217;s timestamp as a query-string when using build-in helper methods &#8212; simple and not requiring server-side URLs rewriting. This is good enough, but only for files accessed from HTML directly and doesn&#8217;t work for files accessed from CSS: background images (unless you have dynamically generated styles). </p>
<p>I was thinking for some time about those background images, because they can be heavy and if you&#8217;re not using CSS sprites they make lots of requests. As I don&#8217;t like dynamically generated style sheets, I didn&#8217;t want any additional processing. And so it came to me: why not incorporate some changing value into the <em>domain name</em>? You could put a revision number or a timestamp in domain name of your statics server, just like this: <code>static-<strong>1566</strong>.example.com</code>. Both Rails and Django provide easy ways to change static assets domain.</p>
<p>This requires you to set-up wildcard subdomain, but is&#8217;s easier than processing CSS files. It works because <code>url</code> function in a style sheet <a href="http://www.w3.org/TR/CSS21/syndata.html#uri">is resolved using the style sheet&#8217;s own address</a>. </p>
<p>PS: This is only a brain-dump &#8212; I didn&#8217;t test it.</p>
]]></content:encoded>
			<wfw:commentRss>http://hauru.eu/2009/10/18/idea-about-expires-header/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Clean Code by Robert C. Martin</title>
		<link>http://hauru.eu/2009/01/28/clean-code-by-robert-c-martin/</link>
		<comments>http://hauru.eu/2009/01/28/clean-code-by-robert-c-martin/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 10:35:57 +0000</pubDate>
		<dc:creator>oinopion</dc:creator>
				<category><![CDATA[Techblog]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[kaizen]]></category>

		<guid isPermaLink="false">http://hauru.eu/?p=52</guid>
		<description><![CDATA[Clean Code is the best book I have read in last six months. In this book Robert C. Martin shares his great experience from the programming battlefield. The book has a very good style. It guides you through refactoring of reams of Java code as if it was solving riddles. It&#8217;s not about high design, [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Clean Code on Amazon.com" href="http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882" target="_blank">Clean Code</a> is the best book I have read in last six months. In this book <a title="Uncle Bos's homepage" href="http://www.objectmentor.com/omTeam/martin_r.html" target="_blank">Robert C. Martin</a> shares his great experience from the programming battlefield.</p>
<p>The book has a very good style. It guides you through refactoring of reams of Java code as if it was solving riddles. It&#8217;s not about high design, though, it&#8217;s about handling the code at a lower level: at the level of organizing classes, functions and blocks. It&#8217;s about writing a beautiful and readable code.</p>
<p>It&#8217;s also a book on craftsmanship. The author has emphasized this many times on his <a title="Object Mentor blog" href="http://blog.objectmentor.com/" target="_blank">blog</a>: being a craftsman-programmer means taking responsibility of producing <em>good code</em> only, just like being craftsman shoemaker, is all about making good shoes. And exactly the same way there are principles and best practices in both professions.</p>
<p>The uncompromising style helps the reader not to lose himself within arguments, but if you don&#8217;t like what Robert Martin says about certain principle, that&#8217;s very good (unless you can&#8217;t provide any arguments to back it up).</p>
<p>All in all it&#8217;s a very good book for anyone who wants to write better code. Get your own copy now and no worries! You&#8217;ll like it.</p>
]]></content:encoded>
			<wfw:commentRss>http://hauru.eu/2009/01/28/clean-code-by-robert-c-martin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gone WordPress</title>
		<link>http://hauru.eu/2008/12/14/gone-wordpress/</link>
		<comments>http://hauru.eu/2008/12/14/gone-wordpress/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 00:06:22 +0000</pubDate>
		<dc:creator>oinopion</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://hauru.eu/?p=32</guid>
		<description><![CDATA[Quick and obvious info: I moved to wordpress. That&#8217;s kind of treason: wordpress is not in Python, but after evaluating it for a few hours it seems nice and very usable. I don&#8217;t know internal code, but from outside it&#8217;s quite good piece of software. Theme used: Elite.]]></description>
			<content:encoded><![CDATA[<p>Quick and obvious info: I moved to <a href="http://wordpress.org">wordpress</a>. That&#8217;s kind of treason: wordpress is not in Python, but after evaluating it for a few hours it seems nice and very usable. I don&#8217;t know internal code, but from outside it&#8217;s quite good piece of software. Theme used: <a href="http://wpzone.net/free-wordpress-themes/elite/">Elite</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://hauru.eu/2008/12/14/gone-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bazaar with Master Branch</title>
		<link>http://hauru.eu/2008/07/31/bazaar-master-branch/</link>
		<comments>http://hauru.eu/2008/07/31/bazaar-master-branch/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 19:28:11 +0000</pubDate>
		<dc:creator>oinopion</dc:creator>
				<category><![CDATA[Techblog]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.hauru.eu/?p=9</guid>
		<description><![CDATA[Problem statement I have a bit svnish view of writing software: there should be one master branch for project just not to confuse users of your code where to get the most recent code from. I&#8217;m writing a little app (I&#8217;ve posted about it earlier) with my girlfriend and we wanted to share and control [...]]]></description>
			<content:encoded><![CDATA[<h3>Problem statement</h3>
<p>I have a bit svnish view of writing software: there should be one master branch for project just not to confuse users of your code where to get the most recent code from.</p>
<p>I&#8217;m writing a little app (I&#8217;ve posted about it earlier) with my girlfriend and we wanted to share and control code with possibly <a href="http://bazaar-vcs.org">the best DVCS in the world</a>. Bazaar promises an easy way for svn people to support central/master branch workflow. Or so I thought.</p>
<h3>Early attempt</h3>
<p>I was to confident with bazaar easiness. So I made <code>bzr push</code> over sftp to some directory on hauru.eu and told my girlfriend it&#8217;s ready. But it wasn&#8217;t: all files had my user permissions (uid/gid) and she couldn&#8217;t check anything in. So&#8230; It&#8217;s not so easy. I could change initial group for both of us, but this is not general solution (it wouldn&#8217;t work on WebFaction shared hosting where you can&#8217;t change initial group).</p>
<p>Heaving previous experience with setting svn central repository I tried to <code>bzr serve</code> the code. But this is simplistic mechanism with no read-write authentication support.</p>
<h3>SGID to the rescue</h3>
<p>With an advice from <a href="http://squarewheel.wordpress.com">Paweł</a> I tried setting <a href="http://en.wikipedia.org/wiki/Setuid">SGID</a> on repository directory. It sounded as a good idea, but it didn&#8217;t work. I was desperate, but I took another shot and browsed the web for solutions with SGID.</p>
<p>It seems there is bug in OpenSSH or python-paramiko or in bazaar sftp support and it doesn&#8217;t honor SGID properly. But with smart-server, that is <strong>bzr+ssh</strong> it does. Moreover it works much faster than sftp. So it&#8217;s double win.</p>
<h3>Complete solution</h3>
<p>In four steps:</p>
<ol>
<li>on server create empty repo folder</li>
<li>change group to some common (users or bzr or your-project)</li>
<li>set SGID on the folder</li>
<li>now you can push your branch with
<pre><code>bzr push bzr+ssh://server/repo-path</code>
<pre></li>
</ol>
<p>Every one in group can check code in and out.</p>
<p>Of course this should not stop you from having as many side branches as you want, but it's good to have a single code branch you can always refer to.</p>
]]></content:encoded>
			<wfw:commentRss>http://hauru.eu/2008/07/31/bazaar-master-branch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Failed with Google App Engine</title>
		<link>http://hauru.eu/2008/07/14/failed-with-google-app-engine/</link>
		<comments>http://hauru.eu/2008/07/14/failed-with-google-app-engine/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 19:13:27 +0000</pubDate>
		<dc:creator>oinopion</dc:creator>
				<category><![CDATA[Techblog]]></category>
		<category><![CDATA[py-jutsu]]></category>

		<guid isPermaLink="false">http://blog.hauru.eu/?p=3</guid>
		<description><![CDATA[I&#8217;m writing a little app for my English course at Jagiellonian University in Django. Right now I&#8217;m hosting it here, on hauru.eu, but soon we&#8217;ll release a book we were producing whole year and thus I have to finish the app and make it public. I thought about putting it on Google App Engine  (think: [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing a little app for my English course at <a href="http://www.uj.edu.pl/">Jagiellonian University</a> in <a href="http://www.djangoproject.com/">Django</a>. Right now I&#8217;m hosting it here, on hauru.eu, but soon we&#8217;ll release a book we were producing whole year and thus I have to finish the app and make it public. I thought about putting it on <a href="http://code.google.com/appengine/">Google App Engine</a>  (think: free hosting in Python), but after two days of trying I must say I don&#8217;t see any point any more.</p>
<p>I wrote my app using many of convenience methods/classes provided by Django, but very few of them are supported by GAE. I&#8217;d have to rewrite half of code! No way. It&#8217;s right time to use some servers in <a href="http://www.ksi.ii.uj.edu.pl/">KSI</a>: Students&#8217; Computer Science Club, which I&#8217;m proud member of.</p>
<p>I&#8217;m sure Google App Engine is powerful and convenient platform, but I don&#8217;t think Django fits there well. While reading about GAE I thought the best solution would be using some external libraries like <a href=" http://werkzeug.pocoo.org/">Werkzeug</a>, as GAE is based on WSGI interface.</p>
<p><strong>Update (Dec 13, 2008)</strong>: The little app is live and indeed running on KSIs server. Check it out, it&#8217;s called <a href="http://englishplusplus.jcj.uj.edu.pl">English++: English for Computer Science Students</a></p>
]]></content:encoded>
			<wfw:commentRss>http://hauru.eu/2008/07/14/failed-with-google-app-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
