slippens's blog

Simple and quick command line argument handling in Python

17 January, 2012 - 00:08

When creating a command line tool, you quickly are faced with the burden of handling command line arguments (parsing options, arguments, flags, etc).
In Python, the optparse module or, its newer version, the argparse module are very nice solutions to build powerful command line interfaces, completely with automatically generated help.

Sometimes however, you just want a quick, simple and small way to get from A to B without a lot of overhead and overkill. Below I'll show you a quick and simple Python trick for command line handling by directly mapping the command line arguments to function arguments.

Read more...

List of available git commands

21 December, 2011 - 21:55
Categories:

Git comes with a massive bunch of (sub)commands and even if you're dealing with git on a daily basis, you might not always remember every single one you need along the way. Having bash completion for git is already a good start (type git, a space and then tab), but this is only a subset with the higher level commands.

Read more...

Slow down Charlie Parker with SoX

16 December, 2011 - 00:57
Categories:

For the saxophone music classes I'm taking, I have some exercises to play along with Charlie Parker records. Because that Bird plays pretty fast, it helps to slow things down a bit. I started with manually slowing down the tempo with Audacity, but soon I couldn't suppress the itch to automate things as I needed several slow down factors and also wanted the slow down factor in the MP3 ID3 title tag.

Read more...

PHP lint checking multiple files in parallel

2 November, 2011 - 00:11
Categories:

When programming, lint checking your source code can be useful to detect low level issues like syntax errors, undefined or unused variables. The PHP command line interpreter has an option -l/--syntax-check to do a syntax check of the provided PHP file, instead of executing it:

$ php -l file_with_syntax_error.php 
PHP Parse error:  syntax error, unexpected T_VARIABLE in file_with_syntax_error.php on line 5
Errors parsing file_with_syntax_error.php

Unfortunately, it only allows to check one file at a time. For example, the following does not work as expected:

$ php -l file1.php file2.php file_with_syntax_error.php 
No syntax errors detected in file1.php

If you want to lint-check (a complete tree of) multiple PHP files, you have to use some kind of loop (e.g. in Bash) to check them one by one.

I recently was faced with this issue, but also wanted to have some parallelism, to speed up the process by putting multiple cores a work, instead of checking one file at a time. After googling a bit I found the following (command line) solutions.

Read more...

Running 32 bit executables on a 64 bit machine (Ubuntu Linux)

1 July, 2010 - 11:55
Categories:

I recently had this strange problem with running a 32 bit executable on a 64 bit machine. It executed just fine on 32 bit machines and some other 64 bit machine. But on this particular machine I got the strange error message:

bash: some32bitexecutable: No such file or directory

which is confusing because bash seems to complain that it does not find the executable, while I knew it was there. Using absolute paths and double checking the permissions didn't help.

The problem was however that the 32 bit runtime libraries were not available.

The fix on Ubuntu is to install the ia32-libs package, described as:

ia32 shared libraries for use on amd64 and ia64 systems.
This package contains runtime libraries for the ia32/i386 architecture, configured for use on an amd64 or ia64 Debian system running a 64-bit kernel.

(FYI: it will pull down some other packages too, like lib32gcc1, libc6-i386 and lib32stdc++6.)

Read more...

Slides of my public PhD defense

13 June, 2010 - 16:30

I finally found some time to upload the slides of my public PhD defense to SlideShare. It's all in Dutch, but if that's Chinese to you, you still can watch a lot of pretty pictures.

Advanced Techniques for Digital Halftoning - PhD Stefaan Lippens (public defense Dec. 19, 2008, in Dutch)

I already tried to upload my slides more than a year ago, but slideshare had troubles with converting my slides. There is still a problem with missing math notation around slide 75, but all the rest seems okay.

Read more...

Indentation with spaces and the tab key in Eclipse (3.5 aka Galileo)

28 May, 2010 - 00:29
Categories:

Indentation with spaces and the tab key in Eclipse. I've pulled quite some hair on this one and now that I found the solution, I decided to write it down, so I don't have to loose my precious hair anymore.

Everybody has its own preferences, but I like 2 space indentation for PHP (code style of Drupal) and 4 space indentation in Python. And when I press the tab key, I want to increase the indentation level, not insert a tab character. Doesn't seem like much to ask, but it took a long and frustrating process to get this working in Eclipse (3.5 aka Galileo at the time of this writing), Aptana Studio actually, with PDT for PHP development and the excellent Pydev for Python development.

Read more...

Keyboard shortcut for code completion in Eclipse on Mac OS X

30 April, 2010 - 18:39

Finally! I found how to get the keyboard shortcut for code completion working in Eclipse on Mac OS X. At work, on Linux, I use CTRL-SPACE all the time in Eclipse. Unfortunately that did not work on my MacBook: CMD-SPACE triggers the spotlight search widget and CTRL-SPACE is tied to the Quicksilver launcher in my case.

Read more...

Gearman (job queue manager) command line tool: routing the workload to the worker process arguments with xargs

27 April, 2010 - 14:55

Abstract

Gearman provides a basic command line tool that helps to distribute work from clients to worker processes/machines. By default the worker process can only receive data from its standard input. With the xargs tool we can circumvent this and route data to the process arguments of the worker process.

Read more...

PDF to PostScript conversion: pdf2ps versus pdftops

5 February, 2010 - 12:16

Occasionally, I have to convert a PDF file to Postscript (e.g. for subsequent processing with some PostScript utility). In the Linux/command line area, I know two options: pdf2ps and pdftops. I also know that one of the two sucks has some issues and the other is better. But because their names are so close I can't manage to remember which one to take. This post should put an end to that!

[Spoiler alert and a questionable mnemonic: pdftops is da top.]

Read more...