Archive for the 'Computer' Category

Published by Niels on 17 Jan 2014

Autotools Cookbook Notes, Part 3

In the previous instalment, Autotools were used to create a separate library from our source code. This time I will show how to add unit tests.

Unit testing is a very important tool for every software engineer and fortunately the Autotools provide us with an easy way to create and use unit tests. After creating the tests running them is as easy as running the following command on the command line:

make check

I will continue where I left of with the Autotools setup for libraries to show how to incorporate unit tests in your project based on the CppUnit. Why not one of the more recent C++ unit test environments such as the Boost Test Library or CxxTest? Simply because I am more experienced using CppUnit and know how to set up Autotools with it. In later instalments I will add setups for other testing frameworks but these setups will probably deviate not too much from the setup using CppUnit.

It is of course assumed that the CppUnit test framework is already installed on your machine. If not then the internet provides sufficient information on how to do so. Continue Reading »

Published by Niels on 29 Dec 2012

Flexible multi-platform Vim setup – part 1

As a software engineer I often prefer to use Vim with an appropriate set of plug-ins for my daily work. Vim is a great editor to get work done, especially when making use of the available plug-ins and the power of personal settings in my ‘.vimrc’ file. But to maintain those plug-ins and ‘.vimrc’ file on a local system can become very cumbersome. It becomes even more cumbersome when you work on multiple machines. Then not only plug-in maintenance is cumbersome, but the fact that you have to install them again every time becomes annoying as well.

In this article I want to show how I am able to make use of a single installation of my plug-ins and ‘.vimrc’ using the power of Dropbox and Vundle.

Although Pathogen seems to be the more popular solution I decided to use Vundle as this enables me to maintain my plug-ins from Vim. The article will assume that you are using Linux. Later instalments will show how to use the set up on multiple platforms. Continue Reading »

Published by Niels on 06 Feb 2011

Remove Build Dependencies after ‘apt-get build-dep’

I recently started to have a look at the LibreOffice code to see if I could contribute to it. On their developers web page there is a nice tutorial on how to install all the build dependencies for it using Debian based Linux distributions like Ubuntu. If you want to get rid of all these dependencies after a while, for example because you are no longer interested or you need the disk space, it is very hard to delete them. Fortunately I found a working solution here.
To make things a bit easier I built a script to for command line use that can be downloaded here:

sudo aptitude markauto $(apt-cache showsrc "$1" \
    | grep Build-Depends \
    | perl -p -e 's/(?:[\[(].+?[\])]|Build-Depends:|,|\|)//g')

It can be invoked as follows (assuming it is in your PATH):


I want to emphasize that I did not invent this method, the credits should have to go to the persons that posted the solution on Launchpad.

Published by Niels on 26 Dec 2010

Autotools Cookbook Notes, Part 2

In the previous instalment a skeleton Autotools project was created. In this instalment the usage of libraries for the application code will be added. I like putting my application data into libraries as it makes it more convenient to reuse the code, e.g. when doing unit testing (which will be shown in a later instalment).

In this instalment a skeleton setup for handling libraries using Libtool will be presented. At the end the methods to link against the static or dynamic libraries will be shown. The created library will be a very trivial one but the created skeleton should be enough to expand on this.
Continue Reading »

Published by Niels on 25 Dec 2010

Autotools Cookbook Notes, Part 1

For most software projects that go past the trivial state a build environment can assist in helping with finding dependencies, providing alternatives, documentation creation, unit testing, etc. One of the most flexible environments are provided by the GNU Autotools, but setting up a new Autotools project can be a bit cumbersome. It always seem to give me the feeling that I have to rediscover everything about the GNU Autotools and to avoid making the same mistakes over and over again I kept a lot of notes. The disadvantage of personal notes are of course:

  • They get disorganized
  • They are hard to keep up-to-date
  • They are not always available
  • It is difficult to transfer the knowledge contained in them to another person

So therefore I decided to do what I always do to solve these issues: I publish the knowledge on a subject that I obtained so far on my homepage. It will be series of instalments, each building on the knowledge from the previous instalments. In this first instalment a trivial ‘Hello, World!’ project will be created. Later instalments will provide information on:

But more subjects might be added in the future. It is also most likely that new insights will be added to already published parts and I will try to indicate the new additions as good as possible.

Since I consider these my personal notes they are not a replacement for the full GNU Autotools documentation and other resources. For more in-depth information the following on- and off-line resources are recommended:

Although I consider these my notes, complete with rough-edges and warts and all, and by no means a complete tutorial on the subject I do still appreciate any remarks or comments. Nowhere will a setup guide for the used tools be given. These differ to much from system to system and with the use of Google resources with better information than I can provide should be available.

Continue Reading »

Published by Niels on 28 Oct 2010

Problems combining OmniCppComplete with Pathogen

Since a few days I am using the Pathogen plug-in together with the scripts from GitHub as described here. I think it is a wonderful way to maintain my personal ViM installation. However, after installing and trying OmniCppComplete I got the following error messages when attempting to complete something:

-- Omni completion (^O^N^P) Pattern not found

After a while I found out that the used complete-function ‘omnifunc’ was set to:


