<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1053249912953633645</id><updated>2011-11-30T19:43:49.008+01:00</updated><category term='gnuplot'/><category term='emacs'/><category term='english'/><category term='security'/><category term='latex'/><category term='development'/><category term='sqlite'/><category term='gtk'/><category term='yasnippet'/><category term='presence'/><category term='stackless'/><category term='rest'/><category term='maemo'/><category term='photo'/><category term='iphone'/><category term='android'/><category term='eyetv'/><category term='terminal'/><category term='scavenger'/><category term='python'/><category term='mac'/><category term='about the blog'/><category term='eclipse'/><category term='qt'/><category term='locusts'/><category term='procrastination'/><category term='chdk'/><title type='text'>Kedelig Data</title><subtitle type='html'>&lt;ul&gt;
&lt;li&gt;Kedelig (DK): Boring, not interesting, tedious&lt;/li&gt;
&lt;li&gt;Data: Plural form of datum, a piece of information&lt;/li&gt;
&lt;/ul&gt;</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>63</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-3506356887924317484</id><published>2011-07-05T13:04:00.002+02:00</published><updated>2011-07-05T13:18:35.727+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Python: Beware of standard parameter values</title><content type='html'>I just spent an hour hunting for a strange bug in my Python code, and once I found it it made perfect sense (it often does when one is on that side of a bug hunt), but it was still obscure enough that I want to share it with you. &lt;br /&gt;&lt;br /&gt;The bug occurred because of my (wrong) use of standard parameter values. Look at the following piece of code&lt;pre&gt;class Foo(object):&lt;br /&gt;    def __init__(self, mylist = []):&lt;br /&gt;        self._mylist = mylist&lt;br /&gt;    &lt;br /&gt;    def addSomethingToMyList(self, something):&lt;br /&gt;        self._mylist.append(something)&lt;br /&gt;        &lt;br /&gt;    def __str__(self):&lt;br /&gt;        return str(self._mylist)&lt;br /&gt;        &lt;br /&gt;if __name__ == '__main__':&lt;br /&gt;    f = Foo()&lt;br /&gt;    f.addSomethingToMyList(42)&lt;br /&gt;    print "I just added 42 to f's mylist, now it contains", f&lt;br /&gt;    f2 = Foo()&lt;br /&gt;    f2.addSomethingToMyList(117)&lt;br /&gt;    print "I just added 117 to f2's mylist, now it contains", f2&lt;/pre&gt;&lt;br /&gt;Just by looking at it, one could expect that this would print:&lt;pre&gt;I just added 42 to f's mylist, now it contains [42]&lt;br /&gt;I just added 117 to f2's mylist, now it contains [117]&lt;/pre&gt;&lt;br /&gt;It doesn't though. What it prints is this:&lt;pre&gt;I just added 42 to f's mylist, now it contains [42]&lt;br /&gt;I just added 117 to f2's mylist, now it contains [42, 117]&lt;/pre&gt;&lt;br /&gt;Now why is that, you may ask? Well it has something to do with when standard parameter values are instantiated - which must be on class definition time. So if you use a standard parameter value that is a reference type (objects, list, dicts, sets, etc) it is that one instance that is passed on to all instances of your class. &lt;br /&gt;&lt;br /&gt;The lesson therefore is: &lt;span style="font-weight:bold;"&gt;never use reference types in standard parameter values!&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-3506356887924317484?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/3506356887924317484/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2011/07/python-beware-of-standard-parameter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3506356887924317484'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3506356887924317484'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2011/07/python-beware-of-standard-parameter.html' title='Python: Beware of standard parameter values'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-957402766969118096</id><published>2011-03-22T21:56:00.004+01:00</published><updated>2011-03-22T22:13:56.535+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='scavenger'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Building the Scavenger Python library</title><content type='html'>This is the second "building scavenger" post -- see the post immediately before this one for a description of how to build the Scavenger daemon. In this post I will describe how you can install the Scavenger Python library on a client device, so that you may start offloading tasks to your Scavenger daemon instance. &lt;br /&gt;&lt;br /&gt;When installing the Scavenger library you designate a Python interpreter that you wish to install the Python modules into, so the first dependency is of course Python. Secondly, the script building the library uses &lt;a href="http://git-scm.com/"&gt;git&lt;/a&gt; to fetch the source code from GitHub, so git is a dependency too. &lt;br /&gt;&lt;br /&gt;Once you have these two dependencies installed, building and installing the Scavenger library (on a Mac or Linux machine) is as simple as 1) downloading &lt;a href="https://github.com/madsdk/python-execution-environment/raw/master/build/build_and_install_mac.sh"&gt;this script&lt;/a&gt;, and 2) running the script with the path to the chosen Python interpreter as an argument.&lt;pre&gt;$ wget https://github.com/madsdk/scavenger-library/raw/master/build/build_and_install.sh&lt;br /&gt;$ sh build_and_install.sh /usr/bin/python&lt;/pre&gt;If you have any questions about getting Scavenger to run on your system, please don't hesitate to contact me. The best thing to do is to leave a comment on this page, but you are also welcome to send me a mail.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-957402766969118096?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/957402766969118096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2011/03/building-scavenger-python-library.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/957402766969118096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/957402766969118096'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2011/03/building-scavenger-python-library.html' title='Building the Scavenger Python library'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-7902235715020132023</id><published>2011-03-22T21:34:00.004+01:00</published><updated>2011-03-22T21:55:32.403+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='scavenger'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Building the Scavenger daemon</title><content type='html'>I recently &lt;a href="http://kedeligdata.blogspot.com/2011/01/scavenger-and-presence-is-moving-to.html"&gt;moved the development of Scavenger onto GitHub.&lt;/a&gt; In that process I created two build scripts: One for building the Scavenger daemon on a Linux or Mac machine, and another for building and installing the Scavenger library on the same platforms. In this post I will describe the installation of the Scavenger daemon. &lt;br /&gt;&lt;br /&gt;In order to build the Scavenger daemon, you need to install a couple of dependencies. You need &lt;a href="http://git-scm.com/"&gt;git&lt;/a&gt;, the gcc compiler and, in order to compile the Presence daemon used for discovery, you also need to install the &lt;a href="http://qt.nokia.com/"&gt;Qt SDK&lt;/a&gt;. If you are on a Mac, getting gcc installed means that you should install Xcode and getting git installed can e.g., be done using &lt;a href="http://www.macports.org/"&gt;MacPorts&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;After having installed these dependencies building the Scavenger daemon is as simple of downloading and running &lt;a href="https://github.com/madsdk/python-execution-environment/raw/master/build/build_and_install_mac.sh"&gt;the Mac script&lt;/a&gt; or &lt;a href="https://github.com/madsdk/python-execution-environment/raw/master/build/build_and_install_linux.sh"&gt;the Linux script&lt;/a&gt;. The script should be downloaded to and run from the folder in which you would like to build the Scavenger daemon. When run it will download and build Stackless Python, checkout and build the relevant GitHub projects, and configure a Scavenger daemon instance. &lt;br /&gt;&lt;br /&gt;After having successfully run the build script, you can start a Scavenger daemon instance by entering the scavenger_daemon directory and running the start_daemon.sh script.&lt;br /&gt;&lt;br /&gt;If you have any questions about getting Scavenger to run on your system, please don't hesitate to contact me. The best thing to do is to leave a comment on this page, but you are also welcome to send me a mail.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-7902235715020132023?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/7902235715020132023/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2011/03/building-scavenger-daemon.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/7902235715020132023'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/7902235715020132023'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2011/03/building-scavenger-daemon.html' title='Building the Scavenger daemon'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-1892648011825561420</id><published>2011-03-02T10:31:00.005+01:00</published><updated>2011-03-02T10:39:17.962+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gtk'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Building PyGTK for Mac</title><content type='html'>In the past couple of months a number of people have asked me to provide new native Mac PyGTK builds. I do not use PyGTK anymore, so I don't have time to maintain these builds - sorry. Out of curiosity I recently built PyGTK on my Snow Leopard (10.6.6) machine, just to see if the process has gotten any easier, and I must say that it has. I was able to build the entire thing without any hacking. So, to those of you asking me to provide new builds, here you have a complete HOWTO of how to build a native Mac PyGTK:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Create a new user account (to make sure that no MacPorts/Fink/other libraries are available in the environment)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Install git (http://code.google.com/p/git-osx-installer/downloads/list?can=3)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Log in to the new account (I ssh'ed in from a Terminal)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Download the build script (https://github.com/jralls/gtk-osx-build/raw/master/gtk-osx-build-setup.sh)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Add ~/.local/bin to PATH&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Edit ~/.jhbuildrc-custom setting setup_sdk like so: setup_sdk(target="10.6", sdk_version="10.6", architectures=["i386"])&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Run these build commands:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;    &lt;li&gt;$ jhbuild bootstrap&lt;/li&gt;&lt;br /&gt;    &lt;li&gt;$ jhbuild build meta-gtk-osx-bootstrap&lt;/li&gt;&lt;br /&gt;    &lt;li&gt;$ jhbuild build meta-gtk-osx-core&lt;/li&gt;&lt;br /&gt;    &lt;li&gt;$ jhbuild build pygtk&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Download the PyGTK hello world script (http://www.pygtk.org/pygtk2tutorial/examples/helloworld.py)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Update your PYTHONPATH: export export PYTHONPATH=$PYTHONPATH:~/gtk/inst/lib/python2.6/site-packages&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Make sure that 32-bit Python is used: export VERSIONER_PYTHON_PREFER_32_BIT=yes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Test your build by running the hello world script: python helloworld.py&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Note that to perform the last step you need to be properly logged in (not just through SSH).&lt;br /&gt;&lt;br /&gt;I hope that this helps some of the people that have asked me about PyGTK builds. Happy hacking ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-1892648011825561420?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/1892648011825561420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2011/03/building-pygtk-for-mac.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1892648011825561420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1892648011825561420'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2011/03/building-pygtk-for-mac.html' title='Building PyGTK for Mac'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-5310675136107627248</id><published>2011-01-11T10:04:00.004+01:00</published><updated>2011-01-11T10:17:27.295+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rest'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Testing Restlet webservices from telnet</title><content type='html'>For the upcoming P2P course at Aarhus University (which I have been co-teaching for the past four years) I am currently playing around with the &lt;a href="http://www.restlet.org/"&gt;Restlet REST API&lt;/a&gt;. We want the students to learn something about peer-to-peer algorithms, protocols, and techniques, and seeing as we like a hands-on approach we always ask them to code a small P2P system as an ongoing exercise throughout the course. In past years we have asked them to do this programming using regular sockets, but that is about to change... While learning about the socket abstraction may be instrumental in teaching a coming computer scientist about the underlying constructs of the network stack, it may be time to teach them this stuff only cursory and then skip ahead to a higher level of abstraction. I mean, who (besides myself) actually works with sockets anymore?&lt;br /&gt;&lt;br /&gt;We have therefore decided to teach the students about REST and let them use the Restlet API to create their own P2P system. But before throwing a new API at my students, I like to experiment with it myself, and I therefore dived into a little bit of Restlet programming. In the process I needed to be able to test a HTTP PUT call to my Restlet, which can not (afaik) be done easily from a webbrowser. I therefore went to my old friend telnet for help. So, if you need to test a HTTP PUT call to a webserver from telnet do the following:&lt;pre&gt;telnet localhost 8182&lt;br /&gt;PUT /peerlist HTTP/1.1&lt;br /&gt;Host: localhost&lt;br /&gt;Content-Length: 13&lt;br /&gt;&lt;br /&gt;Hello, World!&lt;br /&gt;&lt;/pre&gt;Substitute host, URL, and content to your hearts contend.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-5310675136107627248?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/5310675136107627248/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2011/01/testing-restlet-webservices-from-telnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/5310675136107627248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/5310675136107627248'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2011/01/testing-restlet-webservices-from-telnet.html' title='Testing Restlet webservices from telnet'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-3519678758327098100</id><published>2011-01-05T16:51:00.003+01:00</published><updated>2011-01-05T17:02:47.666+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='presence'/><category scheme='http://www.blogger.com/atom/ns#' term='scavenger'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Scavenger and Presence are moving to GitHub</title><content type='html'>I am currently re-booting my work on Scavenger (and therefore also on the Presence service discovery framework) as I need it for some upcoming research. In the process I have decided to move the source code from the Google Code pages and onto GitHub instead. In the last couple of months I have become increasingly fond of git---especially as a collaborative tool where other developers can freely fork my repositories, play around with the source on their own, and then send me a pull request when they are satisfied with their changes. This way of working has worked out extremely well in my small &lt;a href="https://github.com/madsdk/yasnippets-latex"&gt;LaTeX YaSnippet&lt;/a&gt; project. I hope that switching to GitHub means that more people will consider adding to both Scavenger and Presence.&lt;br /&gt;&lt;br /&gt;While moving the code I have also done quite a bit of refactoing and "spring cleaning". This means that the code has now been split into six (more or less) independent projects. All of these can be found here &lt;a href="https://github.com/madsdk/"&gt;https://github.com/madsdk/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Installing the Scavenger client library or the Scavenger daemon has also been simplified quite a bit. Both the lib and the daemon now have build scripts that work on Mac and Linux. If I e.g., would like a Scavenger daemon running om my laptop, I would simply download and run &lt;a href="https://github.com/madsdk/python-execution-environment/raw/master/build/build_and_install_mac.sh"&gt;this script&lt;/a&gt;. The script must be placed in the folder where you would like to install the Scavenger daemon, and it will then download and build all dependencies (Stackless Python, Presence daemon, diverse Python modules). Notice that in order to build the Presence daemon you need to have the &lt;a href="http://qt.nokia.com"&gt;Qt development tools&lt;/a&gt; installed.&lt;br /&gt;&lt;br /&gt;Happy hacking!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-3519678758327098100?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/3519678758327098100/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2011/01/scavenger-and-presence-is-moving-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3519678758327098100'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3519678758327098100'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2011/01/scavenger-and-presence-is-moving-to.html' title='Scavenger and Presence are moving to GitHub'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-6729273782088465350</id><published>2010-12-06T10:42:00.003+01:00</published><updated>2010-12-06T10:46:03.652+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='stackless'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Building Stackless Python on Snow Leopard</title><content type='html'>I have had a hard time debugging this problem I have had with running Stackless Python on my Snow Leopard Mac - that is until I stumbled upon &lt;a href="http://www.nagare.org/trac/blog/macosx-nagare-installation-2"&gt;this post&lt;/a&gt;. It seems that the problem is with using Stackless on a 64-bit Mac OS, and the solution is thus to build Stackless in a 32-bit version. So, if you're having problems with Stackless Python crashing with a "Bus error", do this when you configure during the build process:&lt;pre&gt;CC="gcc -arch i386" ./configure --enable-stacklessfewerregisters&lt;/pre&gt;That seems to have solved the problem for me anyway ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-6729273782088465350?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/6729273782088465350/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2010/12/building-stackless-python-on-snow.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/6729273782088465350'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/6729273782088465350'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2010/12/building-stackless-python-on-snow.html' title='Building Stackless Python on Snow Leopard'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-3094167627018694646</id><published>2010-11-25T09:20:00.003+01:00</published><updated>2010-11-25T10:17:44.390+01:00</updated><title type='text'>My LaTeX snippets for YaSnippet/Emacs are still alive</title><content type='html'>I have very few words for you this time. All I want to do, is to point out that my &lt;a href="https://github.com/madsdk/yasnippets-latex/"&gt;LaTeX snippets&lt;/a&gt; for &lt;a href="http://code.google.com/p/yasnippet/"&gt;YaSnippet&lt;/a&gt; (an &lt;a href="http://www.gnu.org/software/emacs/"&gt;Emacs&lt;/a&gt; snippet plugin) is still alive. I have not updated it myself for quite some time, since I seem to be satisfied with the collection of snippets I already have, but others have been doing the updating for me! Oh the joys of open source ;-)&lt;br /&gt;&lt;br /&gt;The snippet collection is therefore still growing, thanks to additions made by Bjorn Reese, Song Qiang, and Claudio Marforio. Thanks you guys!&lt;br /&gt;&lt;br /&gt;If you are interested in adding snippets to the collection please do one of the following (listed in prioritized order):&lt;br /&gt;1) Create your own branch on &lt;a href="https://github.com"&gt;github&lt;/a&gt; and send me a pull request, or&lt;br /&gt;2) Send me the snippets by email.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-3094167627018694646?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/3094167627018694646/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2010/11/my-latex-snippets-for-yasnippetemacs-is.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3094167627018694646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3094167627018694646'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2010/11/my-latex-snippets-for-yasnippetemacs-is.html' title='My LaTeX snippets for YaSnippet/Emacs are still alive'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-8175680399035384330</id><published>2010-09-10T10:40:00.005+02:00</published><updated>2010-09-10T11:01:01.917+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='sqlite'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>SQLite with stdev (standard deviation) and more!</title><content type='html'>At the moment I am collecting data - hoards of data - my test suite is a veritable cornucopia of boring data. Normally I would be logging such data into flat files, collecting some giga bytes of log files that I would then need to write a handful of Python, Perl, or Ruby scripts to make any sense of. I have done this a thousand times before ... and I'm getting tired of it!&lt;br /&gt;&lt;br /&gt;In comes my new best friend - SQLite. This small relational-database-in-a-file is excruciatingly easy to use from almost any programming language you could think of. So instead of writing a lot of data handling scripts, this time I have written only one - a script that imports the log data into an SQLite database. All other questions about the data, and how the different test results relate to each other, can thus be formulated in simple SQL instead of through increasingly complex Python scripts.&lt;br /&gt;&lt;br /&gt;"When are you coming to the stdev part!", you say? Calm down, I'm getting there. Working with my data in a relational database I found that there were only one piece of functionality that I was missing, and that was the possibility to select out both an average _and_ the standard deviation of a data set. Luckily, this is possible in SQLite through a simple extension.&lt;br /&gt;&lt;br /&gt;This is what you do:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Fetch the source code for the extension &lt;a href="http://www.sqlite.org/contrib?orderby=date"&gt;here&lt;/a&gt; [&lt;a href="http://www.sqlite.org/contrib/download/extension-functions.c?get=25"&gt;direct link&lt;/a&gt;]&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Compile it:&lt;pre&gt;Mac$ gcc -fno-common -dynamiclib extension-functions.c -o libsqlitefunctions.dylib&lt;br /&gt;Linux$ gcc -fPIC -lm -shared extension-functions.c -o libsqlitefunctions.so&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Copy the resulting library to some location where you want to store it. In my case that would be $HOME/opt/lib&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Before executing your select statements be sure to load the extension in SQLite by issuing the following command (within SQLite):&lt;pre&gt;select load_extension('/full/path/to/libsqlitefunctions.dylib');&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;And you're done! Now you can issue select statements with stdev as an aggregate function. E.g.:&lt;pre&gt;SELECT name, stdev(seconds) &lt;br /&gt;FROM benchmarks &lt;br /&gt;GROUP BY name&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note: The SQLite version included in Mac OS X 10.6 does not allow extensions, so you will have to build it yourself. That is luckily easily done - fetch the source &lt;a href="http://www.sqlite.org/download.html"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-8175680399035384330?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/8175680399035384330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2010/09/sqlite-with-stdev-standard-deviation.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8175680399035384330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8175680399035384330'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2010/09/sqlite-with-stdev-standard-deviation.html' title='SQLite with stdev (standard deviation) and more!'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-3289681079816596815</id><published>2010-06-29T09:05:00.002+02:00</published><updated>2010-06-29T09:31:23.970+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scavenger'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>On CPU profiling</title><content type='html'>CPUs are different ... no really, they are. And when working with task scheduling over heterogeneous peers, which is the metier of Scavenger, this heterogeneity of the peers makes it very hard to come up with precise running time estimates. When estimating a task's running time on a peer one needs two things: 1) the running time of the task (with the given input) on a known peer, and 2) a "strength" rating on each peer that says something about how strong the peer is w.r.t. processing work. Having this information an estimated running time can be derived simply by assuming that a peer of strength x can perform a given task twice as fast as a peer of strength x/2. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This is all fairly straight forward, but the tricky part is finding that magical "strength" value for each peer. In related systems, such as Spectra and Chroma, the CPUs clock speed and its Linux BogoMIPS rating has been used, respectively. I expected that these values were pretty useless at estimating peer strength, and my experiments up until now seem to confirm that suspicion. Because of that I in Scavenger chose to use a real CPU benchmark for the strength value, thinking that a CPU benchmark would be written specifically to exercise all the various parts of a CPU and therefore would be more apt at describing its relative strength. I have used the &lt;a href="http://www.tux.org/~mayer/linux/bmark.html"&gt;nbench&lt;/a&gt; benchmarking suite - primarily because it is available as source code, so that I can compile and run it on any platform that I would like to test. Nbench returns two scores, an integer and a floating point score, so I chose to use the average of these two scores as peer strength. My experiments show that this value does indeed model CPU strength much better than clock speed or BogoMIPS - but it is far from perfect!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Because of that I have started work on a new profiling approach - one that will either 1) increase the accuracy when estimating running time on hitherto unknown peers, or 2) show that the performance of different CPU architectures can not be scored on a linear scale... Of course I am hoping for 1 but I somehow expect to conclude 2 :-)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-3289681079816596815?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/3289681079816596815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2010/06/on-cpu-profiling.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3289681079816596815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3289681079816596815'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2010/06/on-cpu-profiling.html' title='On CPU profiling'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-5291495127673542595</id><published>2010-05-05T20:47:00.004+02:00</published><updated>2010-09-12T12:37:51.879+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='eyetv'/><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Getting EyeTV to Put Your Mac to Sleep ... Intelligently!</title><content type='html'>One feature that I _really_ miss in EyeTV is the ability to put my Mac to sleep after a recording. It is possible to write an AppleScript that reacts to the RecordingDone signal in EyeTV, but my previous foray into that area ended up with a simple script that said something like&lt;pre&gt;on RecordingDone(recordingID)&lt;br /&gt;   tell application "Finder" to sleep&lt;br /&gt;end RecordingDone&lt;/pre&gt;This works to some extent but it does have some serious flaws. First and foremost it ruins your second recording if you have scheduled to record two programs back-to-back. In that case EyeTV records the first program, emits the RecordingDone signal, starts recording the second program, and about five seconds into that recording the computer goes to sleep ;-) Another problem with this approach is when you are recording something while you are working on the computer - in that case your computer suddenly goes to sleep while you are working.&lt;br /&gt;&lt;br /&gt;This has annoyed me quite a bit, but seemingly not enough for me to actively search for a better solution - until today. Googling around a bit I found this script: &lt;a href="http://forums.elgato.com/viewtopic.php?f=91&amp;amp;t=1045#p18834"&gt;http://forums.elgato.com/viewtopic.php?f=91&amp;amp;t=1045#p18834&lt;/a&gt;. I have altered it a tiny bit to change the timeouts and to put the computer to sleep instead of powering it off. The result is here:&lt;br /&gt;&lt;pre&gt;on RecordingDone(recordingID)&lt;br /&gt;   set isCurrentlyRecording to check_eyetv_is_recording()&lt;br /&gt;   if isCurrentlyRecording is false then&lt;br /&gt;       with timeout of 300 seconds&lt;br /&gt;           tell me to activate&lt;br /&gt;           display dialog "Warning: EyeTV has now finished recording and the system will automatically shut down in 5 minutes unless you click Stop!" with icon 2 buttons {"Stop!"} giving up after 300 default button "Stop!"&lt;br /&gt;           set theresults to the result&lt;br /&gt;           if gave up of theresults is true then&lt;br /&gt;               tell application "System Events" to sleep&lt;br /&gt;           end if&lt;br /&gt;       end timeout&lt;br /&gt;   else&lt;br /&gt;       quit&lt;br /&gt;   end if&lt;br /&gt;end RecordingDone&lt;br /&gt;&lt;br /&gt;to check_eyetv_is_recording()&lt;br /&gt;   delay 30&lt;br /&gt;   tell application "EyeTV"&lt;br /&gt;       if is_recording then&lt;br /&gt;           return true&lt;br /&gt;       else&lt;br /&gt;           return false&lt;br /&gt;       end if&lt;br /&gt;   end tell&lt;br /&gt;end check_eyetv_is_recording&lt;/pre&gt;This script works perfectly! When the recording is done a dialog is displayed telling you that the computer will be put to sleep in five minutes, and if you press the stop button you can keep the computer awake.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Update:&lt;/span&gt; A guy called Michael asked we where to put the script to make it work. You are supposed to save the scripts as /Library/Application Support/EyeTV/Scripts/TriggeredScripts/RecordingDone.scpt&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-5291495127673542595?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/5291495127673542595/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2010/05/getting-eyetv-to-put-your-mac-to-sleep.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/5291495127673542595'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/5291495127673542595'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2010/05/getting-eyetv-to-put-your-mac-to-sleep.html' title='Getting EyeTV to Put Your Mac to Sleep ... Intelligently!'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-9129076141199040572</id><published>2010-03-19T16:09:00.003+01:00</published><updated>2010-03-19T16:16:28.364+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='procrastination'/><category scheme='http://www.blogger.com/atom/ns#' term='yasnippet'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>YASnippet LaTeX bundle GitHub Project</title><content type='html'>A long time ago &lt;a href="http://kedeligdata.blogspot.com/2009/03/yasnippet-latex-bundle.html"&gt;I wrote about&lt;/a&gt; a &lt;a href="http://www.latex-project.org/"&gt;LaTeX&lt;/a&gt; &lt;a href="http://code.google.com/p/yasnippet/"&gt;YASnippet&lt;/a&gt; bundle that I was building - but I never really got around to publishing it in a way so that anybody except me could get at them. I did create a Google Sites homepage for it, but that's a terrible way to share source code :-)&lt;br /&gt;&lt;br /&gt;I have therefore just created a &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt; project called &lt;a href="http://github.com/madsdk/yasnippets-latex/"&gt;yasnippets-latex&lt;/a&gt;. Now my snippets are freely available - released under the GPL of course. So grab them, play with them, branch the project, create your own snippets, improve my snippets, etc.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-9129076141199040572?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/9129076141199040572/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2010/03/yasnippet-latex-bundle-github-project.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/9129076141199040572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/9129076141199040572'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2010/03/yasnippet-latex-bundle-github-project.html' title='YASnippet LaTeX bundle GitHub Project'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-1828659575917362089</id><published>2010-03-11T13:08:00.002+01:00</published><updated>2010-03-11T14:25:04.376+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Playing around with MacJournal</title><content type='html'>I have recently bought the &lt;a href="http://macheist.com/"&gt;MacHeist&lt;/a&gt; nanoBundle2 which included a license for &lt;a href="http://www.marinersoftware.com/sitepage.php?page=85"&gt;MacJournal&lt;/a&gt; - yet another journaling software for Mac. I already have &lt;a href="http://www.evernote.com/"&gt;Evernote&lt;/a&gt;, which seems to be far better than MacJournal for journalling, but MacJournal has some blogging features that I may be interested in. So I guess I’ll give it a try. This entry is written in MacJournal b.t.w. ;-)&lt;br /&gt;&lt;br /&gt;This image was just copied into the editor window - and then resized a bit to try that out as well. It’s a photo I took during my recent vacation in Sweden b.t.w.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now lets try some pre-formatted text (I need that for displaying code examples). I did this by changing the font in MacJournal to Courier 12pt - I would have liked to edit HTML tags instead...:&lt;br /&gt;&lt;br /&gt;def compare_us(x, y):&lt;br /&gt;  return true if x == y else false&lt;br /&gt;&lt;br /&gt;And then some regular text again...&lt;br /&gt;&lt;br /&gt;Edit: Well, that did not work at all! I guess MacJournal is not for me then  :-) My initial experiences with the software have not been very  good. The first time I added a blog the application crashed, and I had  to try five times before the auto update function actually worked. When adding a blog entry it did not append any of the tags I chose, the editor did not allow me to edit the HTML source etc. Conclusion: it is a crappy blog editor.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-1828659575917362089?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/1828659575917362089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2010/03/playing-around-with-macjournal.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1828659575917362089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1828659575917362089'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2010/03/playing-around-with-macjournal.html' title='Playing around with MacJournal'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-5546614754310655512</id><published>2010-02-09T13:21:00.002+01:00</published><updated>2010-02-09T13:26:52.245+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>XeLaTeX on a Mac</title><content type='html'>As I wrote a couple of hours ago, I am currently writing my thesis using &lt;a href="http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;amp;id=XeTeX"&gt;XeLaTeX&lt;/a&gt;. In the process I have found that the &lt;a href="http://www.macports.org"&gt;MacPorts&lt;/a&gt; version of XeLaTeX seems to be broken when it comes to accepting/finding user-installed fonts. My LaTeX template needs a font called &lt;a href="http://www.josbuivenga.demon.nl/fontinsans.html"&gt;Fontin Sans&lt;/a&gt; that I have downloaded and installed into my "Font Book" on my Mac. After doing that the MacPorts version of XeLaTeX still couldn't find the font, so I uninstalled the texlive packages fro MacPorts and installed the &lt;a href="http://www.tug.org/mactex/2009/"&gt;MacTeX 2009 package&lt;/a&gt; instead. And now everything works :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-5546614754310655512?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/5546614754310655512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2010/02/xelatex-on-mac.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/5546614754310655512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/5546614754310655512'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2010/02/xelatex-on-mac.html' title='XeLaTeX on a Mac'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-2097852729446776365</id><published>2010-02-09T10:48:00.003+01:00</published><updated>2010-02-09T11:03:45.925+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='emacs'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>XeLaTeX and Aquamacs Emacs</title><content type='html'>I have finally begun writing my thesis... or sort of anyway - I have definitely started playing around with a LaTeX skeleton for it :-P&lt;br /&gt;&lt;br /&gt;My friend Clemens gave me the &lt;a href="http://www.latex-project.org/"&gt;LaTeX&lt;/a&gt; template that he used for his thesis, and it creates really pretty documents so I definitely wanted to use it for my thesis as well. But, this template makes use of &lt;a href="http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;amp;id=XeTeX"&gt;XeLaTeX&lt;/a&gt;, a LaTeX variant that supports use of Unicode and "modern font technologies". I found that I already had xelatex installed on my system; apparently it comes with the &lt;a href="http://www.macports.org/"&gt;MacPorts&lt;/a&gt; LaTeX installation, but it did not work immediately in Aquamacs. There _was_ a XeLaTeX command in Aquamacs, but in the background it was calling pdflatex, which in turn went into some never ending loop using a full CPU core...&lt;br /&gt;&lt;br /&gt;In order to fix that you need to do change the way the xelatex command is called in Aquamacs, as &lt;a href="http://www.tug.org/pipermail/macostex-archives/2008-October/037366.html"&gt;described here&lt;/a&gt;.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Open Aquamacs in LaTeX mode (by opening a .tex file).&lt;/li&gt;&lt;li&gt;Go the the LaTeX menu, choose "Customize AUCTeX", choose "TeX Command", choose "TeX Command List".&lt;/li&gt;&lt;li&gt;Navigate to the XeLaTeX command (just search for xelatex).&lt;/li&gt;&lt;li&gt;Alter the "Command" part of that section to "%`xelatex --synctex=1%(mode)%' %t"&lt;/li&gt;&lt;li&gt;Set the "How" part to "TeX-run-command".&lt;/li&gt;&lt;li&gt;Make sure that LaTeX, ConTeXt, and AmSTeX have been checked off in the bottom part of the section.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Save the settings (Ctrl+x, Ctrl+s as usual).&lt;/li&gt;&lt;/ol&gt;And now it works!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-2097852729446776365?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/2097852729446776365/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2010/02/xelatex-and-aquamacs-emacs.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/2097852729446776365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/2097852729446776365'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2010/02/xelatex-and-aquamacs-emacs.html' title='XeLaTeX and Aquamacs Emacs'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-1714310400376245221</id><published>2010-02-03T14:18:00.004+01:00</published><updated>2010-02-03T14:31:30.351+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scavenger'/><title type='text'>Scavenger Daemon - VMWare Fusion Image</title><content type='html'>I have just uploaded a &lt;a href="http://www.vmware.com/products/fusion/"&gt;VMWare Fusion 3&lt;/a&gt; virtual machine image that you may use to tryout &lt;a href="http://code.google.com/p/scavenger-cf/"&gt;Scavenger&lt;/a&gt;. The image is a minimal Ubuntu 9.10 server install with &lt;a href="http://code.google.com/p/presence-discovery/"&gt;Presence&lt;/a&gt; and Scavenger pre-installed - you can &lt;a href="http://www.cs.au.dk/%7Emadsk/files/ScavengerAppliance.zip"&gt;fetch it here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Here's how you use it:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Download and unpack the zip file.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Open the VM in VMWare Fusion 3. When it prompts you the first time select "Take ownership", and the second time you must choose "I copied it".&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Login with username "scavenger" and password "scavenger".&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Go to $HOME/scavenger (i.e., "cd scavenger").&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Start the Scavenger daemon by issuing this command: "./start_daemon.sh"&lt;/li&gt;&lt;/ul&gt;Now you have a fully functional Scavenger daemon running. The Scavenger daemon is running from an SVN checkout, so you may update it to the most current version by issuing the command "svn up daemon scavenger_common" from within the $HOME/scavenger directory.&lt;br /&gt;&lt;br /&gt;In order to make the daemon running within the VM discoverable you of course have to configure the networking options  to fit your environment. I think it is set to use bridged networking at the moment, which should fit in most circumstances.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-1714310400376245221?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/1714310400376245221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2010/02/scavenger-daemon-vmware-fusion-image.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1714310400376245221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1714310400376245221'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2010/02/scavenger-daemon-vmware-fusion-image.html' title='Scavenger Daemon - VMWare Fusion Image'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-7917960106960321711</id><published>2010-02-02T13:26:00.004+01:00</published><updated>2010-02-02T13:35:10.346+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scavenger'/><title type='text'>AugIm v. 2 released!</title><content type='html'>I have just released an entirely new version of my &lt;a href="http://scavenger-cf.googlecode.com"&gt;Scavenger&lt;/a&gt; demonstrator AugIm (The Augmented Image Manager). AugIm is now Maemo 5 only - and it is written in &lt;a href="http://www.riverbankcomputing.co.uk/software/pyqt/intro"&gt;PyQt&lt;/a&gt; so you need to add the extras-devel repository in order to install it.&lt;br /&gt;&lt;br /&gt;You can grab the demonstrator at Scavenger's Google Code page, or you could just use &lt;a href="http://scavenger-cf.googlecode.com/files/augim_2.0.0-1_all.deb"&gt;this direct link&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;B.t.w., if you look in 'branches' in Scavenger's SVN you will find an alternative version of AugIm. This version does _not_ use Scavenger, so it may be used as a comparison to the fully-fledged, Scavenger-enabled version.&lt;br /&gt;&lt;br /&gt;I have also created a VMWare Fusion image of a Scavenger daemon to make testing Scavenger easier, but I have yet to find out how to make such a VM distributable using Fusion... I'll probably link to the current Fusion-only image in the near future, and if I get the time I will try to create an &lt;a href="http://www.vmware.com/appliances/getting-started/learn/ovf.html"&gt;OVF compliant&lt;/a&gt; version.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-7917960106960321711?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/7917960106960321711/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2010/02/augim-v-2-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/7917960106960321711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/7917960106960321711'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2010/02/augim-v-2-released.html' title='AugIm v. 2 released!'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-5625845124490595838</id><published>2010-01-29T23:04:00.002+01:00</published><updated>2010-01-29T23:20:34.481+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='qt'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>PyQt: Emitting events from non-QObject subclasses.</title><content type='html'>In order to emit events in PyQt the emitting class must inherit directly from QObject. This can be quite a nuisance, especially so because multiple inheritance is impossible when using PyQt. E.g., I recently had the problem that I had task running in a QThreadPool that I would like to emit a signal when progress had been made, so that I could update a progressbar in my UI. To make the task runnable in a QThreadPool the task class had to inherit from QRunnable, and as QRunnable is not a subclass of QObject it was impossible to emit signals from within the task class. I found a solution to this problem though - one that I find quite elegant, so I'd like to share it with you :-)&lt;br /&gt;&lt;br /&gt;The trick is to use another object as the mediator for emitting signals, and then using &lt;a href="http://docs.python.org/library/functions.html#property"&gt;Python properties&lt;/a&gt; to hide the fact that a mediator is being used. Consider the example below:&lt;pre&gt;class Mediator(QObject):&lt;br /&gt;    mySignal = pyqtSignal(int)&lt;br /&gt;    def __init__(self):&lt;br /&gt;        super(Mediator, self).__init__()&lt;br /&gt;&lt;br /&gt;class Task(QRunnable):&lt;br /&gt;    def __init__(self):&lt;br /&gt;        super(Task, self).__init__()&lt;br /&gt;        self._mediator = Mediator()&lt;br /&gt;&lt;br /&gt;    def mySignal():&lt;br /&gt;        def fget(self):&lt;br /&gt;            return self._mediator.mySignal&lt;br /&gt;        return locals()&lt;br /&gt;    mySignal = property(**mySignal())&lt;/pre&gt;Using this approach any classes working with Task instances can connect directly to the mySignal signal as if it was bound directly to the Task class. So the property hides the fact that a mediator is in use.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-5625845124490595838?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/5625845124490595838/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2010/01/pyqt-emitting-events-from-non-qobject.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/5625845124490595838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/5625845124490595838'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2010/01/pyqt-emitting-events-from-non-qobject.html' title='PyQt: Emitting events from non-QObject subclasses.'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-3306204240562881059</id><published>2010-01-27T13:40:00.004+01:00</published><updated>2010-01-27T13:47:49.420+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='gnuplot'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Embedding fonts in Gnuplot generated PDFs</title><content type='html'>I have recently submitted two papers to an IEEE conference, and in doing so I had to make sure that _all_ fonts were embedded within the PDFs I submitted. This was not the case with one of my papers, and after some detective work I found out that this pertained to my using Gnuplot's PDF terminal to generate PDF graphs for my paper. Apparently Gnuplot is incapable of embedding fonts into the generated PDFs... &lt;br /&gt;&lt;br /&gt;I found &lt;a href="http://hughanchor.blogspot.com/2008/11/more-pdf-font-embedding-hijinks.html"&gt;this solution&lt;/a&gt; though. You need to pass the PDF that Gnuplot generated through ghostscript with the following command:&lt;pre&gt;gs -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=tmp.pdf\&lt;br /&gt;-dCompatibilityLevel=1.5 -dPDFSETTINGS=/prepress -c .setpdfwrite\&lt;br /&gt;-f infile.pdf&lt;/pre&gt;Where 'infile.pdf' is your Gnuplot graph. If you follow the link to where I found this hack, you may notice that I have changed the commandline slightly, so that it now creates PDF 1.5 compatible output. This is a requirement of IEEE papers I think.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-3306204240562881059?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/3306204240562881059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2010/01/embedding-fonts-in-gnuplot-generated.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3306204240562881059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3306204240562881059'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2010/01/embedding-fonts-in-gnuplot-generated.html' title='Embedding fonts in Gnuplot generated PDFs'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-2435469298987972750</id><published>2010-01-14T11:18:00.004+01:00</published><updated>2010-01-14T11:37:02.507+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><category scheme='http://www.blogger.com/atom/ns#' term='maemo'/><title type='text'>Avoiding "Size mismatch" Errors When Upgrading Maemo 5 Scratchbox</title><content type='html'>I have just returned to developing Maemo application, and as usual when I come back to my Maemo scratchbox installation, I start off by upgrading the development environment. So I opened my scratchbox and issued the commands&lt;pre&gt;fakeroot apt-get update&lt;br /&gt;fakeroot apt-get dist-upgrade&lt;/pre&gt;Unfortunately this did not work for me this time because of some inconsistencies in the index files kept at the Maemo servers (I think). I kept getting these "Failed to fetch http://someurl Size mismatch" errors. An example:&lt;pre&gt;...&lt;br /&gt;Failed to fetch http://repository.maemo.org/pool/maemo5.0/nokia-binaries/4bc37c7c77ebe90177c050b805a8dc79/nokia-binaries/h/hildon-application-manager-l10n/hildon-application-manager-l10n-plpl_6.0+r7389+0m5_all.deb  Size mismatch&lt;br /&gt;Failed to fetch http://repository.maemo.org/pool/maemo5.0/nokia-binaries/4bc37c7c77ebe90177c050b805a8dc79/nokia-binaries/h/hildon-application-manager-l10n/hildon-application-manager-l10n-ptpt_6.0+r7389+0m5_all.deb  Size mismatch&lt;br /&gt;Failed to fetch http://repository.maemo.org/pool/maemo5.0/nokia-binaries/4bc37c7c77ebe90177c050b805a8dc79/nokia-binaries/h/hildon-application-manager-l10n/hildon-application-manager-l10n-ruru_6.0+r7389+0m5_all.deb  Size mismatch&lt;br /&gt;Failed to fetch http://repository.maemo.org/pool/maemo5.0/nokia-binaries/4bc37c7c77ebe90177c050b805a8dc79/nokia-binaries/h/hildon-application-manager-l10n/hildon-application-manager-l10n-svse_6.0+r7389+0m5_all.deb  Size mismatch&lt;br /&gt;Failed to fetch http://repository.maemo.org/pool/maemo5.0/nokia-binaries/4bc37c7c77ebe90177c050b805a8dc79/nokia-binaries/h/hildon-theme-alpha/hildon-theme-alpha_9.1+0m5_all.deb  Size mismatch&lt;br /&gt;Failed to fetch http://repository.maemo.org/pool/maemo5.0/free/m/maemo-launcher/maemo-launcher_0.35-7+0m5_i386.deb  Size mismatch&lt;br /&gt;Failed to fetch http://repository.maemo.org/pool/maemo5.0/free/m/maemo-launcher/maemo-launcher-dev_0.35-7+0m5_all.deb  Size mismatch&lt;br /&gt;E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?&lt;br /&gt;&lt;/pre&gt;To avoid these errors I manually downloaded the packages involved and installed them with dpkg. To make this process easier I simply copied the error messages into a text file, removed the "Failed to fetch" prefix and the "Size mismatch" postfix from all lines using search/replace, and saved this as files.txt. Then I invoked the following commands from within my scratchbox targets:&lt;pre&gt;cat files.txt | xargs wget&lt;br /&gt;dpkg -i *.deb&lt;/pre&gt;And voila, it works ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-2435469298987972750?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/2435469298987972750/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2010/01/avoiding-size-mismatch-errors-when.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/2435469298987972750'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/2435469298987972750'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2010/01/avoiding-size-mismatch-errors-when.html' title='Avoiding &quot;Size mismatch&quot; Errors When Upgrading Maemo 5 Scratchbox'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-3434431462113170400</id><published>2009-12-17T10:32:00.006+01:00</published><updated>2009-12-17T20:18:02.835+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='stackless'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='scavenger'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Building Stackless Python on a PS3 (PPC Linux)</title><content type='html'>I have recently gotten my hands on a PlayStation 3 that I am trying to use as a surrogate[1] in my &lt;a href="http://code.google.com/p/scavenger-cf/"&gt;Scavenger&lt;/a&gt; system. The first thing I did was to install Ubuntu Linux 9.10 on it, and the next step was then getting Stackless Python to compile... Which turned out to be a bit of a bitch ;-)&lt;br /&gt;&lt;br /&gt;But after some heavy debugging and googling I found out how to do it:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Download the Stackless source distribution. I used version 2.6.4.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Unpack it somewhere and enter the newly created directory.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;$ ./configure --prefix=/where/you/want/it&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Edit the file called "Makefile" and change the variable SLPFLAGS to "SLPFLAGS=-fomit-frame-pointer -O2"&lt;/li&gt;&lt;br /&gt;&lt;li&gt;make&lt;/li&gt;&lt;br /&gt;&lt;li&gt;make install&lt;/li&gt;&lt;/ol&gt; It's very simple actually, just took me some time to find the solution :-) By the way, if you do not edit the Makefile you get the following error:&lt;pre&gt;./Stackless/core/slp_transfer.c: In function 'slp_transfer':&lt;br /&gt;./Stackless/core/slp_transfer.c:144: error: 31 cannot be used in asm here&lt;br /&gt;./Stackless/core/slp_transfer.c:144: error: 31 cannot be used in asm here&lt;br /&gt;make: *** [Stackless/core/slp_transfer.o] Error 1&lt;/pre&gt;Looking at that error the 31 hints at that the save registers code for PPC is trying to save register r31. This is reminiscent of the error you get when &lt;a href="http://kedeligdata.blogspot.com/2009/03/building-stackless-python-on-mac.html"&gt;compiling Stackless under Mac OS X&lt;/a&gt;, but in this case adding the --enable-stacklessfewerregisters option does not work.&lt;br /&gt;&lt;br /&gt;[1]: A surrogate in a cyber foraging system is a strong machine that performs heavy work on behalf of the weaker (often mobile) clients.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-3434431462113170400?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/3434431462113170400/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/12/building-stackless-python-on-ps3-ppc.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3434431462113170400'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3434431462113170400'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/12/building-stackless-python-on-ps3-ppc.html' title='Building Stackless Python on a PS3 (PPC Linux)'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-3943183626159296016</id><published>2009-12-14T12:42:00.002+01:00</published><updated>2009-12-14T12:43:26.795+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='presence'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>New Presence2 Beta</title><content type='html'>I have just released the fourth Presence2 beta. In it I have fixed some serious bugs, so if you are using the older betas please upgrade now ;-)&lt;br /&gt;&lt;br /&gt;Grab the files from the &lt;a href="http://code.google.com/p/presence-discovery/"&gt;usual place&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-3943183626159296016?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/3943183626159296016/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/12/new-presence2-beta.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3943183626159296016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3943183626159296016'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/12/new-presence2-beta.html' title='New Presence2 Beta'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-4530468173626210085</id><published>2009-11-27T13:01:00.003+01:00</published><updated>2009-11-27T13:05:35.178+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='eclipse'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Binding keyboard shortcuts to Subclipse commands in Eclipse</title><content type='html'>I have just created a small screencast about how to bind keyboard shortcuts to Subclipse commands within Eclipse. Now I can add, commit, and diff files without having to use my mouse - and I'm using the same Emacs shortcuts that I know and love :-)&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/pfY2Jpc4LLs&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;embed src="http://www.youtube.com/v/pfY2Jpc4LLs&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" height="344" width="425"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;B.t.w., it is cool how products like &lt;a href="http://www.shinywhitebox.com/ishowuhd/main.html"&gt;iShowU HD&lt;/a&gt; makes it incredibly easy to create screencasts. I've probably spent more time writing this blog entry than actually creating and uploading the video ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-4530468173626210085?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/4530468173626210085/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/11/binding-keyboard-shortcuts-to-subclipse.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/4530468173626210085'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/4530468173626210085'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/11/binding-keyboard-shortcuts-to-subclipse.html' title='Binding keyboard shortcuts to Subclipse commands in Eclipse'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-1150043095261277821</id><published>2009-11-24T09:41:00.003+01:00</published><updated>2009-11-24T09:42:44.861+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='presence'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Presence2 beta 2 released</title><content type='html'>I found some bugs in the Python lib for the new version of Presence. These have now been fixed and therefore a second beta has been released. Grab it at the &lt;a href="http://code.google.com/p/presence-discovery/"&gt;Presence Google Code&lt;/a&gt; page.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-1150043095261277821?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/1150043095261277821/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/11/presence2-beta-2-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1150043095261277821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1150043095261277821'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/11/presence2-beta-2-released.html' title='Presence2 beta 2 released'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-3949013105899483719</id><published>2009-11-20T09:50:00.005+01:00</published><updated>2009-11-20T10:18:05.944+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='eclipse'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>TeXlipse build that actually works...</title><content type='html'>I am currently writing an article - which under normal circumstances means that I am working in Emacs (&lt;a href="http://aquamacs.org/"&gt;Aquamacs&lt;/a&gt; f.t.w.!) using &lt;a href="http://www.gnu.org/software/auctex/"&gt;AUCTeX&lt;/a&gt;, &lt;a href="http://www.gnu.org/software/auctex/reftex.html"&gt;RefTeX&lt;/a&gt;, &lt;a href="http://www-sop.inria.fr/members/Manuel.Serrano/flyspell/flyspell.html"&gt;flyspell&lt;/a&gt; etc. But this time around I wanted to try something new, so I installed the &lt;a href="http://texlipse.sourceforge.net/"&gt;TeXlipse&lt;/a&gt; plugin for &lt;a href="http://eclipse.org/"&gt;Eclipse&lt;/a&gt; and started writing.&lt;br /&gt;&lt;br /&gt;I quickly faced a major problem though: If you, like any sane person, split up your document into smaller files and then \include or \input these files in some master file, then the auto completion of BiBTeX references does not work in TeXlipse. This is a known bug - it has been known for almost six months, and yet they haven't released a bugfix release!&lt;br /&gt;&lt;br /&gt;I have therefore built TeXlipse from CVS instead, and that seems to be working so far. You can &lt;a href="http://www.daimi.au.dk/%7Emadsk/files/net.sourceforge.texlipse_1.3.0.jar"&gt;fetch this build here&lt;/a&gt;. It was built using the CVS head as of today...&lt;br /&gt;&lt;br /&gt;Note: This build may have other bugs - it is _just_ a build of the TeXlipse CVS head.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-3949013105899483719?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/3949013105899483719/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/11/texlipse-build-that-actually-works.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3949013105899483719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3949013105899483719'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/11/texlipse-build-that-actually-works.html' title='TeXlipse build that actually works...'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-9176135313775171967</id><published>2009-11-06T14:38:00.003+01:00</published><updated>2009-11-06T14:42:37.193+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='presence'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Presence 2.0.0-b1 Released</title><content type='html'>I have just released the first beta of Presence2 (or qPresence as I also call it because of its Qt dependencies). I have &lt;a href="http://code.google.com/p/presence-discovery/downloads/list"&gt;put up downloadables&lt;/a&gt; for the daemon, the Python API, and the "daemonless" Python API (the one that allows for listening in on Presence announcements without running the Presence daemon).&lt;br /&gt;&lt;br /&gt;Because of the new Qt dependencies you need to install the Qt library and SDK in order to build the daemon. You can fetch these &lt;a href="http://qt.nokia.com/downloads"&gt;at Nokia's Qt page&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Grab 'em while they're hot!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-9176135313775171967?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/9176135313775171967/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/11/presence-200-b1-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/9176135313775171967'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/9176135313775171967'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/11/presence-200-b1-released.html' title='Presence 2.0.0-b1 Released'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-2469808686888259540</id><published>2009-11-05T08:23:00.003+01:00</published><updated>2009-11-05T08:44:35.878+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='qt'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Byte Order Conversion in Qt</title><content type='html'>For my recent &lt;a href="http://kedeligdata.blogspot.com/2009/11/complete-rebuild-of-presence.html"&gt;re-writing of Presence to use the Qt library&lt;/a&gt;, I needed to be able to do byte order swapping on two and four byte integers (short and int). This I used when serializing/marshalling/packing stuff up before transmitting them over the wire. I know that the "right" way of doing that in Qt would be to use &lt;a href="http://doc.trolltech.com/4.5/qdatastream.html"&gt;QDataStream&lt;/a&gt;, which will then handle stuff like byte order conversion, but I needed to be able to pack my own data, so that a QDataStream-capable reader was not required on the other side of the socket connection.&lt;br /&gt;&lt;br /&gt;Byte order conversion is done using the four functions (macros really) called htons, ntohs, htonl, and ntohl that may be found in inet/arpa.h on any Unix system. So of course I included that file and went happily on with my coding. But... when I tried to compile my new version of Presence under Windows I realized that inet/arpa.h does not exist on Windows. It probably resides in winsock.h I guess, but I _really_ do not want to have platform specific code in my project, so I decided to implement them myself instead :-)&lt;br /&gt;&lt;br /&gt;Using Qt you can ask for your systems endianness by using the &lt;a href="http://doc.trolltech.com/4.5/qsysinfo.html"&gt;QSysInfo&lt;/a&gt; class, so a portable implementation of the needed functions is easy to do:&lt;pre&gt;#define BYTE_SWAP4(x) \&lt;br /&gt;    (((x &amp;amp; 0xFF000000) &gt;&gt; 24) | \&lt;br /&gt;     ((x &amp;amp; 0x00FF0000) &gt;&gt; 8)  | \&lt;br /&gt;     ((x &amp;amp; 0x0000FF00) &lt;&lt; 8)  | \&lt;br /&gt;     ((x &amp;amp; 0x000000FF) &lt;&lt; 24))&lt;br /&gt;&lt;br /&gt;#define BYTE_SWAP2(x) \&lt;br /&gt;    (((x &amp;amp; 0xFF00) &gt;&gt; 8) | \&lt;br /&gt;     ((x &amp;amp; 0x00FF) &lt;&lt; 8))&lt;br /&gt;&lt;br /&gt;quint16 _htons(quint16 x) {&lt;br /&gt;    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {&lt;br /&gt;        return x;&lt;br /&gt;    }&lt;br /&gt;    else {&lt;br /&gt;        return BYTE_SWAP2(x);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;quint16 _ntohs(quint16 x) {&lt;br /&gt;    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {&lt;br /&gt;        return x;&lt;br /&gt;    }&lt;br /&gt;    else {&lt;br /&gt;        return BYTE_SWAP2(x);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;quint32 _htonl(quint32 x) {&lt;br /&gt;    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {&lt;br /&gt;        return x;&lt;br /&gt;    }&lt;br /&gt;    else {&lt;br /&gt;        return BYTE_SWAP4(x);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;quint32 _ntohl(quint32 x) {&lt;br /&gt;    if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {&lt;br /&gt;        return x;&lt;br /&gt;    }&lt;br /&gt;    else {&lt;br /&gt;        return BYTE_SWAP4(x);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note that the functions have a '_' prepended - otherwise some compilers may get confused.&lt;br /&gt;&lt;br /&gt;Using these functions I do not need to have any platform specific code in my project. This comes at the cost of actually doing a function call when byte order conversion is needed, as opposed to simply using a macro. So if your code is &lt;span style="font-style: italic;"&gt;very&lt;/span&gt; performance critical you should not use this code - but then again, if your code is that performance critical you should probably not be using C++ ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-2469808686888259540?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/2469808686888259540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/11/byte-order-conversion-in-qt.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/2469808686888259540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/2469808686888259540'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/11/byte-order-conversion-in-qt.html' title='Byte Order Conversion in Qt'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-622704369458238039</id><published>2009-11-04T13:34:00.002+01:00</published><updated>2009-11-04T14:18:08.096+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='presence'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='qt'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>Complete rebuild of Presence</title><content type='html'>I have spent the past week re-writing &lt;a href="http://code.google.com/p/presence-discovery/"&gt;Presence&lt;/a&gt; from scratch using &lt;a href="http://qt.nokia.com/"&gt;Qt&lt;/a&gt;. "Why?" you may ask. The previous version of Presence has been working very well for a long time, but it had a bug that only appeared on 64-bit operating systems. I spent a small amount of time debugging the old code base to find that bug, and then finally decided that a complete re-write would be better. Not that the old code base was that horrible, it was just written in a mixture of C and C++ that made it a bit hard to maintain. E.g., the network related code was written in pure C using a large select() statement and multiplexing over a large number of sockets - it seems obvious that this could be coded _much_ nicer using an event based architecture.&lt;br /&gt;&lt;br /&gt;So I decided to recode it in Qt, and let me tell you: Qt = happiness! I am no fan of C++, but when using Qt it is actually a nice language to work with. The new version of Presence is easily maintainable, because it is so simple to read and understand Qt code (at least compared to reading and understanding C). No more waiting for data on a bunch of sockets, finding out which socket has activity, forwarding the task of handling the activity to someone else, and then back to the listening... In Qt all socket activity can of course be subscribed to as callbacks, so now the Announcer class takes care of all announcement packets, the ControlConnection class talks to application(s), and so forth.&lt;br /&gt;&lt;br /&gt;In the process of porting the daemon I have altered the protocol slightly, which means that I also had to update the Python libraries. In doing this these have also been redesigned, making them a bit easier to read as well. They both work now, though I must admit that I am not completely satisfied with the main Python lib - but seeing as it works I will probably not get to updating it any time soon.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-622704369458238039?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/622704369458238039/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/11/complete-rebuild-of-presence.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/622704369458238039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/622704369458238039'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/11/complete-rebuild-of-presence.html' title='Complete rebuild of Presence'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-8408342017691114183</id><published>2009-09-28T09:37:00.004+02:00</published><updated>2009-09-28T09:45:46.784+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Controlling PDF Minor Version in LaTeX</title><content type='html'>I just had to submit a paper to a conference that was using some web based submission system. As part of that system, the PDF version of the paper I submitted was validated. The system refused my paper because it was seemingly a version 1.4 PDF (w.t.f. do I know about PDF versions?). I spent some time trying to update my LaTeX installation on my Mac (didn't work), compiling the paper on my university's Linux machines (also didn't work), and then I hit Google...&lt;br /&gt;&lt;br /&gt;It seems that you can control the PDF minor version by using this magical LaTeX command&lt;pre&gt;\pdfminorversion=5&lt;/pre&gt;This will make pdflatex create a version 1.5 PDF document (you can also create version 1.6 and 1.7 PDFs, but 1.5 was all I needed).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-8408342017691114183?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/8408342017691114183/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/09/controlling-pdf-minor-version-in-latex.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8408342017691114183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8408342017691114183'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/09/controlling-pdf-minor-version-in-latex.html' title='Controlling PDF Minor Version in LaTeX'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-8392647503856908340</id><published>2009-09-18T21:46:00.003+02:00</published><updated>2009-09-18T21:52:49.396+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gtk'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Native Mac PyGTK for Snow Leopard</title><content type='html'>I have just made a fresh build of native PyGTK for Mac on my new Snow Leopard install. It seems to be working - I have only tested my simple hello_pygtk.py script, and that works at least ;-)&lt;br /&gt;&lt;br /&gt;You can grab the new build here: &lt;a href="http://www.daimi.au.dk/%7Emadsk/files/MacPyGTK_SnowLeopard_091809.dmg"&gt;MacPyGTK_SnowLeopard_091809.dmg&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Remember to follow the three simple instructions in README.txt in order to make it work. B.t.w., one has to be running Python in 32-bit mode for it to work. This can be done in two ways:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;By setting this environment variable VERSIONER_PYTHON_PREFER_32_BIT=yes &lt;/li&gt;&lt;li&gt;By issuing this command (once): defaults write com.apple.versioner.python Prefer-32-Bit -bool yes&lt;/li&gt;&lt;/ol&gt;I would prefer setting the environment variable in a script starting my PyGTK application. That way I am changing as little as possible in the standard setup of the machine...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-8392647503856908340?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/8392647503856908340/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/09/native-mac-pygtk-for-snow-leopard.html#comment-form' title='18 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8392647503856908340'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8392647503856908340'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/09/native-mac-pygtk-for-snow-leopard.html' title='Native Mac PyGTK for Snow Leopard'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>18</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-1143343804413473890</id><published>2009-09-17T20:52:00.002+02:00</published><updated>2009-09-17T21:06:08.722+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><category scheme='http://www.blogger.com/atom/ns#' term='terminal'/><title type='text'>Piping output of shell commands into the clipboard</title><content type='html'>I love my terminal! The availability of a proper shell and set of *nix tools is one of the main reasons that I dared switch to Mac OS X two years ago. I have been used to having the full GNU tool chain on the Linux systems I have been using the last 10 years, and there is no way I will ever give that up :-)&lt;br /&gt;&lt;br /&gt;Today I learned something new about my terminal on OS X; I learned about the &lt;span style="font-style: italic;"&gt;pbcopy&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;pbpaste&lt;/span&gt; commands. These two shell commands copy shell output into the clipboard, and pastes the clipboard content into the shell, respectively. I.e., today I needed to grep+cut through some large log files, and the results of these commands I wanted to paste to a spreadsheet. Instead of having to 1) perform the command, and then 2) use the mouse to scroll up and select all of the results to copy-paste them into the spreadsheet, I found that I could use &lt;span style="font-style: italic;"&gt;pbcopy&lt;/span&gt; to pipe stdout directly to the clipboard:&lt;pre&gt;grep foo logfile.txt | cut -d " " -f1,2,4 | pbcopy&lt;/pre&gt;After running this I could just go to my spreadsheet application and insert the three selected rows.&lt;br /&gt;&lt;br /&gt;This little command is a real time saver I can tell you! I must have saved at least an hours work today alone ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-1143343804413473890?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/1143343804413473890/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/09/piping-output-of-shell-commands-into.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1143343804413473890'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1143343804413473890'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/09/piping-output-of-shell-commands-into.html' title='Piping output of shell commands into the clipboard'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-244817516234630090</id><published>2009-09-13T20:00:00.002+02:00</published><updated>2009-09-13T20:07:51.927+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gtk'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Fresh PyGTK build for Leopard/Intel</title><content type='html'>I have just built a fresh version of native Mac OS X PyGTK and all of its dependencies. This time I have only made an Intel build for Leopard, so no PPC version this time around.&lt;br /&gt;&lt;br /&gt;You can grab the new dmg file here: &lt;a href="http://www.cs.au.dk/%7Emadsk/files/MacPyGTK_Leopard_Intel_091309.dmg"&gt;MacPyGTK_Leopard_Intel_091309.dmg&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The install procedure is the usual:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Download and mount the dmg&lt;/li&gt;&lt;li&gt;Drag the MacPyGTK folder to /Developer&lt;/li&gt;&lt;li&gt;Copy the contents of site-packages into the site packages of your Python installation (on 10.5 this should be /Library/Python/2.5/site-packages)&lt;/li&gt;&lt;li&gt;Test that it works by running the hello_pygtk.py file with your Python interpreter.&lt;/li&gt;&lt;/ol&gt;That's it - now you should have a fully functional PyGTK installation to play around with.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-244817516234630090?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/244817516234630090/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/09/fresh-pygtk-build-for-leopardintel.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/244817516234630090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/244817516234630090'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/09/fresh-pygtk-build-for-leopardintel.html' title='Fresh PyGTK build for Leopard/Intel'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-3960533284782171911</id><published>2009-07-21T08:41:00.005+02:00</published><updated>2009-07-21T08:48:35.302+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='locusts'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>New Logo for Locusts?</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_BH8Ue1jc5vM/SmVjpXG1I-I/AAAAAAAAA1c/yKMzFhmql_I/s1600-h/grasshopper-300.jpg"&gt;&lt;img style="border: 0px; margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 300px; height: 193px;" src="http://2.bp.blogspot.com/_BH8Ue1jc5vM/SmVjpXG1I-I/AAAAAAAAA1c/yKMzFhmql_I/s320/grasshopper-300.jpg" alt="" id="BLOGGER_PHOTO_ID_5360800493682893794" border="0" /&gt;&lt;/a&gt;I have for some time now been searching for a nice picture of a grasshopper to use as a logo for the Locusts project that I am working on. I never found one that I was satisfied with though, but yesterday I got lucky. While I was out walking in Lappeenranta this little fellow was sitting on the side of the road - and he really liked being photographed.&lt;br /&gt;&lt;br /&gt;B.t.w., I edited this image using &lt;a href="http://www.pixelmator.com/"&gt;Pixelmator&lt;/a&gt; to remove the background. This little app is really turning out to be an excellent image editor - who needs Photoshop anyway? :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-3960533284782171911?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/3960533284782171911/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/new-logo-for-locusts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3960533284782171911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3960533284782171911'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/new-logo-for-locusts.html' title='New Logo for Locusts?'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_BH8Ue1jc5vM/SmVjpXG1I-I/AAAAAAAAA1c/yKMzFhmql_I/s72-c/grasshopper-300.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-8540266805298629258</id><published>2009-07-17T12:43:00.002+02:00</published><updated>2009-07-17T12:46:53.492+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scavenger'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Excited about Scavenger...</title><content type='html'>Just wanted to let you know that I have &lt;a href="http://www.daimi.au.dk/%7Emadsk/?p=98"&gt;posted something about Scavenger&lt;/a&gt; on my &lt;a href="http://www.daimi.au.dk/%7Emadsk/"&gt;"work" blog&lt;/a&gt;. I have conducted some benchmarks of Scavengers parallel processing abilities and it is looking very promising I must say.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-8540266805298629258?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/8540266805298629258/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/excited-about-scavenger.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8540266805298629258'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8540266805298629258'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/excited-about-scavenger.html' title='Excited about Scavenger...'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-5881316371693243028</id><published>2009-07-15T08:58:00.009+02:00</published><updated>2009-07-15T10:12:05.779+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Making your OS X hostname stick</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_BH8Ue1jc5vM/Sl2B9sxAk8I/AAAAAAAAA1U/mhqvLEbgNzI/s1600-h/utilities-terminal.png"&gt;&lt;img style="border: 0pt none ; margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="http://2.bp.blogspot.com/_BH8Ue1jc5vM/Sl2B9sxAk8I/AAAAAAAAA1U/mhqvLEbgNzI/s320/utilities-terminal.png" alt="" id="BLOGGER_PHOTO_ID_5358582028629480386" border="0" /&gt;&lt;/a&gt;If you are both a Mac user and a terminal junkie, as I am, you will probably have noticed that your computers hostname changes whenever you enter a new network environment[1]. More precisely, when you join a network through a DHCP server in some cases it also assigns you a new hostname. This has been a major annoyance to me for some time now, so I finally decided to find out how to make my hostname stick. And, as it turns out, that is of course quite simple to do:&lt;br /&gt;&lt;br /&gt;1) Issue the command "sudo vi /etc/hostconfig"&lt;br /&gt;2) Add the line HOSTNAME=my-hostname to this file (pressing i to enter edit mode).&lt;br /&gt;3) Save and close (that's Esc &lt;esc&gt; &lt;esc&gt; to quit editing mode, and then :wq + Enter &lt;enter&gt;&lt;enter&gt;for you vi rookies)&lt;br /&gt;&lt;br /&gt;The HOSTNAME line may already exist on your system in which case its value will be "-AUTOMATIC-". In that case you just replace that with your hostname. It was not there on my Leopard (client) machine.&lt;br /&gt;&lt;br /&gt;Oh yeah, thanks to Robert Brewer for &lt;a href="http://excitedcuriosity.wordpress.com/2007/08/24/mac-os-x-hostname-determination/"&gt;teaching me how to do this&lt;/a&gt;. Take a look at his article if you are interested in getting some more detailed information about the whole hostname determination business on OS X.&lt;br /&gt;&lt;br /&gt;[1]: For those of you not used to using a terminal a new command-line in a terminal typically starts with "username@hostname:top-level-path$". E.g., my prompt right now shows "madsk@leela:Development$".&lt;/enter&gt;&lt;/enter&gt;&lt;/esc&gt;&lt;/esc&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-5881316371693243028?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/5881316371693243028/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/making-your-os-x-hostname-stick.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/5881316371693243028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/5881316371693243028'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/making-your-os-x-hostname-stick.html' title='Making your OS X hostname stick'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_BH8Ue1jc5vM/Sl2B9sxAk8I/AAAAAAAAA1U/mhqvLEbgNzI/s72-c/utilities-terminal.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-4381331504159588618</id><published>2009-07-13T18:41:00.002+02:00</published><updated>2009-07-13T18:44:37.831+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='scavenger'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Scavenger tutorial available</title><content type='html'>I have finally gotten around to writing some documentation of Scavenger, so that others may in fact start writing Scavenger-enabled applications. I have spent the entire day updating the wiki pages of &lt;a href="http://code.google.com/p/scavenger-cf/"&gt;Scavengers GoogleCode homepage&lt;/a&gt; so now you will find a &lt;a href="http://code.google.com/p/scavenger-cf/wiki/Tutorial"&gt;tutorial&lt;/a&gt; there along with some other related information about scavenger. Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-4381331504159588618?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/4381331504159588618/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/scavenger-tutorial-available.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/4381331504159588618'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/4381331504159588618'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/scavenger-tutorial-available.html' title='Scavenger tutorial available'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-1187795782940457633</id><published>2009-07-10T10:08:00.002+02:00</published><updated>2009-07-10T10:27:33.306+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>Python in the Android Emulator</title><content type='html'>I have recently started playing around with the Android platform; more specifically I have begun experimenting with Python development on Android through the &lt;a href="http://code.google.com/p/android-scripting/"&gt;Android Scripting Environment&lt;/a&gt; (or ASE, as its called).&lt;br /&gt;&lt;br /&gt;In ASE you are able to run Python 2.6.2 scripts that, as far as I can tell so far, have full access to the underlying Python libraries. Furthermore, through the "android" module, you gain access to some Android specific things like location services, sensor data, sms messaging, and more.&lt;br /&gt;&lt;br /&gt;One problem with ASE though is the fact that it is impossible to run a Python program within the &lt;a href="http://developer.android.com/guide/developing/tools/emulator.html"&gt;Android Emulator&lt;/a&gt;. When you try to start a Python script all you get is a black screen. This is due to some &lt;a href="http://code.google.com/p/android/issues/detail?id=2566"&gt;sensor-thingy not being available&lt;/a&gt; in the emulator, and the &lt;a href="http://code.google.com/p/android-scripting/issues/detail?id=45"&gt;suggested fix&lt;/a&gt; is to rebuild ASE with the sensor service disabled.&lt;br /&gt;&lt;br /&gt;To spare others of the &lt;a href="http://code.google.com/p/android-scripting/wiki/CompilingASE"&gt;pain involved&lt;/a&gt; rebuilding ASE from source (it is really not that hard, just takes some valuable time away from coding in Python), I will share my build of ASE that actually works in the emulator. You can download it here: &lt;a href="http://www.daimi.au.dk/~madsk/files/ScriptManager.apk"&gt;ASE Emulator build (do not use this on a real device!)&lt;/a&gt;. This build is provided as is; I will not be held liable if it blows up your computer, burns down your house, or runs away with your wife ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-1187795782940457633?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/1187795782940457633/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/python-in-android-emulator.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1187795782940457633'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1187795782940457633'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/python-in-android-emulator.html' title='Python in the Android Emulator'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-8192934627309184647</id><published>2009-07-07T15:30:00.006+02:00</published><updated>2009-07-07T15:48:17.972+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='scavenger'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><category scheme='http://www.blogger.com/atom/ns#' term='maemo'/><title type='text'>Scavenger demo application released!</title><content type='html'>I have just released the first Scavenger demo app: &lt;a href="http://scavenger-cf.googlecode.com/files/augim_0.2.0-1_all.deb"&gt;AugIM - the Augmented Image Manager&lt;/a&gt;. AugIM is an old demonstrator that I made a long time ago, and now I have ported it to use Scavenger for its cyber foraging tasks.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_BH8Ue1jc5vM/SlNPLS6CpvI/AAAAAAAAAzU/lwagk2rP8nA/s1600-h/screenshot01.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 192px;" src="http://1.bp.blogspot.com/_BH8Ue1jc5vM/SlNPLS6CpvI/AAAAAAAAAzU/lwagk2rP8nA/s320/screenshot01.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5355711437346088690" /&gt;&lt;/a&gt;&lt;br /&gt;AugIM is an image browser/editor for &lt;a href="http://maemo.org/"&gt;Maemo&lt;/a&gt; (running on Nokia's N800/N810 devices) that allows you to do simple image manipulation tasks such as sharpening, resizing, adjusting color/contrast/brightness, rotating, flipping etc. It also allows you to share your images with the world through email or &lt;a href="http://picasaweb.google.com/"&gt;Google Picasa Web&lt;/a&gt;. The N800 and N810 devices &lt;span style="font-style:italic;"&gt;are&lt;/span&gt; capable of performing these services on their own, but it takes a long time for them to do so and it consumes a very large amount of energy. Using Scavenger, AugIM makes sure that heavy processing is offloaded to larger surrogates whenever possible, which means that the image manipulation tasks are performed faster and using less energy on the mobile device.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-8192934627309184647?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/8192934627309184647/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/scavenger-demo-application-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8192934627309184647'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8192934627309184647'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/scavenger-demo-application-released.html' title='Scavenger demo application released!'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_BH8Ue1jc5vM/SlNPLS6CpvI/AAAAAAAAAzU/lwagk2rP8nA/s72-c/screenshot01.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-1048308786886251427</id><published>2009-07-07T15:21:00.003+02:00</published><updated>2009-07-07T15:30:09.751+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='scavenger'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Yet another Scavenger build...</title><content type='html'>I have just uploaded a new self-contained Scavenger daemon build to &lt;a href="http://code.google.com/p/scavenger-cf/"&gt;Scavengers Google Code page&lt;/a&gt;. This build is for Mac OS X 10.5 (Leopard) and it contains the same components as the Ubuntu Linux version &lt;a href="http://kedeligdata.blogspot.com/2009/07/scavenger-build-available-for-ubuntu.html"&gt;I released yesterday&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;From your Mac simply download the archive, unpack it, and start the start_daemon script from a terminal. Then a Scavenger daemon should be running on your machine, and you are ready to start playing with cyber foraging! :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-1048308786886251427?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/1048308786886251427/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/yet-another-scavenger-build.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1048308786886251427'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1048308786886251427'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/yet-another-scavenger-build.html' title='Yet another Scavenger build...'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-2016195442918494740</id><published>2009-07-06T14:06:00.003+02:00</published><updated>2009-07-07T14:29:20.777+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='scavenger'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Scavenger build available for Ubuntu 9.04</title><content type='html'>I have finally gotten around to creating a &lt;a href="http://code.google.com/p/scavenger-cf/"&gt;Scavenger&lt;/a&gt; build that you can use to easily experiment with Scavenger, without having to install &lt;a href="http://stackless.com/"&gt;Stackless Python&lt;/a&gt; and other dependencies (e.g., &lt;a href="http://code.google.com/p/presence-discovery/"&gt;Presence&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;The build, which is created and tested to run on Ubuntu 9.04, is &lt;a href="http://scavenger-cf.googlecode.com/files/scavenger-build-ubuntu904.tar.bz2"&gt;available here&lt;/a&gt;. All you need to do is 1) download the archive, 2) unpack it, and 3) run the "start_daemon" script.&lt;br /&gt;&lt;br /&gt;The "bundle" contains Stackless Python 2.6.2, the Presence python lib and daemon, PIL (Python Imaging Library), Google Data API, and the Scavenger daemon.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-2016195442918494740?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/2016195442918494740/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/scavenger-build-available-for-ubuntu.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/2016195442918494740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/2016195442918494740'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/07/scavenger-build-available-for-ubuntu.html' title='Scavenger build available for Ubuntu 9.04'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-1169286997999961644</id><published>2009-06-30T23:26:00.003+02:00</published><updated>2009-06-30T23:29:37.158+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='photo'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><category scheme='http://www.blogger.com/atom/ns#' term='chdk'/><title type='text'>Timelapse photography using CHDK</title><content type='html'>I thought it could be fun to do some &lt;a href="http://en.wikipedia.org/wiki/Time-lapse"&gt;time-lapse&lt;/a&gt; photography now that I have a programmable camera. So I have quickly whipped up a small time-lapse script that works on my Ixus 750:&lt;br /&gt;&lt;pre&gt;@title Timelapse&lt;br /&gt;@param a Number of steps &lt;br /&gt;@default a 30&lt;br /&gt;@param b Period (seconds)&lt;br /&gt;@default b 60&lt;br /&gt;&lt;br /&gt;rem Sanity check.&lt;br /&gt;if a&lt;1 then let a=1&lt;br /&gt;if b&lt;5 then let b=5&lt;br /&gt;let b=b*1000&lt;br /&gt;&lt;br /&gt;rem Take the pictures!&lt;br /&gt;for s=1 to a+1&lt;br /&gt;    rem Take a single picture.&lt;br /&gt;    print "Shoot", s, "of", a&lt;br /&gt;    press "shoot_half"&lt;br /&gt;    sleep 2500&lt;br /&gt;    press "shoot_full"&lt;br /&gt;    release "shoot_full"&lt;br /&gt;    release "shoot_half"&lt;br /&gt;    print "shot done"&lt;br /&gt;&lt;br /&gt;    rem Sleep until its time to take the next picture.&lt;br /&gt;    sleep b&lt;br /&gt;next s&lt;/pre&gt;&lt;br /&gt;At the standard setting it takes thirty pictures in roughly 30 minutes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-1169286997999961644?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/1169286997999961644/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/06/timelapse-photography-using-chdk.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1169286997999961644'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1169286997999961644'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/06/timelapse-photography-using-chdk.html' title='Timelapse photography using CHDK'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-3075899078516083068</id><published>2009-06-30T23:22:00.004+02:00</published><updated>2009-06-30T23:25:30.605+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='photo'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><category scheme='http://www.blogger.com/atom/ns#' term='chdk'/><title type='text'>CHDK oddities</title><content type='html'>The script I posted in my last post, the one that does exposure bracketing, used to work - I swear it did! But all of a sudden it decided to stop working, and I can't find an good explanation for that at all ;-)&lt;br /&gt;&lt;br /&gt;But, instead of an explanation i offer you a fix. The following script _does_ work on my Ixus 750 camera (right now it does anyway):&lt;br /&gt;&lt;pre&gt;@title EXP bracketing &lt;br /&gt;@param a Number of +/- steps &lt;br /&gt;@default a 2&lt;br /&gt;@param b Step size (1/3EV)&lt;br /&gt;@default b 3&lt;br /&gt;&lt;br /&gt;if a&lt;1 then let a=2&lt;br /&gt;if b&lt;1 then let b=3&lt;br /&gt;&lt;br /&gt;print "Preparing..."&lt;br /&gt;for n=1 to a*b&lt;br /&gt;    click "left"&lt;br /&gt;next n&lt;br /&gt;&lt;br /&gt;for s=1 to a*2&lt;br /&gt;    print "Shoot", s, "of", a*2+1&lt;br /&gt;    press "shoot_half"&lt;br /&gt;    sleep 2500&lt;br /&gt;    press "shoot_full"&lt;br /&gt;    release "shoot_full"&lt;br /&gt;    release "shoot_half"&lt;br /&gt;    print "shot done"&lt;br /&gt;    sleep 5000&lt;br /&gt;    for n=1 to b&lt;br /&gt;        click "right"&lt;br /&gt;    next n&lt;br /&gt;next s&lt;br /&gt;&lt;br /&gt;print "Shoot", a*2+1, "of", a*2+1&lt;br /&gt;press "shoot_half"&lt;br /&gt;sleep 2500&lt;br /&gt;press "shoot_full"&lt;br /&gt;release "shoot_full"&lt;br /&gt;release "shoot_half"&lt;br /&gt;sleep 5000&lt;br /&gt;&lt;br /&gt;print "Finalizing..."&lt;br /&gt;for n=1 to a*b&lt;br /&gt;    click "left"&lt;br /&gt;next n&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-3075899078516083068?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/3075899078516083068/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/06/chdk-oddities.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3075899078516083068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3075899078516083068'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/06/chdk-oddities.html' title='CHDK oddities'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-7971863632969279182</id><published>2009-06-09T13:52:00.009+02:00</published><updated>2009-06-30T21:14:52.969+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='photo'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><category scheme='http://www.blogger.com/atom/ns#' term='chdk'/><title type='text'>CHDK on an Ixus 750</title><content type='html'>While on paternity leave I have been &lt;a href="http://www.flickr.com/photos/38968343@N06/"&gt;playing around with&lt;/a&gt; my Canon Ixus 750 digital camera. Primarily I have been doing macro (close-up) shots of insects etc., but I also wanted to experiment with other kinds of photography, e.g., High Dynamic Range images (&lt;a href="http://en.wikipedia.org/wiki/High_dynamic_range_imaging"&gt;HDR&lt;/a&gt;). In HDR you take pictures of the same scene at different exposure levels, and after that a computer program stacks these images to create the HDR image. When taking such pictures it is &lt;span style="font-style:italic;"&gt;vital&lt;/span&gt; that you do not move the camera, which can be quite hard even if you have a stand for it. I was therefore looking for a software solution to HDR, that would automatically take 3 to 5 pictures at different exposure levels for me, so that Idid not need to touch the camera in between shots.&lt;br /&gt;&lt;br /&gt;For that I installed &lt;a href="http://chdk.wikia.com/wiki/CHDK"&gt;CHDK&lt;/a&gt; on my Ixus 750 and I must say that I am impressed. Using the CHDK firmware extension a horde of new features are unlocked (for example the possibility to take RAW images instead of JPEGs). And most importantly CHDK is scriptable, so you may write your own scripts to control your camera.&lt;br /&gt;&lt;br /&gt;Based on an example in the tutorial I quickly wrote an HDR script that works on an Ixus 750. When I activate this script my camera snaps five pictures at -2, 1, 0, +1, +2 exposure.&lt;pre&gt;@title EXP bracketing &lt;br /&gt;@param a Number of +/- steps &lt;br /&gt;@default a 2&lt;br /&gt;@param b Step size (1/3EV)&lt;br /&gt;@default b 3&lt;br /&gt;&lt;br /&gt;if a&lt;1 then let a=2&lt;br /&gt;if b&lt;1 then let b=3&lt;br /&gt;&lt;br /&gt;sleep 1000&lt;br /&gt;&lt;br /&gt;print "Preparing..."&lt;br /&gt;rem click "erase"&lt;br /&gt;for n=1 to a*b&lt;br /&gt;    click "left"&lt;br /&gt;next n&lt;br /&gt;&lt;br /&gt;click "shoot_half"&lt;br /&gt;sleep 3000&lt;br /&gt;for s=1 to a*2&lt;br /&gt;    print "Shoot", s, "of", a*2+1&lt;br /&gt;    click "shoot_full"&lt;br /&gt;    print "shot done"&lt;br /&gt;    sleep 5000&lt;br /&gt;    for n=1 to b&lt;br /&gt;        click "right"&lt;br /&gt;    next n&lt;br /&gt;next s&lt;br /&gt;&lt;br /&gt;print "Shoot", a*2+1, "of", a*2+1&lt;br /&gt;click "shoot_full"&lt;br /&gt;sleep 5000&lt;br /&gt;&lt;br /&gt;print "Finalizing..."&lt;br /&gt;for n=1 to a*b&lt;br /&gt;    click "left"&lt;br /&gt;next n&lt;br /&gt;rem click "erase"&lt;br /&gt;&lt;br /&gt;end&lt;/pre&gt;&lt;br /&gt;In order to use this script the camera must be in manual mode and the exposure menu must be opened...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-7971863632969279182?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/7971863632969279182/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/06/chdk-on-ixus-750.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/7971863632969279182'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/7971863632969279182'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/06/chdk-on-ixus-750.html' title='CHDK on an Ixus 750'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-8881189330221390381</id><published>2009-05-19T11:05:00.005+02:00</published><updated>2009-05-19T11:17:09.348+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Controlling the firewall on Mac OS X 10.4 (Tiger) from the command line</title><content type='html'>I have just had the need to control (actually disable) the firewall on a Mac running OS X 10.4 (Tiger). This should be no problem; just start System Preferences go to Sharing... The problem was that the only connection I had to the machine was through SSH, so going to System Preferences was not an option.&lt;br /&gt;&lt;br /&gt;Luckily the firewall can be controlled with the &lt;span style="font-style:italic;"&gt;ipfw&lt;/span&gt; command on the command line. Take a look at &lt;a href="http://www.macdevcenter.com/pub/a/mac/2005/03/15/firewall.html"&gt;this article at macdevcenter&lt;/a&gt; for an example of how to use ipfw.&lt;br /&gt;&lt;br /&gt;And, to disable the firewall all that is needed is thus:&lt;pre&gt;sudo ipfw disable firewall&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Update:&lt;/span&gt; To disable the firewall on Mac OS X 10.5 (Leopard) you can issue the following command:&lt;pre&gt;sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 0&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-8881189330221390381?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/8881189330221390381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/05/controlling-firewall-on-mac-os-x-104.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8881189330221390381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8881189330221390381'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/05/controlling-firewall-on-mac-os-x-104.html' title='Controlling the firewall on Mac OS X 10.4 (Tiger) from the command line'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-3775802789227399972</id><published>2009-04-29T16:17:00.002+02:00</published><updated>2009-04-29T16:24:29.582+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='scavenger'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Scavenger - Now With History Based Profiling</title><content type='html'>I have just added yet another scheduler to &lt;a href="http://code.google.com/p/scavenger-cf/"&gt;Scavenger&lt;/a&gt; (yes, there is three of them now). This scheduler is the "smartest" of the three as it uses history based profiling in order to be able to choose the right surrogate for the job. History based profiling in a cyber foraging system is nothing new - the Chroma system used that some 6-7 years ago. What is new is the &lt;span style="font-style:italic;"&gt;way&lt;/span&gt; that the profiling information is used within the Scavenger system. In Scavenger the profiling information can be used not only to tell you something about how the task will perform on certain surrogates (i.e., the ones where you have earlier performed the task), it is also capable of making an informed estimate of the running time on an unknown surrogate... more on that later ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-3775802789227399972?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/3775802789227399972/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/04/scavenger-now-with-history-based.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3775802789227399972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3775802789227399972'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/04/scavenger-now-with-history-based.html' title='Scavenger - Now With History Based Profiling'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-7536527526639505512</id><published>2009-04-27T07:13:00.006+02:00</published><updated>2009-04-27T08:07:01.584+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='iphone'/><title type='text'>Building the Python Imaging Library (PIL) for iPhone/iPod Touch</title><content type='html'>As my last post hints at I have started experimenting with building PIL for my iPod Touch. Doing so is non-trivial and I have therefore decided to write a small tutorial here, so that others may be spared of wasting &lt;span style="font-style: italic;"&gt;their&lt;/span&gt; time on this project ;-)&lt;br /&gt;&lt;br /&gt;What I did was to compile the thing directly on the iPod, and to do that I went through the following steps:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Jailbreak: I used QuickPWN 2.2.5 under Windows (it did not work on my Mac for some reason) and that was quite easy.&lt;/li&gt;&lt;li&gt;Install SSH on the iPod using Cydia (there is an entry in the main menu showing you how to do that).&lt;/li&gt;&lt;li&gt;SSH in to your iPod as the root user with password "alpine".&lt;/li&gt;&lt;li&gt;Install Python, the gcc compiler,  the code signing tool, and make by issuing this command: apt-get install python iphone-gcc ldid make (alternatively you could install it using Cydia it you like).&lt;/li&gt;&lt;li&gt;Download the SDK headers, you may find them along with a description of how to use them &lt;a href="http://antirez.com/page/iphone-gcc-guide.html"&gt;here&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;[Optional] Download the &lt;a href="http://www.ijg.org/files/jpegsrc.v6b.tar.gz"&gt;libjpeg source&lt;/a&gt; if you want jpeg support. Untar the source bundle, enter the directory containing the source and issue the following commands: &lt;pre&gt;export C_INCLUDE_PATH=/var/include/&lt;br /&gt;./configure --prefix=/usr/&lt;br /&gt;make&lt;br /&gt;make install&lt;br /&gt;make install-lib&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Download the &lt;a href="http://effbot.org/downloads/Imaging-1.1.6.tar.gz"&gt;PIL source&lt;/a&gt; and unpack it.&lt;/li&gt;&lt;li&gt;Enter the source directory and issue the following commands:&lt;pre&gt;python setup.py build&lt;br /&gt;python setup.py install&lt;br /&gt;ldid -S /usr/lib/python2.5/site-packages/PIL/*.dylib&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;After going through all of these steps I ended up with a working PIL library on my iPod. Oh, and thanks to Renaud Blanch for pointing out to me that I needed to sign the dynamic libraries for them to work.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-7536527526639505512?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/7536527526639505512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/04/building-python-imaging-library-pil-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/7536527526639505512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/7536527526639505512'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/04/building-python-imaging-library-pil-for.html' title='Building the Python Imaging Library (PIL) for iPhone/iPod Touch'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-7302910091555735221</id><published>2009-04-26T19:57:00.004+02:00</published><updated>2009-04-27T07:33:20.543+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='scavenger'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><category scheme='http://www.blogger.com/atom/ns#' term='iphone'/><title type='text'>Scavenger on iPhone/iPod Touch</title><content type='html'>The first thing I did after implementing the &lt;a href="http://kedeligdata.blogspot.com/2009/04/new-presence-consumer-lib.html"&gt;new Presence lib&lt;/a&gt; was of course to install &lt;a href="http://code.google.com/p/scavenger-cf/"&gt;Scavenger&lt;/a&gt; on my iPod Touch. And I am happy to report that it works! :-)&lt;br /&gt;&lt;br /&gt;The Python version installable on a jailbroken iPhone/iPod is version 2.5.1, and since Scavenger is developed using Python 2.6 in a "backwards compatible" way everything worked like a charm.&lt;br /&gt;&lt;br /&gt;The next step is getting the &lt;a href="http://www.pythonware.com/products/pil/"&gt;Python Imaging Library&lt;/a&gt; working on the iPod...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-7302910091555735221?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/7302910091555735221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/04/scavenger-on-iphoneipod-touch.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/7302910091555735221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/7302910091555735221'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/04/scavenger-on-iphoneipod-touch.html' title='Scavenger on iPhone/iPod Touch'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-3115433883943809684</id><published>2009-04-26T14:17:00.003+02:00</published><updated>2009-04-26T14:27:14.721+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='presence'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>New Presence Consumer Lib</title><content type='html'>I have just created a new &lt;a href="http://code.google.com/p/presence-discovery/"&gt;Presence&lt;/a&gt; library - one that does &lt;span style="font-style:italic;"&gt;not&lt;/span&gt; depend on the Presence daemon. This lib may be used by Python applications that only act as consumers of Presence services, i.e., application that do not advertise services through Presence but merely uses services announced by other peers.&lt;br /&gt;&lt;br /&gt;So why did I make this new consumer-only lib? Because it enables devices that are not capable of running the Presence daemon to use Presence anyway (as a client/consumer right now). This means for example, that I can discover and use Presence services from my &lt;a href="http://www.iphonehacks.com/jailbreak_iphone/"&gt;jailbroken&lt;/a&gt; iPod.&lt;br /&gt;&lt;br /&gt;The new lib can be found in &lt;a href="http://code.google.com/p/presence-discovery/source/browse/#svn/trunk/libs/python_consumer_lib"&gt;/trunk/libs/python_consumer_lib&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-3115433883943809684?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/3115433883943809684/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/04/new-presence-consumer-lib.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3115433883943809684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/3115433883943809684'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/04/new-presence-consumer-lib.html' title='New Presence Consumer Lib'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-6110840012107127769</id><published>2009-04-22T15:32:00.010+02:00</published><updated>2011-09-05T14:32:40.374+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>More about the __cmp__ method in Python</title><content type='html'>I just stumbled upon this little something about overloading the __cmp__ method in a Python class. If you are not careful, you will end up having a class whose instances can not be compared to None (as I always do to see if some optional parameter has been passed to a method or function). Lets take a small example:&lt;br /&gt;&lt;pre&gt;class Foo(object):&lt;br /&gt;def __init__(self, x):&lt;br /&gt;    self._x = x&lt;br /&gt;def __cmp__(self, other):&lt;br /&gt;    if type(other) == Foo:&lt;br /&gt;        return cmp(self._x, other._x)&lt;br /&gt;    else:&lt;br /&gt;        raise TypeError("Foo cannot be compared to %s"%str(type(other))) f1 = Foo(1)&lt;br /&gt;f2 = Foo(2)&lt;br /&gt;print 'f1 is smaller than f2:', f1 &amp;lt; f2 # True&lt;br /&gt;print 'f1 is larger than f2:', f1 &amp;gt; f2  # False&lt;br /&gt;print 'f1 is equal to f2:', f1 == f2    # False&lt;br /&gt;print 'f1 is None:', f1 == None         # Crash!&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This code crashes in the final statement, because the comparison to None calls the __cmp__ method, and it has no way of comparing to None. This could of course be fixed by adding "if other == None: return -1" but the right way to fix this would be by overloading another method called __eq__ that is used to test for object equality.&lt;br /&gt;&lt;pre&gt;class Foo(object):&lt;br /&gt;def __init__(self, x):&lt;br /&gt;    self._x = x&lt;br /&gt;def __eq__(self, other):&lt;br /&gt;    if type(other) == Foo:&lt;br /&gt;        return cmp(self, other) == 0&lt;br /&gt;    else:&lt;br /&gt;        return False&lt;br /&gt;def __cmp__(self, other):&lt;br /&gt;    if type(other) == Foo:&lt;br /&gt;        return cmp(self._x, other._x)&lt;br /&gt;     else:&lt;br /&gt;         raise TypeError("Foo cannot be compared to %s"%str(type(other)))&lt;br /&gt;&lt;br /&gt;f1 = Foo(1)&lt;br /&gt;f2 = Foo(2)&lt;br /&gt;print 'f1 is smaller than f2:', f1 &amp;lt; f2 # True print 'f1 is larger than f2:', f1 &amp;gt; f2  # False&lt;br /&gt;print 'f1 is equal to f2:', f1 == f2    # False&lt;br /&gt;print 'f1 is None:', f1 == None         # False&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now the comparison to None (or in fact to any object that is not of type Foo) is caught by the __eq__ method, and comparisons to other type Foo objects are correctly forwarded to the __cmp__ method.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-6110840012107127769?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/6110840012107127769/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/04/more-about-cmp-method-in-python.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/6110840012107127769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/6110840012107127769'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/04/more-about-cmp-method-in-python.html' title='More about the __cmp__ method in Python'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-5250221967624066400</id><published>2009-04-02T08:27:00.003+02:00</published><updated>2009-04-02T08:32:11.514+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='emacs'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Emacs ido-mode (minor mode)</title><content type='html'>I have just spent some time play around with the Emacs "InteractivelyDoThings"-mode; ido-mode. Ido-mode replaces your regular "find-file" and "switch-buffer" mini-buffer with a much more flexible version; a version where you are allowed to do fussy matching, tab-complete your way to opening files on remote servers, and much much more...&lt;br /&gt;&lt;br /&gt;Check out &lt;a href="http://www.vimeo.com/1013263"&gt;this screencast&lt;/a&gt; by Stuart Halloway if you have the time, or just dive into this &lt;a href="http://www.emacswiki.org/emacs/InteractivelyDoThings"&gt;EmacsWiki-page&lt;/a&gt; for a short explanation of what ido-mode does for you.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-5250221967624066400?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/5250221967624066400/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/04/emacs-ido-mode-minor-mode.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/5250221967624066400'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/5250221967624066400'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/04/emacs-ido-mode-minor-mode.html' title='Emacs ido-mode (minor mode)'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-5880672561420075505</id><published>2009-04-01T11:15:00.003+02:00</published><updated>2009-04-01T11:29:15.914+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>The "with"-statement in Python</title><content type='html'>In Python 2.5 and onwards a new "with" statement has been introduced. I recently read a &lt;a href="http://effbot.org/zone/python-with-statement.htm"&gt;really great article&lt;/a&gt; by Fredrik Lundh about the inner workings of this statement, so please read it if you are interested in all the dreary details. The syntax of the with statement is shown below:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;with expression [as name]&lt;br /&gt;    code block&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;What it boils down to is this: The with statement expects its expression to evaluate to an object that has two methods: &lt;span style="font-style:italic;"&gt;__enter__&lt;/span&gt; and &lt;span style="font-style:italic;"&gt;__exit__&lt;/span&gt;. These will then be called before and after executing the code within the statement. To quote the article &lt;span style="font-style:italic;"&gt;"Now, when the “with” statement is executed, Python evaluates the expression, calls the __enter__ method on the resulting value (which is called a “context guard”), and assigns whatever __enter__ returns to the variable given by as. Python will then execute the code body, and no matter what happens in that code, call the guard object’s __exit__ method. "&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This means, that you can use the with statement for other things than merely locking (which is probably the mostly know use). Consider the code below:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;with open('foo.txt', 'r') as infile:&lt;br /&gt;    print infile.read()&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This would open the file, assign it the name &lt;span style="font-style:italic;"&gt;infile&lt;/span&gt; in the statement code block, read and print the file, and finally close the file again. This is all because a file objects &lt;span style="font-style:italic;"&gt;__enter__&lt;/span&gt; method returns the opened file, and its &lt;span style="font-style:italic;"&gt;__exit__&lt;/span&gt; method closes the file. Pretty neat, huh? :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-5880672561420075505?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/5880672561420075505/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/04/with-statement-in-python.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/5880672561420075505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/5880672561420075505'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/04/with-statement-in-python.html' title='The &quot;with&quot;-statement in Python'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-143495566627657096</id><published>2009-03-31T15:15:00.003+02:00</published><updated>2009-03-31T15:26:40.149+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><category scheme='http://www.blogger.com/atom/ns#' term='maemo'/><title type='text'>Reading battery status on an N800/N810</title><content type='html'>For one of my projects I need to be able to read out the energy levels of the battery on my Nokia Internet Tablet (N810) - and I need to be able to do so from within a Python program, so that I may continuously monitor the energy usage of my program. After reading &lt;a href="http://davyd.livejournal.com/206645.html"&gt;this blog post&lt;/a&gt; and talking to my friend Jussi, who had spent some days implementing such functionality in a C++ program of his, I spent about five minutes porting it to Python (thanks Jussi!). The result is shown below:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;import dbus&lt;br /&gt;&lt;br /&gt;bus = dbus.SystemBus()&lt;br /&gt;hal_obj = bus.get_object ('org.freedesktop.Hal', &lt;br /&gt;                          '/org/freedesktop/Hal/Manager')&lt;br /&gt;hal = dbus.Interface (hal_obj, 'org.freedesktop.Hal.Manager')&lt;br /&gt;uids = hal.FindDeviceByCapability('battery')&lt;br /&gt;dev_obj = bus.get_object ('org.freedesktop.Hal', uids[0])&lt;br /&gt;&lt;br /&gt;print 'charge level percentage',\&lt;br /&gt;      dev_obj.GetProperty('battery.charge_level.percentage')&lt;br /&gt;print 'charge current', dev_obj.GetProperty('battery.reporting.current')&lt;br /&gt;print 'charge design', dev_obj.GetProperty('battery.reporting.design')&lt;br /&gt;print 'charge last full',\&lt;br /&gt;      dev_obj.GetProperty('battery.reporting.last_full')&lt;br /&gt;print 'charge unit', dev_obj.GetProperty('battery.reporting.unit')&lt;br /&gt;print 'voltage current', dev_obj.GetProperty('battery.voltage.current')&lt;br /&gt;print 'voltage design', dev_obj.GetProperty('battery.voltage.design')&lt;br /&gt;print 'voltage unit', dev_obj.GetProperty('battery.voltage.unit')&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This little snippet of Python code talks to the HAL layer through D-Bus, and in that way is capable of coming up with quite a lot of information about the battery. Check the &lt;a href="http://people.freedesktop.org/~david/hal-spec/hal-spec.html#device-properties-battery"&gt;complete HAL battery API&lt;/a&gt; for more information about what can be read through these calls.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-143495566627657096?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/143495566627657096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/reading-battery-status-on-n800n810.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/143495566627657096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/143495566627657096'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/reading-battery-status-on-n800n810.html' title='Reading battery status on an N800/N810'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-4547710723402546546</id><published>2009-03-30T17:13:00.003+02:00</published><updated>2009-03-30T17:25:44.757+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='security'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Excellent article about securing Python</title><content type='html'>It seems that there is in fact people out there that are actively trying to create a secure Python; as in a Python that can be used to execute untrusted code within, without endangering your trusted code (or filesystem for that matter).&lt;br /&gt;&lt;br /&gt;I was google "securing python" out of interest, to see if something has happened in this respect since the time when I was looking into it when designing my &lt;a href="http://code.google.com/p/scavenger-cf/"&gt;Scavenger&lt;/a&gt; system, and it seems that there have been some important progress since then. I found this &lt;a href="http://tav.espians.com/paving-the-way-to-securing-the-python-interpreter.html"&gt;great article&lt;/a&gt; by Tav (Vageesan Sivapathasundaram). It describes how a security system based on object capabilities can be built (and is in fact being built) within the Python interpreter. Some of the ideas are reminiscent of my approach - but what they are doing here is &lt;span style="font-style:italic;"&gt;way cooler&lt;/span&gt; than what I was playing around with ;-)&lt;br /&gt;&lt;br /&gt;By the way they are having a &lt;span style="font-style:italic;"&gt;&lt;a href="http://tav.espians.com/a-challenge-to-break-python-security.html"&gt;hack-attack&lt;/a&gt;&lt;/span&gt;, exactly &lt;a href="http://www.daimi.au.dk/~madsk/?p=36"&gt;like I did when I was testing Scavenger's security system&lt;/a&gt; :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-4547710723402546546?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/4547710723402546546/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/excellent-article-about-securing-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/4547710723402546546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/4547710723402546546'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/excellent-article-about-securing-python.html' title='Excellent article about securing Python'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-1659430836039617040</id><published>2009-03-28T11:34:00.004+01:00</published><updated>2009-03-28T11:40:27.995+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='stackless'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Building Stackless Python on a Mac</title><content type='html'>I use &lt;a href="http://stackless.com/"&gt;Stackless Python&lt;/a&gt; for some of my work (and also for my open source project &lt;a href="http://code.google.com/p/scavenger-cf/"&gt;Scavenger&lt;/a&gt;). Seeing as I do most of my development on a Mac I have a number of times had the need to build Stackless Python from source. Doing that there is one thing that you should know: you need to add the configure option called --enable-stacklessfewerregisters, otherwise you will get the following error when compiling:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;./Stackless/platf/switch_ppc_macosx.h:51: error: PIC register 'r31' &lt;br /&gt;clobbered in 'asm'&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-1659430836039617040?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/1659430836039617040/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/building-stackless-python-on-mac.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1659430836039617040'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/1659430836039617040'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/building-stackless-python-on-mac.html' title='Building Stackless Python on a Mac'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-179917853009789797</id><published>2009-03-25T14:35:00.003+01:00</published><updated>2010-03-31T13:29:00.428+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='yasnippet'/><category scheme='http://www.blogger.com/atom/ns#' term='emacs'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>YASnippet LaTeX bundle</title><content type='html'>I have started using YASnippet for Emacs and one thing that I immediately noticed was the shocking lack of LaTeX snippets. Yes, I know that the auxtex package lets you do everything by using some keyboard shortcuts, but I find it much more intuitive working with tab completed snippets. I have therefore begun a project of creating a proper LaTeX bundle for YASnippet - you may find the snippets I create &lt;a href="http://sites.google.com/site/madsdk/yasnippet-latex-snippets"&gt;here&lt;/a&gt; [old link!].&lt;br /&gt;&lt;br /&gt;Update: The snippets have been moved to a GitHub project - you may find it here &lt;a href="http://github.com/madsdk/yasnippets-latex/"&gt;http://github.com/madsdk/yasnippets-latex/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It is still a work in progress, but as soon as I find my bundle to be complete enough I will start releasing versioned "builds". As of right now you have to download the snippets individually from the download section of the homepage.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-179917853009789797?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/179917853009789797/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/yasnippet-latex-bundle.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/179917853009789797'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/179917853009789797'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/yasnippet-latex-bundle.html' title='YASnippet LaTeX bundle'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-427808522288157552</id><published>2009-03-25T09:55:00.002+01:00</published><updated>2009-03-25T10:46:47.025+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Great article about the Python GIL</title><content type='html'>I just stumbled upon &lt;a href="http://jessenoller.com/2009/02/01/python-threads-and-the-global-interpreter-lock/"&gt;this article&lt;/a&gt; about the Global Interpreter Lock in Python by Jesse Noller.&lt;br /&gt;&lt;br /&gt;I was benchmarking my Stackless Python execution environment to see whether it was actually able to utilize my multi-core CPU fully - and it wasn't... In it I spawn a thread per CPU core and thus maintain separate stackless schedulers so that I may schedule multiple tasklets for execution at the same time - or so I thought :-)&lt;br /&gt;&lt;br /&gt;The article by Jesse Noller is very nice, and I suggest that anyone interested in using threading in Python to do heavy lifting should read it. If you are using threads solely to get more responsiveness when doing blocking I/O calls there is no need to read it; just continue doing what it is you are doing ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-427808522288157552?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/427808522288157552/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/great-article-about-python-gil.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/427808522288157552'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/427808522288157552'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/great-article-about-python-gil.html' title='Great article about the Python GIL'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-4133799268222293064</id><published>2009-03-20T13:33:00.001+01:00</published><updated>2009-03-25T14:39:57.341+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='yasnippet'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='emacs'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>More Python YASnippets</title><content type='html'>I found that snippets were missing for try- and with-statements as well, so I created some:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;# contributor: Mads D. Kristensen &lt;madsdk@gmail.com&gt;&lt;br /&gt;# name: try&lt;br /&gt;# --&lt;br /&gt;try:&lt;br /&gt;    $0&lt;br /&gt;except ${1:Exception}, ${2:e}:&lt;br /&gt;    pass&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;# contributor: Mads D. Kristensen &lt;madsdk@gmail.com&gt;&lt;br /&gt;# name: with&lt;br /&gt;# --&lt;br /&gt;with ${1:lock}:&lt;br /&gt;     $0&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;These are &lt;span style="font-style: italic;"&gt;very&lt;/span&gt; simple snippets but I find them immensely useful and I hope you will too :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-4133799268222293064?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/4133799268222293064/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/more-python-yasnippets.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/4133799268222293064'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/4133799268222293064'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/more-python-yasnippets.html' title='More Python YASnippets'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-6066925608234926606</id><published>2009-03-20T13:04:00.002+01:00</published><updated>2009-03-25T14:40:12.954+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='yasnippet'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='emacs'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Python property snippet for YASnippet</title><content type='html'>&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;I have recently begun using &lt;a href="http://code.google.com/p/yasnippet/"&gt;YASnippet&lt;/a&gt; for &lt;a href="http://www.gnu.org/software/emacs/"&gt;Emacs&lt;/a&gt; (&lt;a href="http://aquamacs.org/"&gt;AquaMacs&lt;/a&gt; on Mac actually). YASnippet adds powerful snippet support to Emacs reminiscent of the snippet support in &lt;a href="http://macromates.com/"&gt;TextMate&lt;/a&gt;. Using YASnippet you may for example in Python mode type "class" and then hit the Tab-key which would expand into a class-definition snippet where all of the boiler-plate code has already been written for you.&lt;br /&gt;&lt;br /&gt;While YASnippet is quite powerful is does lack a number of standard snippets (or templates) in its standard library. For example I was missing a proper Python property snippet, so I wrote one:&lt;span style="font-family:monospace;"&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;# contributor: Mads D. Kristensen &lt;madsdk@gmail.com&gt;&lt;br /&gt;# name: prop&lt;br /&gt;# --&lt;br /&gt;def ${1:foo}():&lt;br /&gt;   doc = """${2:Doc string}"""&lt;br /&gt;   def fget(self):&lt;br /&gt;       return self._$1&lt;br /&gt;   def fset(self, value):&lt;br /&gt;       self._$1 = value&lt;br /&gt;   def fdel(self):&lt;br /&gt;       del self._$1&lt;br /&gt;   return locals()&lt;br /&gt;$1 = property(**$1())&lt;br /&gt;&lt;br /&gt;$0&lt;br /&gt;&lt;/madsdk@gmail.com&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;Using this snippet you can write "prop" and press the Tab-key. Now you only need to provide a name for the property and, if you like, a doc string for the property. The snippet then creates a getter, setter, and deleter method for the property.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-6066925608234926606?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/6066925608234926606/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/python-property-snippet-for-yasnippet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/6066925608234926606'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/6066925608234926606'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/python-property-snippet-for-yasnippet.html' title='Python property snippet for YASnippet'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-4551112944948909154</id><published>2009-03-19T13:29:00.003+01:00</published><updated>2009-03-20T13:09:41.973+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='about the blog'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>New blog</title><content type='html'>&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;I have decided to move part of my blogging to this &lt;a href="http://blogspot.com/"&gt;blogspot.com&lt;/a&gt; site instead of my &lt;a href="http://www.daimi.au.dk/%7Emadsk"&gt;original blog&lt;/a&gt;. My old blog will still hold all my research related blogging, but any tech/development/personal blogging will from now on reside on this blog.&lt;br /&gt;&lt;br /&gt;The first thing I will do, when I get the time, is to migrate old (relevant) blog posts from my old blog to this new site.&lt;br /&gt;&lt;br /&gt;By the way, I will be writing on this blog in both English and Danish. I have therefore created both an "english" and a "danish" category, and I will try to remember to apply one of these to all posts. This way you may e.g. create an English-only feed if you should so desire.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-4551112944948909154?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/4551112944948909154/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/new-blog.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/4551112944948909154'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/4551112944948909154'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/new-blog.html' title='New blog'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-8793812284446825094</id><published>2009-03-06T16:46:00.000+01:00</published><updated>2009-03-25T08:07:59.135+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Comparing and the __cmp__ method in Python</title><content type='html'>Sometimes it would be nice to be able to ask questions such as “does this array hold an object that has its instance variable ‘foo’ set to 42?” in a simpler way than by iterating through the entire array whilst comparing each objects ‘foo’ attribute to 42. This can be done quite easily in Python by overloading the __cmp__ method in your classes. The following example shows how that works in practice:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;class Foo(object):&lt;br /&gt;    def __init__(self, a_string, an_integer):&lt;br /&gt;        self.my_string = a_string&lt;br /&gt;        self.my_integer = an_integer&lt;br /&gt;&lt;br /&gt;    def __cmp__(self, other):&lt;br /&gt;        if type(other) == type(self):&lt;br /&gt;            return cmp(self.my_string, other.my_string) and\&lt;br /&gt;            cmp(self.my_integer, other.my_integer)&lt;br /&gt;        elif type(other) == int:&lt;br /&gt;            return cmp(self.my_integer, other)&lt;br /&gt;        elif type(other) == str:&lt;br /&gt;            return cmp(self.my_string, other)&lt;br /&gt;        else:&lt;br /&gt;            raise TypeError('Unable to compare %s to %s'%(type(self), type(other)))&lt;br /&gt;&lt;br /&gt;f1 = Foo('hello', 1)&lt;br /&gt;f2 = Foo('world', 2)&lt;br /&gt;f3 = Foo('!', 3)&lt;br /&gt;my_list = [f1, f2]&lt;br /&gt;print f1 in my_list # Prints "True"&lt;br /&gt;print f3 in my_list # Prints "False"&lt;br /&gt;print 1 in my_list  # Prints "True"&lt;br /&gt;print 42 in my_list # Prints "False"&lt;br /&gt;print 'hello' in my_list  # Prints "True"&lt;br /&gt;print 'mojn' in my_list  # Prints "False"&lt;br /&gt;try:&lt;br /&gt;    (1+0j) in my_list # Raises a TypeError&lt;br /&gt;except TypeError, e:&lt;br /&gt;    print e.message&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-8793812284446825094?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/8793812284446825094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/comparing-and-cmp-method-in-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8793812284446825094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8793812284446825094'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/comparing-and-cmp-method-in-python.html' title='Comparing and the __cmp__ method in Python'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-4009022813334272544</id><published>2008-12-19T16:54:00.000+01:00</published><updated>2009-03-25T08:06:36.679+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gtk'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>PyGTK natively on Mac</title><content type='html'>I recently found out that the &lt;a href="http://www.gtk.org/"&gt;GTK+&lt;/a&gt; GUI widget set had been ported to run natively (i.e. without the use of X11) on Mac OS X. Information about this project can be found on &lt;a href="http://developer.imendio.com/projects/gtk-macosx/"&gt;this page&lt;/a&gt;. Now, I like GTK+ but life is too short to be coding in C, so I imediately started looking into the possibility of using PyGTK together with this native Mac version of GTK+ and that is indeed possible. To get a fully functional version of GTK+ and PyGTK installed onto your Mac follow the &lt;a href="http://developer.imendio.com/projects/gtk-macosx/build-instructions"&gt;instructions&lt;/a&gt; on Imendio's page and then after finishing the installation add the following command:&lt;br /&gt;&lt;pre&gt;jhbuild build pygtk&lt;/pre&gt;&lt;br /&gt;This will build libglade, pygtk, pycairo and some other stuff and install the necessary files into your site-packages folder of your local Python.&lt;br /&gt;&lt;br /&gt;Building all of this from source is a lengthy process, and I have therefore created a .dmg image (&lt;a href="http://www.daimi.au.dk/%7Emadsk/files/PyGTK%20Mac%20%28Intel%29.dmg"&gt;Intel&lt;/a&gt; or &lt;a href="http://www.daimi.au.dk/%7Emadsk/files/PyGTK%20Mac%20%28PPC%29.dmg"&gt;PPC&lt;/a&gt;) of a GTK+-with-PyGTK that you may use as a shortcut :-) Using this approach will give you a fully functional native PyGTK to play with in less than two minutes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-4009022813334272544?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/4009022813334272544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/pygtk-natively-on-mac.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/4009022813334272544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/4009022813334272544'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/pygtk-natively-on-mac.html' title='PyGTK natively on Mac'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-828380043558180894</id><published>2008-12-05T08:09:00.000+01:00</published><updated>2009-03-25T08:13:23.688+01:00</updated><title type='text'>Building PythonCE from source</title><content type='html'>&lt;p&gt;I have recently had the need to compile &lt;a href="http://pythonce.sourceforge.net/"&gt;PythonCE&lt;/a&gt; from source, which turned out to be a quite complex task. Therefore I have decided to write this blog post, so that others may avoid wasting the many hours that I wasted trying to get it to build.&lt;/p&gt; &lt;p&gt;My setup for building PythonCE was this: Windows XP SP2, Microsoft eMbedded Visual C++ 4 with SP4, Pocket PC 2003 SDK, and Python 2.5.&lt;/p&gt; &lt;p&gt;To actually build the thing you need to download the PythonCE source, unzip it, enter the PCBuild/WinCE directory, and typing “scons”. This failed on my machine though, which I later found was due to a missing registry key in my Pocket PC 2003 SDK install (or something of the likes). To get it to compile i edited the file PCbuild/WinCE/msevc.py and made a small correction to the get_msevc_paths function - this is shown below. The addition I made was in the except-clause, where I manually set the exe_path.&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;def get_msevc_paths(env):&lt;br /&gt;    ...&lt;br /&gt;    try:&lt;br /&gt;        value, value_type = SCons.Util.RegQueryValueEx(hkey, 'Path Dirs')&lt;br /&gt;        exe_path = str(value.decode('utf_16_le').rstrip(u'\x00'))&lt;br /&gt;    except (SCons.Util.RegError, SCons.Errors.InternalError):&lt;br /&gt;        exe_path="C:\\Program Files\\Microsoft eMbedded C++ 4.0\\"\&lt;br /&gt;                 "EVC\\wce420\\bin;C:\\Program Files\\"\&lt;br /&gt;                 "Microsoft eMbedded C++ 4.0\\Common\\EVC\\Bin"&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-828380043558180894?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/828380043558180894/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/building-pythonce-from-source.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/828380043558180894'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/828380043558180894'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/building-pythonce-from-source.html' title='Building PythonCE from source'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1053249912953633645.post-8104477613809100956</id><published>2008-08-19T16:49:00.000+02:00</published><updated>2009-03-25T08:07:12.912+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='english'/><title type='text'>Type checking in Python</title><content type='html'>I love working with Python, and most of the time I love the fact that it is a dynamically typed language. But, sometimes type checking would be nice to have; especially when debugging larger projects. Therefore I decided to look into how function/method decorators could help me there, and I very quickly found that it is possible to implement simple type checking quite easily using such decorators. So I have written a small Python module that adds the possibility of doing run-time type checking on functions and methods. The code for this module is here:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;def decorator_with_args(decorator):&lt;br /&gt;    def new(*args, **kwargs):&lt;br /&gt;        def new2(fn):&lt;br /&gt;            return decorator(fn, *args, **kwargs)&lt;br /&gt;        return new2&lt;br /&gt;    return new&lt;br /&gt;&lt;br /&gt;@decorator_with_args&lt;br /&gt;def typecheck(fn, *decorator_args):&lt;br /&gt;    def new(*args):&lt;br /&gt;        if len(decorator_args) != len(args):&lt;br /&gt;            raise Exception('Wrong number of arguments given to\&lt;br /&gt;                             decorator.')&lt;br /&gt;        for x in range(0, len(args)):&lt;br /&gt;            if type(args[x]) != decorator_args[x]:&lt;br /&gt;                raise TypeError('Argument %i is of wrong type.\&lt;br /&gt;                                 %s expected, %s received.'%\&lt;br /&gt;                               (x+1, str(decorator_args[x]),&lt;br /&gt;                                str(type(args[x]))))&lt;br /&gt;        return fn(*args)&lt;br /&gt;    return new&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The reason that two decorators are created in the above code is, that the typecheck decorator is decorated by the decorator_with_args decorator to enable the decorator to take arguments - which is not otherwise possible.&lt;br /&gt;&lt;br /&gt;Using the typecheck decorator is as simple as:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;@typecheck(int, int)&lt;br /&gt;def add(x, y):&lt;br /&gt;    return x+y&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now, whenever the add function is called, it will be checked whether the arguments x and y are indeed integers, and if not a TypeError exception will be thrown.&lt;br /&gt;&lt;br /&gt;Feel free to copy the code into your own projects - consider it released under a BSD licence :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1053249912953633645-8104477613809100956?l=kedeligdata.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kedeligdata.blogspot.com/feeds/8104477613809100956/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/type-checking-in-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8104477613809100956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1053249912953633645/posts/default/8104477613809100956'/><link rel='alternate' type='text/html' href='http://kedeligdata.blogspot.com/2009/03/type-checking-in-python.html' title='Type checking in Python'/><author><name>Mads Darø Kristensen</name><uri>http://www.blogger.com/profile/16033062769034871096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='22' src='http://4.bp.blogspot.com/_BH8Ue1jc5vM/TA_gtPeqCcI/AAAAAAAAA4I/iIJ22nx9Lt8/S220/4623640163_65ab456ef9_m.jpeg'/></author><thr:total>0</thr:total></entry></feed>
