<?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>Torsten Rehn Photography &#187; Development</title> <atom:link href="http://trehn.com/category/dev/feed/" rel="self" type="application/rss+xml" /><link>http://trehn.com</link> <description>Personal website and blog of photographer Torsten Rehn</description> <lastBuildDate>Mon, 31 May 2010 07:16:37 +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>Chromium Auto-Update</title><link>http://trehn.com/2010/05/29/chromium-auto-update/</link> <comments>http://trehn.com/2010/05/29/chromium-auto-update/#comments</comments> <pubDate>Sat, 29 May 2010 00:28:01 +0000</pubDate> <dc:creator>Torsten Rehn</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[System Administration]]></category> <category><![CDATA[Chromium]]></category> <category><![CDATA[Python]]></category><guid isPermaLink="false">http://trehn.com/?p=247</guid> <description><![CDATA[Posted a Python script to auto-update Chromium for Mac.]]></description> <content:encoded><![CDATA[<p>Just hacked together a small Python script to automatically update Chromium on my Mac to the latest SVN revision. I wrote this around 2am, so don&#8217;t expect bells and whistles. You can download it here:</p> &nbsp;&nbsp;&nbsp;&nbsp;<a href="http://files.trehn.com/chromium-updater.py">http://files.trehn.com/chromium-updater.py</a><p> The script is public domain, meant to be run interactively and provided without any warranties or batteries. It may or may not do bad things to your house and your cat, but mostly it just updates Chromium.</p> ]]></content:encoded> <wfw:commentRss>http://trehn.com/2010/05/29/chromium-auto-update/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Stuck with PyQt4</title><link>http://trehn.com/2010/02/24/stuck-with-pyqt4/</link> <comments>http://trehn.com/2010/02/24/stuck-with-pyqt4/#comments</comments> <pubDate>Wed, 24 Feb 2010 01:04:51 +0000</pubDate> <dc:creator>Torsten Rehn</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[Cocoa]]></category> <category><![CDATA[GUI]]></category> <category><![CDATA[nagify]]></category> <category><![CDATA[py2app]]></category> <category><![CDATA[PyObjC]]></category> <category><![CDATA[PyQt4]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[Qt]]></category> <category><![CDATA[sqlite]]></category> <category><![CDATA[Xcode]]></category><guid isPermaLink="false">http://trehn.com/?p=124</guid> <description><![CDATA[Rant about Python GUI development on OS X with some insight into the future of nagify.]]></description> <content:encoded><![CDATA[<p> Been looking into GUI options for <a href="http://nagify.org">nagify</a> lately. Thought I&#8217;d give Cocoa via PyObjC a try. Learned that using PyObjC is at least just as hard as learning Objective-C from scratch. Which I can&#8217;t because of the infamous once-you-know-python-you-don&#8217;t-want-anything-else-anymore syndrome. Also, there are memory issues and I ran into some obscure failure that I can&#8217;t even recall anymore.</p><p style="text-align: center;"><img class="size-full wp-image-125  aligncenter" title="nagify.ui" src="http://trehn.com/wp-content/uploads/2010/02/nagify.ui_1.png" alt="" /></p><p> So, after a quick look at the even more arcane options, I&#8217;m back with PyQt4. Took me a while to figure layouting in Qt Designer out, just to notice that I still can&#8217;t build a working distribution with py2app. I&#8217;m really looking forward to when everything will be 64bit and we don&#8217;t have this multilib/universal pile of crap anymore. Yuck.</p><p> My total whackjob of a solution right now is to mutilate a PyObjC-Cocoa Xcode template into running a Qt4 app. It&#8217;s not pretty and will probably break sometime in the future, but right now I just want to get some .app out there. Qt also gives me platform independence, which I like.</p><p> I&#8217;m currently working on having nagify save Nagios data into a local sqlite database so I can generate stats from it later. Those stats will then be used in a fullscreen view mode designed for large displays. At least that&#8217;s the plan.</p>]]></content:encoded> <wfw:commentRss>http://trehn.com/2010/02/24/stuck-with-pyqt4/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>nagify 1.0 released</title><link>http://trehn.com/2010/01/01/nagify-1-0-released/</link> <comments>http://trehn.com/2010/01/01/nagify-1-0-released/#comments</comments> <pubDate>Fri, 01 Jan 2010 20:15:42 +0000</pubDate> <dc:creator>Torsten Rehn</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[System Administration]]></category> <category><![CDATA[Growl]]></category> <category><![CDATA[nagify]]></category> <category><![CDATA[Nagios]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[release]]></category><guid isPermaLink="false">http://trehn.com/?p=95</guid> <description><![CDATA[I just released version 1.0 of nagify, a new Python library and utility for displaying notifications about Nagios alerts. The original purpose was to display Growl notifications for Nagios alerts, but nagify is designed to be very flexible and can be expanded to output notifications in pretty much any way. Please report any bugs to [...]]]></description> <content:encoded><![CDATA[<p> I just <a href="http://github.com/trehn/nagify/downloads">released</a> version 1.0 of <a href="http://nagify.org">nagify</a>, a new Python library and utility for displaying notifications about <a href="http://nagios.org">Nagios</a> alerts.</p><p> The original purpose was to display <a href="http://growl.info">Growl</a> notifications for Nagios alerts, but nagify is designed to be very flexible and can be expanded to output notifications in pretty much any way.</p><p> Please report any bugs to the <a href="http://github.com/trehn/nagify/issues">issue tracker at github</a>.</p><p> <b>Update:</b> 1.0.1 is out, now also available via the <a href="http://pypi.python.org/pypi/nagify">Python Package Index</a>.</p>]]></content:encoded> <wfw:commentRss>http://trehn.com/2010/01/01/nagify-1-0-released/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Add Python icons to TextMate</title><link>http://trehn.com/2009/11/21/add-python-icons-to-textmate/</link> <comments>http://trehn.com/2009/11/21/add-python-icons-to-textmate/#comments</comments> <pubDate>Sat, 21 Nov 2009 14:30:30 +0000</pubDate> <dc:creator>Torsten Rehn</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[customization]]></category> <category><![CDATA[icon]]></category> <category><![CDATA[Mac OS]]></category> <category><![CDATA[TextMate]]></category><guid isPermaLink="false">http://trehn.com/?p=74</guid> <description><![CDATA[Instructions on how to add a custom Python icon to the TextMate text editor.]]></description> <content:encoded><![CDATA[I missed having an icon for Python files in TextMate, so I made one with a <a href="http://python.org/community/logos/">Python Logo</a> on it:<img style="display: block; margin: auto;" title="PBX-python-Icon" src="http://trehn.com/wp-content/uploads/2009/11/PBX-python-Icon.png" alt="PBX-python-Icon" width="16" height="16" /> <br /> You can add it to your TextMate by downloading <a href="http://files.trehn.com/PBX-python-Icon.tiff">this file</a> and putting it unter <em>Contents/Resources/File Icons/</em> within your TextMate.app folder (to open that folder in the Finder, go to Applications, right-click TextMate and choose &#8220;Show Package Contents&#8221;).<br /> Then open the file <em>Bindings.plist</em> (located in the same folder where you put the .tiff) in your favorite text editor and add this anywhere directly after a &#8220;&lt;/array&gt;&#8221;:<pre class="code">
&lt;key&gt;PBX-python-Icon&lt;/key&gt;
&lt;array&gt;
&lt;string&gt;py&lt;/string&gt;
&lt;/array&gt;
</pre>That&#8217;s it! Restart TextMate and you&#8217;re done.<br /><br /> If you&#8217;re looking for better folder icons, there&#8217;s <a href="http://www.creative-toolbox.com/2009/03/update-your-textmate-folder-icons-for-leopard/">a blog post for that</a>, too.]]></content:encoded> <wfw:commentRss>http://trehn.com/2009/11/21/add-python-icons-to-textmate/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Forking Wikipedia</title><link>http://trehn.com/2009/11/06/forking-wikipedia/</link> <comments>http://trehn.com/2009/11/06/forking-wikipedia/#comments</comments> <pubDate>Fri, 06 Nov 2009 20:40:20 +0000</pubDate> <dc:creator>Torsten Rehn</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[git]]></category> <category><![CDATA[knowledge]]></category> <category><![CDATA[RFBW]]></category> <category><![CDATA[wiki]]></category> <category><![CDATA[wikipedia]]></category> <category><![CDATA[XML]]></category><guid isPermaLink="false">http://trehn.com/?p=71</guid> <description><![CDATA[Article about how the current problems with Wikipedia might be solved by creating a mostly unmoderated Really Friggin Big Wiki.]]></description> <content:encoded><![CDATA[<p>With the recent debate about the deletion practices in the german Wikipedia, a fork has been brought up as an option a couple of times. Right now, Wikipedia has a huge monopoly when it comes to online knowledge and a fork may be able to decentralize things a bit. While the content is under a free license, the policy governing it is not that flexible.</p><p> One of the problems is that Wikipedia is supposed to be an encyclopedia, not a system to store any and all knowledge. I wonder if it would be feasible to implement a Really Friggin Big Wiki where anyone can write about any topic. The only restriction would be that the article has to state facts in a neutral manner (citing the most dubious sources is ok, as long as it&#8217;s clear that the text in question is just the possibly biased opinion or completely insane claims of the source). No restrictions should be imposed when it comes to relevance or target audience.</p><p> Such a Really Friggin Big Wiki (maybe I should trademark that) could then be forked into an encyclopedia, a sysadmin wiki, a cookbook, &#8230; anything. Edits should be made by the general public in the RFBW and can then find their way into the subwikis where stronger moderation is imposed.</p><p> This leads to an interesting set of problems. On the technical side, people are already experimenting with <a href="http://scytale.name/blog/2009/11/announcing-levitation">converting MediaWiki XML dumps into a git repository</a>. The problem that remains is making that data available again for web-based editing. I&#8217;ve experimented with this in the past and created a very rudimentary wiki system that used git as a backend for both read and write operations. The code sucked, but I think in principle it is the right way to go about this.<br /> Another problem is namespacing and categorizing the data, using &#8220;John_Smith&#8221; as identifier for an article will no longer be sufficient &#8211; the disambiguation pages would be interesting.</p><p> I&#8217;m looking forward to what the community will come up with and how we&#8217;ll organize knowledge in ten years. Just too bad rfbw.org is already taken. Dammit.</p>]]></content:encoded> <wfw:commentRss>http://trehn.com/2009/11/06/forking-wikipedia/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Turbocharging BCFG2</title><link>http://trehn.com/2009/04/30/turbocharging-bcfg2/</link> <comments>http://trehn.com/2009/04/30/turbocharging-bcfg2/#comments</comments> <pubDate>Thu, 30 Apr 2009 20:41:47 +0000</pubDate> <dc:creator>Torsten Rehn</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[System Administration]]></category> <category><![CDATA[BCFG2]]></category> <category><![CDATA[config management]]></category> <category><![CDATA[Genshi]]></category> <category><![CDATA[XML]]></category><guid isPermaLink="false">http://blog.trehn.com/?p=30</guid> <description><![CDATA[How to use XInclude to make your BCFG2 bundles even more powerful.]]></description> <content:encoded><![CDATA[<p>I&#8217;ve spent a lot of time at work tinkering around with the <a href="http://bcfg2.org">BCFG2</a> configuration management system. Here&#8217;s a neat stunt you can pull off in your bcfg2 repo to achieve great flexibility when it comes to templating.</p><p>First off, <i>all</i> my bundles are defined in SGenshi. Now you can obviously use &lt;ConfigFile&gt; and point to a TGenshi template. But you might run into a problem here: A TGenshi template always has a static owner/group/perms tuple set in the info.xml file (which is bad if you need multiple instances of the template that belong to different users). I tried working around this via an extra &lt;Permissions&gt;, but the default info from &lt;ConfigFile&gt; seems to have a higher priority (see <a href="http://trac.mcs.anl.gov/projects/bcfg2/ticket/627">BCFG2 bug #627</a>).</p><p>My next shot was to use &lt;BoundConfigFile&gt;, which lets you inline the template in the bundle file. However, this method has a number of problems as it tends to clutter your bundle files and forces you to use XML templating for text files.</p><p>So here&#8217;s my <i>ingenious</i> solution: Genshi allows the use of XInclude in XML templates, but with a special twist: You can tell Genshi to parse the referenced file as a text template! So here we go:</p><pre class="code">
&lt;BoundConfigFile 
    name="/foo/bar" owner="${owner}" group="${group}" perms="0644">
  &lt;xi:include parse="text" href="templates/foo/bar.newtxt" />
