<?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"
	>

<channel>
	<title>kerbtier</title>
	<atom:link href="http://kerbtier.ch/feed" rel="self" type="application/rss+xml" />
	<link>http://kerbtier.ch</link>
	<description>mind the gap</description>
	<pubDate>Tue, 25 May 2010 09:58:02 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>Router with failover line</title>
		<link>http://kerbtier.ch/2010/05/25/router-with-failover-line</link>
		<comments>http://kerbtier.ch/2010/05/25/router-with-failover-line#comments</comments>
		<pubDate>Tue, 25 May 2010 09:58:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://kerbtier.ch/?p=190</guid>
		<description><![CDATA[The last month i worked in the Nairobi Office. For internet we have a KDN-Fibre. Because it&#8217;s so often down we also have a KDN-Wimax line. But even with this configuration sometimes we have downtimes so we also ordered a ZUKU Wimax line.

Both KDN lines use the same IP. I don&#8217;t think it&#8217;s easy possible [...]]]></description>
			<content:encoded><![CDATA[<p>The last month i worked in the Nairobi Office. For internet we have a KDN-Fibre. Because it&#8217;s so often down we also have a KDN-Wimax line. But even with this configuration sometimes we have downtimes so we also ordered a ZUKU Wimax line.</p>

<p>Both KDN lines use the same IP. I don&#8217;t think it&#8217;s easy possible to have them both plugged into the router for redundancy. So when the fiber is down someone has to unplug and plug the wimax cable. for the ZUKU line i wanted a better solution. if KDN has a problem the ZUKU line should take over automatically. The first approach was to use an old PC with linux installed and three network cards. But there are a few serious drawbacks. A whole PC uses lots of Power. It&#8217;s expensive, heats up the office, it&#8217;s not so green and if we have a power cut it drains the backup battery faster.
A router with redundant line capabilities is quite expensive&#8230; and also uses lots of power. It&#8217;s also over sized for our little office.</p>

<p>But there is <a href="http://openwrt.org">openwrt</a> and a few similar projects. They provide a linux distribution which you can install on a few cheap and small wireless routers. These routers with almost no functionality can get very powerful devices with a proper Operating System installed on them.</p>

<p>It was really hard to find a supported router in Nairobi. In Switzerland you can get them in lots of online and offline shops. Here we had to find someone who specialized only in routers. The one we bought was a Linksys WRT54GL.
The next Step was to install the openwrt OS on it. There are two flavors, used the Kamikaze, it&#8217;s more modern! You can use the original webinterface to upload the new firmware. There is a Page with <a href="http://wiki.openwrt.org/doc/howto/installing">all the ways how to install it</a>. The router now has a very powerful web interface. You can already add multiple WAN interfaces. I created one for the ZUKU line called zukuwan. You also have to add a third vpn (*1) which uses one of the LAN ports and uses the zukuwan network. i also had to add that zukuwan network to the WAN zone of the firewall. To modify the firewall settings i had to install the luci firewall packet (*2).</p>

<p>You can check if both WAN lines are properly working when you plug only one WAN line and restart the router.
</p>

<p>A nice guy created a script which ads line balancing and failover support. For this some rather complex routing stuff is required. The script manages that and also checks if a line is down. You have to add the packages multiwan and luci-app-multiwan (config interface) from <a href="https://forum.openwrt.org/viewtopic.php?id=23904">https://forum.openwrt.org/viewtopic.php?id=23904</a>.</p>

<p>After you installed the packages you have a multi-wan configuration page in the network menu. Remove there the wan2 config and add a new one called zukuwan or however you called your second WAN connection. You can also remove all of the entries in mwanfw. The default route should be fastbalancer. Set the failover_to for each interface to the other one.</p>

<p>After this it should work. If it&#8217;s not working ther is a way to check. You can connect via ssh to the router if you changed your password. There type
<code>ip route show table 123
</code>
This should give two default routes. If you plug out one cable it should take about 10 to 20 seconds and then this route should be removed.
</p>

<br/><br/><br/><br/>
<p>(*1) Go to the Administration/Network/Switch Page. Add an interface ethX.2. set it to the ports 0 and 5. Remove Port 0 from ethX.0. For the second WAN connection set eth0.2 as Interface.</p>
<p>(*2) Go to Administration/Overview/LuCI Components. Check luci-app-firewall package and press the Install button. After a restart you have the Administration/Network/Firewall config page. Select wan and zukuwan for the wan Zone.</p>]]></content:encoded>
			<wfw:commentRss>http://kerbtier.ch/2010/05/25/router-with-failover-line/feed</wfw:commentRss>
		</item>
		<item>
		<title>Merge and split PDFs</title>
		<link>http://kerbtier.ch/2010/05/19/merge-and-split-pdfs</link>
		<comments>http://kerbtier.ch/2010/05/19/merge-and-split-pdfs#comments</comments>
		<pubDate>Wed, 19 May 2010 11:24:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://kerbtier.ch/?p=183</guid>
		<description><![CDATA[
To make one PDF file out of many is not so hard on Linux. Usually there is ghostscript already installed. You can use
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=merged.pdf\
     file1.pdf file2.pdf file3.pdf

to do that. instead of providing every single filename something like *.pdf is more usable.


To extract a few pages out of one [...]]]></description>
			<content:encoded><![CDATA[<p>
To make one PDF file out of many is not so hard on Linux. Usually there is ghostscript already installed. You can use
<code>gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=merged.pdf\
     file1.pdf file2.pdf file3.pdf
</code>
to do that. instead of providing every single filename something like *.pdf is more usable.
</p>
<p>
To extract a few pages out of one big PDF you can use:
<code>gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=pages_10_to_15.pdf\
    -dFirstPage=10 -dLastPage=15 bif_file.pdf
</code>
</p>]]></content:encoded>
			<wfw:commentRss>http://kerbtier.ch/2010/05/19/merge-and-split-pdfs/feed</wfw:commentRss>
		</item>
		<item>
		<title>Wordpress login used for rails application</title>
		<link>http://kerbtier.ch/2010/02/22/wordpress-login-used-for-rails-application</link>
		<comments>http://kerbtier.ch/2010/02/22/wordpress-login-used-for-rails-application#comments</comments>
		<pubDate>Mon, 22 Feb 2010 09:52:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://kerbtier.ch/?p=180</guid>
		<description><![CDATA[in order to use the rails login mechanism with another non-php application there are two solutions.
for both you need to read the rails login cookie. it is named wordpress_logged_in_XXXX. Where XXXX is a random string. it contains a string of the form: admin&#124;YYYY&#124;ZZZZ. YYYY is the expiration date, in seconds i think, and ZZZZ is [...]]]></description>
			<content:encoded><![CDATA[<p>in order to use the rails login mechanism with another non-php application there are two solutions.
for both you need to read the rails login cookie. it is named wordpress_logged_in_XXXX. Where XXXX is a random string. it contains a string of the form: admin|YYYY|ZZZZ. YYYY is the expiration date, in seconds i think, and ZZZZ is a hash calculated from lots of different inputs.</p>

<p>the first solution is to get the cookie from the browser, fetch the different input parameters for the hash from the config-files and the database and compare this hash with the hash given by the cookie. but it&#8217;s quite hard to calculate the hash. it uses not only username and password, it uses also salt values from the config file or the database, depending on many configuration options. to make it properly it would be quite hard. but there is an easier, not much more unsecure way. instead of only sending the cookie and it&#8217;s value to the browser we could write it also somewhere in a tempfolder to the filesystem. so we can read the cookie from the second application and check it againts the one from the filesystem. instead of the filesystem we could also use memcached to store the cookie infos.</p>

<p>whenever wordpress writes the cookie we have to write it also to the filesystem. this can be done inside the wp_set_auth_cookie function inside the file wp-includes/pluggable.php. but there is another problem. the name of the cookie is the same for different clients. so we have to use another name. i&#8217;d propose to use the username of the logged in user. the value which has to be written is stored in the logged_in_cookie -variable inside the wp_set_auth_cookie method.</p>

<code>
$user = get_userdata($user_id);
file_put_contents('/tmp/wp_rails_'.$user->user_login.'_'.$expiration, $logged_in_cookie);</code>

<p>
with the code above the cookies content for each logged in user is writen to a file in the tmp folder. in the rails or whatever application this file can be read and compared to the actual cookie sendt by the browser. if it matches, the user is properly logged into rails.</p>]]></content:encoded>
			<wfw:commentRss>http://kerbtier.ch/2010/02/22/wordpress-login-used-for-rails-application/feed</wfw:commentRss>
		</item>
		<item>
		<title>google geocoding service</title>
		<link>http://kerbtier.ch/2010/01/26/google-geocoding-service</link>
		<comments>http://kerbtier.ch/2010/01/26/google-geocoding-service#comments</comments>
		<pubDate>Tue, 26 Jan 2010 17:53:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://kerbtier.ch/?p=175</guid>
		<description><![CDATA[
google has a great geocoding service. it is possible to find out the latitude and the longitude of an address and the opposite is possible too. for a little project i had to get the coordinates of an address an user entered. if he enters only the city it might be possible that multiple cities [...]]]></description>
			<content:encoded><![CDATA[<p>
google has a great <a href="http://code.google.com/apis/maps/documentation/geocoding/index.html" target="_blank">geocoding</a> service. it is possible to find out the latitude and the longitude of an address and the opposite is possible too. for a little project i had to get the coordinates of an address an user entered. if he enters only the city it might be possible that multiple cities exist and the geocoding service returns a list of all cities with details. for example if i search for &#8220;stein&#8221; (http://maps.google.com/maps/geo?q=stein&#038;key=key) multiple entries in germany an multiple entries in austria are returned. the user is then asked to pick the proper location. i need this project only for germany so i add a postfix to the querystrings like &#8220;stein, germany&#8221; (http://maps.google.com/maps/geo?q=stein, germany&#038;key=key). now there is only one result for germany instead of the multiples like before. i tried it with other cities and it looks like a general problem. even when i use the gl parameter like &#038;gl=de instead of appending &#8220;, germany&#8221; to the query string it won&#8217;t work properly.
</p>

<p>
i have no idea why this happens and no idea how to fix this. it&#8217;s probably possible to &#8220;fix&#8221; this problem by using a viewport. so you can instruct to return only cities from the given bounding box. it&#8217;s not a really good solution but beter than nothing.
</p>]]></content:encoded>
			<wfw:commentRss>http://kerbtier.ch/2010/01/26/google-geocoding-service/feed</wfw:commentRss>
		</item>
		<item>
		<title>check html templates for spelling errors</title>
		<link>http://kerbtier.ch/2009/11/17/check-html-templates-for-spelling-errors</link>
		<comments>http://kerbtier.ch/2009/11/17/check-html-templates-for-spelling-errors#comments</comments>
		<pubDate>Tue, 17 Nov 2009 17:24:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[development]]></category>

		<category><![CDATA[python]]></category>

		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://kerbtier.ch/?p=161</guid>
		<description><![CDATA[my spelling is horribly. it&#8217;s quite annoying to update a webpage and getting complaints about some spelling errors. usually all the human language strings are nicely stored in a separate textfile but for smaller projects i often put them directly into html templates. if you have a proper ide it will do the spell checking [...]]]></description>
			<content:encoded><![CDATA[my spelling is horribly. it&#8217;s quite annoying to update a webpage and getting complaints about some spelling errors. usually all the human language strings are nicely stored in a separate textfile but for smaller projects i often put them directly into html templates. if you have a proper ide it will do the spell checking for you. but if you use some not so sophisticated ide you have to do it yourself or you can use one of the opensource spellers. there are ispell, aspell, myspell and some more. at first i tried to write a shellscript using one of them. then i remembered using one once from python. there is this nice library, <a href="http://sourceforge.net/projects/pyenchant/">pyEnchant</a>. it makes spellchecking really easy. here is a little python script which checks all the html templates. the advantage of this is that it can be implemented as a unittest or something similar, so you will be warned if there is a new spelling error in your project.<br/><br/>

the script is quick and dirty and for german. but you should get the idea.

<code>from enchant.checker import SpellChecker 
import os, re, codecs, sys

chkr = SpellChecker("de_DE")

# patterns remove in this case html and jinja2/ django
# code and some special words
rmPatterns = [r'<.*?>', r'{%.*?%}', r'{{.*?}}', r'me@norep\.com',
                                    u'projectName', u'FooName']

# get a list of directories and subdirectories
def listdirs(dirname):
  dirs = [os.path.join(dirname, f) for f in os.listdir(dirname) /
              if os.path.isdir(os.path.join(dirname, f))]
  for d in dirs[:]:
    dirs += listdirs(d)
  return dirs

for d in listdirs(&#8217;templates&#8217;):
  for f in [os.path.join(d, f) for f in os.listdir(d) if re.search(r'\.html$', f)]:
    
    # read filedata&#8230; as unicode, i always use unicode
    fd = codecs.open(f, &#8216;r&#8217;, &#8216;utf-8&#8242;)
    data = fd.read()
    fd.close()
    
    # remove the tags and codes defined in rmPatterns
    for p in rmPatterns:
      data = re.sub(p, &#8221;, data)
    
    # get error words
    found = []
    chkr.set_text(data)
    for err in chkr:
      found.append(err.word)
    
    # if errors found, print them  
    if len(found) > 0:
      print &#8220;%s: %s&#8221; % (len(found), f)
      for w in found:
        print &#8221;  : %s -> %s&#8221; % (w, &#8216;, &#8216;.join(chkr.dict.suggest(w)))
</code>

the output for one of my projects is:

<code>1: templates/pages/about.html
  : stösst -> stößt, störst
2: templates/pages/help.html
  : Registrier -> Registrier-, Registriere, Registriert, Registrieren
  : Bestätigungs -> Bestätigung, Bestätigungs-
3: templates/pages/legalNotice.html
  : St -> Set, St., Et, Kt, Sh, SV, Ist, Äst, Ast, Ost, Gst, Sät, So
  : mail -> Mail, mal, -mail, mail-, mai-
  : tel -> teil, Gel, Tel., Telex, Teller, Telekom
</code>
]]></content:encoded>
			<wfw:commentRss>http://kerbtier.ch/2009/11/17/check-html-templates-for-spelling-errors/feed</wfw:commentRss>
		</item>
		<item>
		<title>zine, wordpress killer</title>
		<link>http://kerbtier.ch/2009/05/10/zine-wordpress-killer</link>
		<comments>http://kerbtier.ch/2009/05/10/zine-wordpress-killer#comments</comments>
		<pubDate>Sat, 09 May 2009 23:46:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[python]]></category>

		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://kerbtier.ch/?p=156</guid>
		<description><![CDATA[i think about a new blog. a nontechnical trashblog or something. for the kerbtier blog i&#8217;m using wordpress and i&#8217;m quite happy with it. lots of useful plugins and quite stable. but the code is somewhat funny and it&#8217;s not so easy to adapt/extend it to ones needs. i often had to change code instead [...]]]></description>
			<content:encoded><![CDATA[i think about a new blog. a nontechnical trashblog or something. for the kerbtier blog i&#8217;m using wordpress and i&#8217;m quite happy with it. lots of useful plugins and quite stable. but the code is somewhat funny and it&#8217;s not so easy to adapt/extend it to ones needs. i often had to change code instead of reconfigure or add code and this makes it time consuming to keep it up to date.<br/><br/>
i looked for another blog software and found <a href="http://zine.pocoo.org/">zine</a>. it&#8217;s quite similar to wordpress but written in python. i did a test installation and till now everything went perfect. i didn&#8217;t test it properly but only the fact that it&#8217;s written in python makes me belive in it much more than in wordpress.]]></content:encoded>
			<wfw:commentRss>http://kerbtier.ch/2009/05/10/zine-wordpress-killer/feed</wfw:commentRss>
		</item>
		<item>
		<title>is XUL really cool?</title>
		<link>http://kerbtier.ch/2009/05/08/is-xul-cool</link>
		<comments>http://kerbtier.ch/2009/05/08/is-xul-cool#comments</comments>
		<pubDate>Fri, 08 May 2009 07:24:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[development]]></category>

		<category><![CDATA[xul]]></category>

		<guid isPermaLink="false">http://kerbtier.ch/?p=151</guid>
		<description><![CDATA[i recently started to develop a little twitter client in XUL. i did a lot of web-development with lots of javascript and i thought that it would be fast and easy to develop a XUL application. now, after a few hours i must say that XUL is a great thing. the available widgets are quite [...]]]></description>
			<content:encoded><![CDATA[i recently started to develop a little twitter client in XUL. i did a lot of web-development with lots of javascript and i thought that it would be fast and easy to develop a XUL application. now, after a few hours i must say that XUL is a great thing. the available widgets are quite complete, the xml to desribe an UI is properly designed and it&#8217;s easy to manipulate the whole thing with javascript. i didn&#8217;t have a look at the template stuff yet and i dont know how usable it is. i&#8217;m a bit sceptic&#8230;

<h3>but</h3>
a pain in the ass is that javascript frameworks like prototype are only working partially. to manipulate the DOM with the DOM-API you need lots of unelegant lines of code. this would not be a problem if someone wrote a little javascript library for easier DOM-manipulation. but i didn&#8217;t found anything. the most javascript libraries are quite browserspecific and are not properly usable by XUL. there is in general almost no community produced stuff like tutorials, examples, proper IDEs&#8230; it is a bit frustrating to have almost only the API-reference-like tutorial and the API-reference on the <a href="https://developer.mozilla.org/En/XUL">official XUL homepage</a>. firefox and mozilla are such well known. why isn&#8217;t there a big XUL echo from the internet?]]></content:encoded>
			<wfw:commentRss>http://kerbtier.ch/2009/05/08/is-xul-cool/feed</wfw:commentRss>
		</item>
		<item>
		<title>apache with a segmentation fault</title>
		<link>http://kerbtier.ch/2009/03/18/apache-with-a-segmentation-fault</link>
		<comments>http://kerbtier.ch/2009/03/18/apache-with-a-segmentation-fault#comments</comments>
		<pubDate>Wed, 18 Mar 2009 12:59:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[development]]></category>

		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://kerbtier.ch/?p=148</guid>
		<description><![CDATA[i deployed a python app on a live server and the only output i got was a blank page. there was no error in the virtual hosts log file and it stopped somewhere during the execution of the script. in the apache error log file i found the following line:
child pid 15136 exit signal Segmentation [...]]]></description>
			<content:encoded><![CDATA[i deployed a python app on a live server and the only output i got was a blank page. there was no error in the virtual hosts log file and it stopped somewhere during the execution of the script. in the apache error log file i found the following line:
<code>child pid 15136 exit signal Segmentation fault (11)</code>
a very informative and helpful message. after a bit of googling i found out that the gdb would help. gdb is short for <a href="http://www.gnu.org/software/gdb/">GNU Project Debugger</a>. in the file /usr/share/doc/apache2.2-common/README.backtrace there is a short howto to get a stacktrace of a segmentation fault in apache&#8230; at least on debian based systems. here is a short overview of what there is to do. at first it&#8217;s necessary to install the following packages:
<code>apt-get install apache2-dbg libapr1-dbg libaprutil1-dbg gdb</code>
add the line
<code>CoreDumpDirectory /var/cache/apache2</code>
to your apache config, usually /etc/apache/apache2.conf.
after a restart of apache it should now create a memory dump named /var/cache/apache2/core which can be analysed with gdb. it might be necessary to set the maximum size of the coredump like following (inclusive restart of apache):
<code>/etc/init.d/apache2 stop
ulimit -c unlimited
/etc/init.d/apache2 start
</code>

to analyze the core dump you need to execute the gdb like following:
<code>
gdb /usr/sbin/apache2 /var/cache/apache2/core
(gdb) bt full
...
(gdb) quit
</code>
if you use the threaded mpm (unlikely) then you need to use
<code>
gdb /usr/sbin/apache2 /var/cache/apache2/core
(gdb) thread apply all bt full
...
(gdb) quit
</code>

my dump produced following output:
<code>#0  0xb7dd86a5 in free () from /lib/libc.so.6
#1  0xb6675011 in RelinquishMagickMemory () from /usr/lib/libMagick.so.9
#2  0xb6625ba0 in DestroyDrawInfo () from /usr/lib/libMagick.so.9
#3  0xb57d9857 in Magick::Options::~Options () from /usr/lib/libMagick++.so.10
#4  0xb57d6725 in Magick::ImageRef::~ImageRef () from /usr/lib/libMagick++.so.10
#5  0xb57cbfe6 in Magick::Image::~Image () from /usr/lib/libMagick++.so.10
#6  0xb59ed7f3 in boost::python::objects::value_holder<Magick::Image>::~value_holder
    () from /var/lib/python-support/python2.5/PythonMagick/_PythonMagick.so
#7  0xb581adea in ?? () from /usr/lib/libboost_python-gcc42-1_34_1-py25.so.1.34.1
#8  0xb6ce6f4f in ?? () from /usr/lib/libpython2.5.so.1.0
#9  0&#215;0889a39c in ?? ()
#10 0xb6d8f7e0 in ?? () from /usr/lib/libpython2.5.so.1.0
#11 0xbf80d088 in ?? ()
#12 0xb6ce6c60 in ?? () from /usr/lib/libpython2.5.so.1.0
#13 0&#215;00000000 in ?? ()
</code>
i was using pythonMagick which uses Magick++ wich uses ImageMagick. it was a bit irritating that Magick++ version 10 used ImageMagick version 9 instead of 10. after removing ImageMagick version 9 the problem was gone. no idea why it used the wrong version.
]]></content:encoded>
			<wfw:commentRss>http://kerbtier.ch/2009/03/18/apache-with-a-segmentation-fault/feed</wfw:commentRss>
		</item>
		<item>
		<title>image manipulation with python</title>
		<link>http://kerbtier.ch/2009/03/11/image-manipulation-with-python</link>
		<comments>http://kerbtier.ch/2009/03/11/image-manipulation-with-python#comments</comments>
		<pubDate>Wed, 11 Mar 2009 13:07:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[development]]></category>

		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://kerbtier.ch/?p=142</guid>
		<description><![CDATA[in webapps you often need to manipulate images. create thumbnails, add shadows or borders, create captchas and many other things. usually i use imagemagick. it&#8217;s a very powerfull image manipulation tool with apis for many languages. i often experienced some difficulties when trying to use it with a specific language. there i usually almost no [...]]]></description>
			<content:encoded><![CDATA[in webapps you often need to manipulate images. create thumbnails, add shadows or borders, create captchas and many other things. usually i use imagemagick. it&#8217;s a very powerfull image manipulation tool with apis for many languages. i often experienced some difficulties when trying to use it with a specific language. there i usually almost no documentation for the apis and it looks like it&#8217;s not a lot used. many tend to call the imagemackig executable trough a os call.

<h3>how is it with python</h3>
i found a few image magick python modules. most were completely undocumented, unfinished or more or less uninstallable (at least on a 64 bit debian). the one who works properly is <a href="http://www.imagemagick.org/download/python/">PythonMagick</a>. i first tried to install the lattest version but due to some dependencies problems it wasn&#8217;t possible on my ubuntu system. there is a deb package available which was easyli installed with:
<code>sudo apt-get install python-pythonmagick
</code>
it&#8217;s not the latest version but it worked ok, at least for my needs.

<h3>how do you use it</h3>
i found no documentation for it but it was quite simple to figure out the basic things. there is <a href="http://www.imagemagick.org/Magick++/Image.html#Image%20Manipulation%20Methods">documentation for Magick++</a> which is a object oriented wrapper around imagemagick. all the image methods have short descriptions. to add a red 2 pixel border to an image for example you need following code:
<code>from PythonMagick import Image
i = Image('example.jpg')   # reades image and creates an image instance
i.borderColor("#ff0000")    # sets border paint color to red
i.border("2x2")                # paints a 2 pixel border
i.write("out.jpg")    # writes the image to a file
</code>

the parameter &#8220;2&#215;2&#8243; of the border method is a <a href="http://www.imagemagick.org/script/command-line-processing.php#geometry">geometry string</a> used by imagemagick as input for many methods. another example who crops the image, flips it, adds an oil paint look and finally save it as a png.
<code>i = Image('example.jpg')
i.crop("100x100+25+25")
i.flip()
i.oilPaint(2)
i.save('out.png')
</code>
 if i find some spare time i will add a few more complex examples of how to use imagemagick from python.]]></content:encoded>
			<wfw:commentRss>http://kerbtier.ch/2009/03/11/image-manipulation-with-python/feed</wfw:commentRss>
		</item>
		<item>
		<title>python, i like the snake</title>
		<link>http://kerbtier.ch/2009/03/02/python-i-like-the-snake</link>
		<comments>http://kerbtier.ch/2009/03/02/python-i-like-the-snake#comments</comments>
		<pubDate>Mon, 02 Mar 2009 10:31:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[development]]></category>

		<category><![CDATA[java]]></category>

		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://kerbtier.ch/?p=135</guid>
		<description><![CDATA[90% of my development work during the last few years was done in java. i had to create a little project for the OLPC about a year ago. OLPC is using python very heavily and so i developed the tool in python. before that, i did only a few very simple things in python. a [...]]]></description>
			<content:encoded><![CDATA[90% of my development work during the last few years was done in java. i had to create a little project for the <a href="laptop.org">OLPC</a> about a year ago. OLPC is using python very heavily and so i developed the tool in python. before that, i did only a few very simple things in python. a few weeks ago i started to develop webapplications in python. here are a few ideas and a list of packages/ software i used.

<h3>python versus java</h3>
compared with java, python is IMHO not as clean. it isn&#8217;t as &#8220;designed&#8221; as java is. but compared with, for example PHP, it&#8217;s a hyper clean and intuitive language. java is static typed and although also bytecode compiled like python, it needs an explicit compilation step. this makes developing python programs a bit more agile. for java and python there are lots of libraries/ packages available. as much as i have seen the python ones seems to be usually higher quality, but this can just be the selection i made and doesn&#8217;t need to be a general thing. the most important point in using python for webapps instead of java is that the python programs are usually fewer lines of code compared to the java programs. as much as i have seen till now i think this is also possible while having at least the same readability of the code like java programs. on the other hand you can write more easyli horrible code in python than in java. so python needs a bit more discipline. i will use python mainly for little not so critical projects, at least until i am fluent with it.

<h3>what did i use for webapps</h3>
with java i usually used an apache with mod_jk to connect to tomcat. i looked for a similar setup in python and found that there are a lot of possible ways but the most promising thing was the <a href="http://www.wsgi.org/wsgi/">WSGI</a> standard. there was a module for apache2 and so i was happy. WSGI is short of WebServer Gateway Interface and it sits somewhere between the webserver and python. compared with java where a application server is used who shares a common context for all servlets/ requests, WSGI-python scripts are loaded in a context for each process (apache processes i think), so caching and communication with other requests is not possible. but, if you are used to develop your applications with a cluster in mind it doesn&#8217;t hurt. you can use <a href="http://www.danga.com/memcached/">memcached</a> for a cache.<br/><br/>

because WSGI is a very low level interface it&#8217;s best to use a proper webframework. there are lots of them. the most are full blown frameworks and i am a bit allergic to them, i like it when i can put together the tools i want and doesn&#8217;t have to be pushed to use a certain way (forced, you are never. with full blown frameworks it&#8217;s the same as with certain girlfriends. they tend to give subtle hints about something but don&#8217;t force you, they are open to everyting but you get afraid what awaits you if you really go with something else then her preferred way). the only one i kind of liked was <a href="http://webpy.org/">web.py</a>. i&#8217;ts not the most beautiful but well built and it lets you do whatever you want if you like to. i use it mainly for mapping urls to code and webstuff like redirecting, send errors and stuff.<br/><br/>

to access a database there are different packages available. i checked for orm mappers and found quite a lot of different implementations. the two best (as much or less as i can judge it) are <a href="https://storm.canonical.com/">Storm</a> and <a href="http://www.sqlalchemy.org/">SQLAlchemy</a>. both are flexible, easy to use and have lots of functionality who doesn&#8217;t get in your way if not used. compared with <a href="http://hibernate.org/">hibernate</a> it&#8217;s a dream.<br/><br/>

to render html or whatever, i was looking for a good template language. there are many of them and i decided to use <a href="http://jinja.pocoo.org/2/documentation/">Jinja2</a>. its the one i liked most but, hey it&#8217;s a template language, they are almost all usefull, properly built and support about the same featureset.<br/><br/>

if i remember properly, thats all i needed, at least for the web aspect of the applications. python also has many very useful modules included, therefore you don&#8217;t need to include lots of modules. no crappy apache commons jars who give some functionality they missed to implement in the standard library.]]></content:encoded>
			<wfw:commentRss>http://kerbtier.ch/2009/03/02/python-i-like-the-snake/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
