No application without a library, no web site without an API?

When I wrote the first versions of Dynamite and Unshield (eight and nine years ago!) I decided from the start that each project had to be implemented in two parts: a library (hopefully reusable) and a command line tool using the library. I believe I learned this from cURL and libcurl, and I still consider it a best practice. For the purposes of this article, let’s call it the tool-library pattern.

I don’t do much C/C++ coding these days, even though I have been ogling Spindly – the C89 implementation of SPDY forked from libspdy by cURL author Daniel Stenberg.

For my current clients at work, I do Java coding or webMethods Integration Server development.

When I can spare some and energy for coding at home, it’s mostly web development in PHP, which brings me back to the tool-library pattern: Unfortunately I have not yet started using a smilar practice for my web development.

So what is the web site equivalence to the tool-library pattern? For a web site I mean that the “library” is a web service API that is consumed by the actual web site.  This is called First-Class APIs by Helgi Þormar Þorbjörnsson.

The API does not have to be public, but if it is, any other consumers of the API (for example a Smartphone app) will share the same API (or parts of it).

I’m currently rewriting my Swedish site for colloquial words and expressions from a hack (!) to a proper layered architecture. The next step will be to add new features and I hope to move these into an API.

Setup a new headless Ubuntu VM in VirtualBox on FreeBSD

  1. Download from
  2. VBoxManage register “/storage2/virtualboxes/Ubuntu server 11.10/Ubuntu server 11.10.vbox”
  3. VBoxManage list vms
    “Ubuntu server 11.10” {231c28f0-19bb-48d7-9db4-ba29de37e5fd}
  4. VBoxManage modifyvm “Ubuntu server 11.10” –usbehci off
  5. VBoxManage modifyvm “Ubuntu server 11.10” –pae on
  6. VBoxManage modifyvm “Ubuntu server 11.10” –nic1 bridged –bridgeadapter1 em0
  7. VBoxManage sharedfolder add “Ubuntu server 11.10” –name backup –hostpath /backup
  8. nohup VBoxHeadless –startvm “Ubuntu server 11.10” -n 2>&1 &
  9. Connect from desktop via VNC to configure and install guest additions (sudo apt-get install virtualbox-guest-dkms)
(Note that my blog converts two dashes to a single long dash above.)

Moving a DokuWiki site to a new server

I have customized my DokuWiki installation to allow multiple wikis, similar to running multiple WordPress blogs on different domains. My /etc/dokuwiki/local.php looks like this:

This means that I have multiple DokuWiki sites in my /var/lib/dokuwiki/ directory. To copy only one of them:

  1. Copy the /etc/dokuwiki/hostname directory and symbolic links
  2. Copy the /var/lib/dokuwiki/hostname directory and symbolic links
  3. Copy the template(s) from /var/lib/dokuwiki/tpl/templatename or /var/lib/dokuwiki/lib/tpl/templatename

Installing tarsnap on a vanilla Ubuntu server

  1. cd /var/tmp/
  2. curl -O  (or actually the latest version from
  3. sudo apt-get install gcc e2fslibs-dev zlib1g-dev libssl-dev make
  4. cd tarsnap-autoconf-1.0.31 (directory name corresponding to the downloaded tarball)
  5. ./configure && make && sudo make install
  6. sudo tarsnap-keygen –keyfile /root/tarsnap.key –user username –machine machinename (note that my blog converts two dashes to a single long dash so you need to edit this line after cut & paste)
  7. sudo cp /usr/local/etc/tarsnap.conf.sample /usr/local/etc/tarsnap.conf
  8. sudo vim /usr/local/etc/tarsnap.conf (if you need to edit any options)