&lt;/BoundConfigFile>
</pre>Remember to include the xi namespace reference in your &lt;Bundle&gt;. ]]></content:encoded> <wfw:commentRss>http://trehn.com/2009/04/30/turbocharging-bcfg2/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>New pyplog stuff</title><link>http://trehn.com/2009/02/22/new-pyplog-stuff/</link> <comments>http://trehn.com/2009/02/22/new-pyplog-stuff/#comments</comments> <pubDate>Sun, 22 Feb 2009 17:31:48 +0000</pubDate> <dc:creator>Torsten Rehn</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[API]]></category> <category><![CDATA[Photoshop]]></category> <category><![CDATA[pyplog]]></category><guid isPermaLink="false">http://trehn.com/?p=57</guid> <description><![CDATA[Post about pyplog development progress.]]></description> <content:encoded><![CDATA[Today I had an incredibly productive day resulting in the new whiteish pyplog look you see around here. Not having to reboot into Windows for Photoshop really is a great relief.<br /> Currently I&#8217;m working on API support for mobile blogging, stay tuned!]]></content:encoded> <wfw:commentRss>http://trehn.com/2009/02/22/new-pyplog-stuff/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Caching Django QuerySets</title><link>http://trehn.com/2008/10/01/caching-django-querysets/</link> <comments>http://trehn.com/2008/10/01/caching-django-querysets/#comments</comments> <pubDate>Wed, 01 Oct 2008 09:41:15 +0000</pubDate> <dc:creator>Torsten Rehn</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[caching]]></category> <category><![CDATA[django]]></category> <category><![CDATA[Python]]></category><guid isPermaLink="false">http://trehn.com/?p=65</guid> <description><![CDATA[Post about how to cache QuerySets in Django and updating the cache as needed.]]></description> <content:encoded><![CDATA[If you&#8217;re using generic views in Django, you probably do something like this in your URLconf:<br /><pre class="code">
pages = Page.objects.all()
[...]
  url(r"^pages/(?P&lt;slug&gt;.*)$", object_detail, { "queryset" : pages }),