This is the generic completion function for C-based programs and does not work well with C++-programs. To fix this add the following line to .vimrc:

au BufNewFile,BufRead,BufEnter *.cpp,*.hpp set omnifunc=omni#cpp#complete#Main

This should leave you with a working OmniCppComplete plug-in managed from the vim-scripts repositories at GitHub.

Published by Niels on 08 Apr 2010

Computable door de bocht

Ik heb me net heerlijk zitten ergeren aan een artikel op de Computable website. De stelling is dat het introduceren (het gebruik wordt niet eens genoemd), van Linux in een bedrijfsomgeving verborgen kosten met zich mee brengt. Dat zou helemaal waar kunnen zijn, maar de auteurs Johan Zwiekhorst en Jozef Schildermans van Data TestLab slaan volgens mij op een aantal punten behoorlijk door. De argumenten op een rijtje:

  • Bovendien is opensourcesoftware minder populair dan Windows, zodat vandalen het vooralsnog grotendeels met rust laten…Echt waar? Zouden de onderzoekers wel eens een gekeken hebben naar de echte getallen over Open Source? Apache, iemand? PHP? Java? Bovendien gaat het begrip Open Source veel verder dan alleen het operating system, dus het begint al door appels met peren te vergelijken.
  • Zoals je waarschijnlijk wel weet, bestaan er honderden Linux-distributies. De toon lijkt nu wel gezet. Feitelijk en tendentieus.
  • De basis van die bundel is de linux kernel: die is hetzelfde voor iedereen. Daarbovenop komt het GNU/Linux platform. Kennis van GNU/Linux ontbreekt blijkbaar bij de auteurs: de kernel is niet bij alle distributies hetzelfde. Ze zijn wel gebaseerd op dezelfde broncode, maar vaak aangepast door de maker van de distributie om zo goed mogelijk aan te sluiten bij de doelgroep van de distributie. De opmerking dat het GNU/Linux platform erbovenop komt is natuurlijk onzin. Het heet GNU/Linux omdat een Linux kernel wordt gecombineerd met de GNU applicaties om een operating system te maken. Richard Stallman zal het niet waarderen dat de GNU applicaties GNU/Linux worden genoemd.
  • Als je een Windows-gebaseerde server draait, dan moet je die clientlicenties betalen ongeacht het gebruikte desktopsysteem. Wat een raar argument. Als het een homogene Windows-omgeving is, moet er ook voor zowel de client als de server licenties betaald worden. Bij Linux ben je in ieder geval nog het bedrag voor het desktop operating system kwijt.
  • Zo blijkt het erg moeilijk om computers van A-merken te kopen zonder Windows erop. Dat is alleen Microsoft aan te rekenen. Dus feitelijk weer juist, maar het lijkt mij eerder een argument om zo snel mogelijk te stoppen met het gebruik van Microsoft producten, want daardoor wordt blijkbaar de prijs van apparatuur onnodig opgejaagd.

Afgezien van de hierboven beschreven argumenten, staat het artikel bovendien vol met taal- en/of typefouten. Ik ben benieuwd naar het vervolg op dit artikel op 12 april, maar gezien de argumentaties in dit artikel vrees ik het ergste.

Published by Niels on 02 Apr 2010

Error: Cannot modify header information…

If PHP ever gives you the following error (I just encountered it while developing with the Yii Framework):

Cannot modify header information - headers already sent by

Then you probably injected some whitespace somewhere in your output. The easiest way to avoid that is by not using the PHP closing tag ‘?>‘ at the end of PHP source files. Some people are against that but if I look into the sources for Yii and read the Zend Framework Programmer’s Reference Guide then it is obviously a well established method of avoiding the mentioned error.

Published by Niels on 14 Nov 2007

Color schemes, Color schemes, Color schemes…

As a passionate and seasoned user of the best editor in the world I always look around for ways to improve the editing experience. One way to improve that is by selecting a good color scheme. The ViM website offer a ton of color schemes but no way to sample them other then look at the user ratings, install them and then judge for yourself. And even then the color schemes on the ViM site are not all schemes that are available.

Fortunately someone wrote a page where, as far as I know, all color schemes are shown and downloadable. Even my two favorite ones: here and here. The only minor annoyance is the fact that the color schemes are not all alphabetically ordered.

I know, I know, old news, but I still like to use this web site as my own long term memory…

Published by Niels on 29 Aug 2006

Release of NanoBlogger Gallery plugin 0.6.0

There is a new release of the NanoBlogger Gallery plugin. The previous version had a problem when run in Bash versions below 3.1. There are some differences when initializing arrays from a ‘string’ using $IFS.

In Bash 3.1 you can do this:

declare -a arr=( $a )
echo "${#arr[@]}"
# Outputs 3 in version 3.1 and 1 in version 3.0

But if you instead do this then it works in both versions:

declare -a arr
eval "arr=( $a )"
echo "${#arr[@]}"
# Outputs 3 in version 3.1 and 3.0

So hopefully the Gallery plug-in is better prepared for the real world :). Thanks to Chris Gratham for helping me out with this.

The new version can be downloaded here.

Next »