Maxima (software) and gnuplot – plot functions using lines with symbols on it (workaround)


I am recently working on some scientific papers for which I have to visualize a lot of mathematical functions. In a good scientific paper the graphs (and visualizations in general) should be colorless and utilize dotted/dashed lines or lines with symbols on it instead of colors. This has several advantages: A colorless plot is more neutral to the reader, he/she does not get distracted by the different colors. A reader may also have a (subliminal) preference in color, so he/she pays more attention to e.g. the red curve than the yellow one, that is hardly readable on the white background anyway. This also helps to distinguish functions, if they are plotted in one diagram and printed in gray scale mode or read by color blind people. Also, if two identical functions are plotted in one diagram, using just colors will probably only show one of the functions and hide the other.

I am using the CAS software Maxima to do the calculations, which in turn uses gnuplot to plot the functions. Gnuplot alone does the job perfectly. However, when plotting functions (and not discrete data points) using lines with symbols on it from within Maxima (which also uses gnuplot to plot the graphs), the results are quite ugly. There seems to be no proper solution to this problem.

This blog post suggests a workaround that is rather ugly, but which produces very nice graphics, that meet the above-mentioned requirements.

Continue reading

Coders’ forbidden vocabulary

I often have to read a lot of code from other people that is not exactly well written or easily understandable. I am working on several different projects; some open-source for fun & giggles and some closed-source for money & fame. I just noticed that the biggest problem in understanding other peoples code is not about things you could easily measure, like code quality in the sense of code formatting standards or the language that it is written in. Naming of constants and variables make all the difference for understanding the code others have written.

forbiddenvocabularyI realized, that there are some words which should just be forbidden to use on their own. They are too broad or just don’t add any valuable information. I am also very sorry that these following examples contain PHP code, but this is where examples for doing things wrong are easily found. Most of the example code listings are not good practice in other senses as well, but that’s not what this post is about; It’s about the kind of readability which applies to all programming languages.

Continue reading

How to install and configure CherryMusic on a Debian Wheezy (headless) server


This guide explains how to correctly — and more importantly cleanly — install CherryMusic on a (headless) server running Debian Wheezy — without polluting the operating system in any way. For Arch Linux or a more generic installation see the CherryMusic Arch Linux wiki page and CherryMusic’s own wiki on GitHub.

Continue reading

The “Matrix Code” in your linux terminal using python and curses

Everybody knows the code on the screens in the movie the matrix. You can see it for example when the character “cypher” talks to “neo” somewhen in the night, and the green letters fall down on those second-hand dell screens behind them. Funky. I want that too.


I’ve written a python program that uses curses to create a similar looking animation and just now cleaned up the code a bit and made sure it runs in python 2 and 3. You can get the source code on github and there’s a screenshot and a short explaination after the break…

Continue reading

PyLint and Pep8 validation in geany

If you’re into python, but don’t know about PEP8 or PyLint, you should find out right now. And because pep8 and pylint are great, but it’s hard to force yourself to use them all the time, lets integrate them into geany, a fast and lightweight IDE.

Continue reading

3to2 by hand – back porting python 3 to python 2

As mentioned in an earlier post, I’m currently writing a music streaming server in python. As I wanted to go with the newest thing available, I wrote it in python 3. Unfortunately the application server we rely on, cherrypy, is only packaged for python 2 in most distributions! Even worse, even if the packages were installed for python 3, it would not run, since I relied on python 3.3 features.

Since this keeps my program from being used in the world, I decided to backport it to python 2. For me it was very important, that the code would not get any uglier by doing so, so I started writing a replacement module.

Here’s a collection of useful code snippets to help you making your software python 2 / 3 compatible.

Continue reading

CherryMusic – A Music Streaming server for your browser

This post is quite old. CherryMusic has improved a lot since then. For the latest version and information on CherryMusic, please visit

I recently wrote a Music Streaming Server in python, that allows you to listen to your music inside a browser, no matter where you are. It is called CherryMusic and features a standalone webserver based on cherryPy as well as JPlayer, a HTML5/Flash music player. It indexes your data for fast search using a sqlite database, so there is nothing to setup for you, just download the sources and off it goes!

In my tests it works perfectly with many thousand indexed files: searches are returned immediately, even on my  little home server.

You can download the sources from github or download them directly from the projects page. Any suggestions for improvement are welcome.

After the break you can find some screenshots of it in action.

Continue reading

Conway’s Game of Life in 3 Lines of Python

I recently saw a video of an implementation of Conway’s game of life written in APL which was done in just one line. And because I couldn’t sleep last night, I implemented it in python as short as I possibly could.

So here it is:

There’s a little write-up and the source after the break.

Continue reading

Indexing large tar files for fast access using python

I recently needed to get some data out of a large tar file, about 5gb in size, that I didn’t want to extract, as it contained many thousands of small files. Unfortunately the tar format was not designed to be indexed, since it was meant for backups on magnetic tapes (tar stands for tape archive). The gnu tar has a command for retrieving single files, but it needs to go through the whole tar each time, which was just too slow.

So I decided to write a little tool, that would index all files inside the archive and write that index to another file. Now I can access each file within the tar in just a second, instead of 15 minutes. Introducing the tarindexer!

UPDATE: The project is now up on github under GPL v3

Continue reading

Poor man’s DynDNS – A PHP solution

I’m running a Thin-Client as a home server and sometimes I need access to some files at home. Since those no-ip services didn’t prove that reliable in the past, I decided to implement a DynDNS substitute in PHP.

The concept is quite simple: Let the little server at home call a PHP script somewhere on a “big” Server that has a static IP. The big server then writes the IP to a file, so it can be read from anywhere. There are two scripts that have to reside on the big server: an index.php, which reads and echoes the IP, that was recorded, and another script in a .htaccess protected folder, which is able to write the IP of the home server to a file.

Continue reading