Sometimes I need a simple stop watch in my Python scripts to find out how expensive my code is in wall clock time. The problem is trivial to solve, but I thought I’d give it a try using Python’s with statement and a context manager.
Fun with Context Managers
Posted January 23, 2010 by mafrCategories: python
Tags: python, scripting
Eee PC Wireless Troubles
Posted January 17, 2010 by mafrCategories: linux
Tags: linux, scripting, shell
Half a year ago, I bought an Asus Eee PC 1000HE netbook. The first thing I did was wiping Windows XP off the disk and installing Ubuntu Jaunty Netbook Remix. When I bought the netbook, I knew support for the wireless chip (AR928X, according to lspci) was limited, but things worked most of the time. Unfortunately, things changed with Ubuntu Karmic.
Google Gollections 1.0
Posted January 16, 2010 by mafrCategories: java
Tags: google, java, libraries
The guys at Google took their time, but the much anticipated Google Collections 1.0 have finally been released. I expect this library to change the way we write our Java code (at least it did that to mine), so I put together an overview article to get you started.
Plotting with Matplotlib
Posted December 26, 2009 by mafrCategories: python
Tags: libraries, linux, python, tools
For a long time, Gnuplot has been my tool of choice for plotting diagrams. The diagrams it produces out of the box look very scientific, but it takes a lot of tweaking to produce something that’s visually pleasing. I got used to Gnuplot’s weird ways but I was never entirely happy with it. For example, I found it quite annoying that there’s no easy way to plot a simple histogram. The only way to do this is by beating a bar chart into submission (and counting the buckets yourself in a script). Not entirely my idea of fun.
Apache 2.2 and Digest Authentication
Posted November 22, 2009 by mafrCategories: linux
Tags: linux, server, web
A few weeks ago I wanted to enable digest authentication on an Apache 2.2 web server. I got basic authentication working within minutes, but I didn’t want to send plain text passwords over the web, so how difficult could it be?
A Template for Python Unix Utilities
Posted October 24, 2009 by mafrCategories: python
Tags: linux, python, scripting
One of the most often read postings on this blog is the one about my getopts-enabled shell script template. So I figured, a similar template in Python would also be useful. Like the shell script, it’s quite trivial, but it might still save some time.
Quick Tip #3: Creating Histograms in Python
Posted September 10, 2009 by mafrCategories: python
Tags: python, quick tips
Since Python 2.5, creating histograms has become easier. Instead of dict, we can now use defaultdict which is similar in behavior to awk’s associative arrays. Instead of raising a KeyError for undefined keys, defaultdict adds a user-defined item and returns it.
An IMAP Configuration for Mutt
Posted September 8, 2009 by mafrCategories: linux
Tags: linux, shell, tools
Usually, I download all my email via fetchmail, sort it into folders using procmail and read the mails with mutt. This works reasonably well and I’ve been using this mail setup without major changes for about 10 years. Since I recently bought a netbook, I also wanted to read mails with it, but without touching my existing mail setup. The netbook should only read mails directly on the server without downloading anything to local disk.