</pre>Now, say you want to show the title of these pages in a menu on each page. You add a new context_processor:<br /><pre class="code">
from myapp.pages.models import Page

pages =  Page.objects.all()

def add_pages():
    return { "pages" : pages }
</pre>When you add a page now, you&#8217;ll notice that it won&#8217;t appear in your menu because the queryset has been evaluated the first time it has been accessed, and will remain the same as long as the python interpreter isn&#8217;t restarted. However, generic views appear to do the same thing and still show the most current content. They accomplish this by doing<pre class="code">queryset = queryset._clone()</pre>on each call. A cloned queryset will always be non-evaluated at first, which means that generic views will hit the database each time they&#8217;re called. You could of course do that as well, but you feel bad about grabbing those pages out of the database at every single request. My solution for this in pyplog was the following:<br /><pre class="code">
from django.db.models.signals import post_delete, post_save

class CachedQuerySetManager:
    """
    Manages a list of querysets that are automatically updated
    whenever an object is added to or deleted from one of them.
    """
    def __init__(self):
        self.querysets = {}

    def __getitem__(self, key):
        return self.querysets[key]["queryset"]
    
    def add(self, model, manager = "_default_manager"):
        self.querysets[model] = {
            "queryset" : getattr(model, manager).all(),
            "manager" : manager,
        }
        post_delete.connect(self.update, sender = model)
        post_save.connect(self.update, sender = model)
        
    def remove(self, model):
        post_delete.disconnect(self.update, sender = model)
        post_save.disconnect(self.update, sender = model)
        self.querysets.__delitem__(model)
    
    def update(self, sender, **kwargs):
        self.querysets[sender]["queryset"] = \
         getattr(sender, self.querysets[sender]["manager"]).all()

