... and their answer to everything

Manipulating pdfs with pdfjam

posted on 2011-02-14, author: Christoph Sieghart

Every once in a while you need to manipulate pdfs on a high level. Thats where pdfjam comes to the rescue. It is the swiss army knive of high level pdf manipulation. The operations I perform the most are merging, splitting, trimming and converting documents to multiple pages per page.


To merge two or more pdf documents, just pass them to pdfjam with the appropriate page selectors.

pdfjam file1.pdf '-' file2.pdf '1,2' file3.pdf '2-' --outfile output.pdf

This will take all pages of file1.pdf, page 1 and 2 of file2.pdf and all pages up from page 2 of file3.pdf and merge them in a file called output.pdf. For more info an pdfjam page selector see the pdfjam help.


Splitting works just the way merging does.

pdfjam file1.pdf '1,2' --outfile first.pdf
pdfjam file1.pdf '3-' --outfile second.pdf

If you know of a way to do it in one go, drop me an email.


pdfjam --trim '1cm 2cm 1cm 2cm' --clip true file1.pdf --outfile output.pdf

This trims 1cm from the left and right, and 2cm from the top and bottom of the file. This is especially useful for removing blank margins from pdfs (really nice for reading on an ebook reader like the Amazon Kindle).


pdfjam --nup 2x2 file1.pdf --outfile output.pdf

This recombines the pdf file to contain 4 pages per page. Useful for printing slides.

This is just a small peek at what pdfjam can do. If you need help checkout

pdfjam --help

and the LaTeX pdfpages package.

tag: cli, tools

Improve Samsung Galaxy S performance with Voodoo

posted on 2011-01-23, author: Michael Zoech

The Samsung Galaxy S is still one of the best phones out there for Android. Lightweight, great colors, no judders like other phones in the same price range. But there is still one problem with the stock Samsung firmware. Laggy applications when compared to other phones. The problem is known, the filesystem access is really slow compared to e.g. a Nexus One. I first noticed this while developing an application and writing some debug information to the filesystem on each app start. While the startup time on a Nexus One or a Galaxy Tab was somewhere between 2 to 4 seconds, it took around 8-10 seconds for the SGS to get up and running.

But not any longer, Open Source to the rescue. The people behind Project Voodoo have a fix by converting the proprietary RFS filesystem found on stock SGS to Ext4. To compare the performance of stock and voodo i have used a free app called Quadrant Standard Edition.

Stock 2.2 BenchmarkVoodoo Benchmark

On the left side you see the performance of the stock firmware, while on the right side the voodoo lagfix has been applied. While the benchmark not only tests filesystem performance, the result jumped from 970 to 1510 points. An increase by 55 percent simply by converting the filesystem. The result is noticeable, laggy apps now appear much faster. The best example would be the new Android Market app. The UI feels snappy and no noticeable lags that happened with the stock firmware.

tag: android

DirectX 10 and CUDA in C#

posted on 2009-04-27, author: Michael Zoech

I’m currently evaluating the possibilities to use DirectX 10 and CUDA from C# for a realtime visualization project. The official CUDA sdk contains many samples written in Cpp, but i couldn’t find one sample in the whole web written in C#. So i ported one of the CUDA sdk samples using SlimDX for DirectX 10 and CUDA.NET to access the CUDA functionality. Grab the source here.

More Eclipse Shortcuts You Should Know

posted on 2008-09-17, author: Michael Zoech

There is an excellent post about Eclipse navigation shortcuts at 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know. Since this post only looks at navigation shortcuts, i thought i post some of my favourite Eclipse shortcuts i use every time in Eclipse to boost my productivity.

Look at next/previous error in current file

Use Ctrl + . or Ctrl + , to cycle through the errors in the current file. This marks the next or previous error. Hitting F2 shows the error description and the quick-fix menu. This is much faster than using the mouse to locate the error, float over and wait for the description to pop up. Note, this works for warnings too.

Error Description and Quickfix

Quick-Fix menu

The quick-fix menu provides you with the appropriate refactoring options for the current cursor position. This lets you add imports (see picture above), add unimplemented methods, extract marked expressions to local variables, … . Hit Ctrl + 1 to get it.

Show quickfix for unimplemented methods

Show quickfix extract to ...

Run jUnit tests of current file

Hitting Shift + Alt X T runs the jUnit tests found in the current file. Use Shift + Alt D T if you want to debug-run the tests.

Rerun jUnit Test

I often find myself in the need to run the same jUnit tests again and again. The jUnit plugin provides the ReRun Test button, i think i have hit a million times now.

ReRun JUnit Test Button

Luckily you can create a shortcut binding for this. Go to Window -> Preferences -> General -> Editors -> Keys and setup an appropriate binding. I have bound this command to Ctrl + Alt R R. This makes it really easy to write tests, jump back and forth to the production code and rerun the same test files over and over again.

Surrounding code parts with try-catch, if, for, …

Surrounding already existing code with something like a try-catch block or a for loop is often tedious and error-prone. Not any longer. Mark the code you want to move inside the block or loop, hit Shift + Alt Z and select the type of surrounding block.


Selected expression Integer.parseInt(input);


Expression surrounded by try-catch block

Rename variable, method, class, …

Hitting Shift + Alt + R lets you rename a variable, method or class name at the current cursor position. The renaming happens not only in the current file, but takes care of all references to the variable, method or class in other files of the project.

Renaming a method

Note that the renaming fixes the reference in the other method.

The Content Assist Menu

Hitting Ctrl + Space shows the Content Assist menu for the current cursor position. E.g. writing ‘‘for’’ and hitting Ctrl + Space shows the following:

Content Assist Menu

Selecting the first template (for - iterate over array) replaces the ‘‘for’’ with this:

Content Assist for

There are many predefined templates. Go to Window -> Preferences -> Java -> Editor -> Content Assist -> Templates to find out about templates and to create your own templates. My favourite one is ‘‘Test’’ for creating an empty jUnit test method.

Show all shortcuts

Shift + Ctrl + L shows a list of all shortcuts. Although i do not use this on a daily basis you may find even more interesting shortcuts there.

Show Key Asist

sed - non greedy matching

posted on 2008-07-08, author: Christoph Sieghart

I just needed non greedy matching in sed and the man page had nothing to say about it (I was hoping for a simple flag, but nada).

As do all other regexp engines I know of, sed uses greedy matching per default. The trick to get non greedy matching in sed is to match all characters excluding the one that terminates the match. I know, a no-brainer, but I wasted precious minutes on it and shell scripts should be, after all, quick and easy.

So in case somebody else might need it:

Greedy matching:

% echo "<b>foo</b>bar" | sed 's/<.*>//g'

Non greedy matching:

% echo "<b>foo</b>bar" | sed 's/<[^>]*>//g'
tag: shell