cached_querysets = CachedQuerySetManager()
</pre>The above example would look like this:<br /><pre class="code">
from myapp.pages.models import Page
from myapp.util.query import cached_querysets

cached_querysets.add(Page)

def add_pages():
    return { "pages" : cached_querysets[Page] }
</pre>Now the queryset is reset everytime a page is added or deleted. Note that you should of course only do this with QuerySets that you can afford to completely keep in memory (read: just a couple of objects). The QuerySet passed to a generic view never gets evaluated itself, so that it&#8217;s very cheap to have it around. The above code however keeps the evaluated QuerySet and will increase memory usage in favor of database load.<br /> You probably won&#8217;t need this if you&#8217;re using traditional caching (memcached), but for the folks that choose to go without it, this little helper might come in handy. <br /><br /> Note that the CachedQuerySetManager class above is part of <a href="http://pyplog.googlecode.com">pyplog</a> and therefore published under the GPL license. See pyplog&#8217;s LICENSE file for more information.]]></content:encoded> <wfw:commentRss>http://trehn.com/2008/10/01/caching-django-querysets/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>A new site&#8230; again</title><link>http://trehn.com/2008/02/18/a-new-site-again/</link> <comments>http://trehn.com/2008/02/18/a-new-site-again/#comments</comments> <pubDate>Mon, 18 Feb 2008 17:43:22 +0000</pubDate> <dc:creator>Torsten Rehn</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[Photography]]></category> <category><![CDATA[engagement]]></category> <category><![CDATA[Photoshop]]></category> <category><![CDATA[pyplog]]></category> <category><![CDATA[University]]></category><guid isPermaLink="false">http://trehn.com/?p=67</guid> <description><![CDATA[Post introducing the first installment of pyplog.]]></description> <content:encoded><![CDATA[Once again, all has changed. I&#8217;m officially engaged, had my first exams at university and hacked together this new site. The code is Open Source (as in <a href="http://www.gnu.org/licenses/gpl.html">GPLv3</a>) and can be found at <a href="http://code.google.com/p/pyplog">Google Code</a>. As of now, it&#8217;s probably useless to anyone else, but feel free to test it.<br /><br /> I recently watched some Photoshop training by <a href="http://www.chrisorwig.com">Chris Orwig</a> and <a href="http://www.deke.com">Deke McClelland</a> &#8211; quite insightful, you can sign up for a 7-day trial membership at <a href="http://www.lynda.com/freepass">Lynda.com</a> to see some of their stuff.]]></content:encoded> <wfw:commentRss>http://trehn.com/2008/02/18/a-new-site-again/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached
Page Caching using memcached (user agent is rejected)
Database Caching 6/28 queries in 0.005 seconds using memcached
Object Caching used 319/569 cached requests

Served from: trehn.com @ 2010-07-29 19:25:28 -->