Could not import extension sphinxcontrib.spelling (exception: cannot import name xmlrpc_client)

While attempting to get sphinx to build the documentation for Imbo, I ran into the error message “Could not import extension sphinxcontrib.spelling (exception: cannot import name xmlrpc_client)”. I had just installed sphinxcontrib.spelling, so I had assumed it would pick up any dependencies – apparently not.

The python xmlrpc_client module name comes from the six library, a library to help write code that works on both python2 and python3. The library was installed, but apparently Ubuntu had an older version available, where xmlrpc_client wasn’t available.

Solution: Update six manually with pip:

sudo pip install --upgrade six

Making Multi-Level Anchors Work With for Sphinx

One of the issues I’ve come across when using Sphinx (awesome application) for writing documentation is that the table of contents disappear when using the singlefile format (which generates the documentation as one large page instead of having to click through to other files).

Luckily Matteo Franchin had the same issue, and created a small extension for Sphinx that allows you to add a TOC to SingleHTML builders as well! The problem I discovered after a while is that it ends up adding redundante HTML anchors for each level when resolving the TOC, where it ends up generating #html#anchors like that. Which doesn’t work.

I solved the issue (.. for my simple case, this is still a hack) by adding regular expression that removes any HTML anchors that are followed by another HTML-anchor (and could very possibly eat a lot more in edge cases, but hey, it works for me!).

rendered_toctree = re.sub(r'(#[^ "]+)#', '#', rendered_toctree);

The lines around line 59 should then look like:

            rendered_toctree = builder._get_local_toctree(docname, **kwargs)
            rendered_toctree = re.sub(r'(#[^ "]+)#', '#', rendered_toctree);
            node['content'] = rendered_toctree

Apache 2.4 Failing to Recognize Virtual Hosts

After upgrading from Apache 2.2 to 2.4 in a Windows development environment, all my virtualhosts stopped working. I could add syntax errors to the files which would make Apache refuse to start up, or get notices about invalid document roots, but the virtual host server names just wouldn’t catch on.

After removing the reference to Include conf/extra/httpd-vhosts.conf things suddenly started working! Weird. The reason seems to be that the default vhost referenced in httpd-vhosts.conf uses _default_ instead of * to reference the virtualhost name. I’ve used * in all my configuration files, and apparently Apache refuses to reference any * references if it hits a _default_ name in the VirtualHost configuration first. That seems weird, so if someone has any more information about what’s causing this, I’m very interested.

My setup now works again, so I’m not going to start digging into the source to find the reason for this just yet. :-)

AH01753: access check of ‘’ to /xxx/ failed, reason: unable to get the remote host name

This error message can be caused by placing an IP instead of a hostname in a Require host statement in Apache 2.4+. After porting some old access rules to Apache 2.4 I had used Require host instead of the correct Require ip Switched it, and ahoy! It now works.

Merging Weird, Splitted Email Attachments as .DAT-files With [x/x] in Subject

A client received a large collection of emails today, where the sender’s software had split the mail into several parts. Outlook / Exchange at our end did however not understand the scheme the user had used to split the files, so the mails arrived as separate entities in the mailbox.

Each mail was named in the same manner:

filename [1_3].dat
filename [2_3].dat
filename [3_3].dat

After saving the files by themselves, it became clear that the files contained a set of mime encoded files (separated by –-=_NextPart_) (I first attempted to decode one of the files by itself as base64, which failed).

To decode these files, I saved all the different parts of the .dat to a directory, then appended the files together with cat *.dat > merged.dat. At least we have a complete version of the attachment.

To extract the files from the attachment, use munpack – available in the mpack package under Ubuntu.

munpack merged.dat extracts all the files from the .dat to the current directory.

NetBeans with NBandroid, Emulator Never Shows After Building/Running With F6

Trying to build my first (or second, I tend to forget) Android project under NetBeans, I ran into an issue where the emulator would never show up when I tried to build the project. Turns out I even got a null pointer exception which I thought were generated somewhere else in NetBeans (next time: read the actual exception and don’t assume).

The solution to fix the emulator never showing up? Update the currently installed version of the JDK. (Thanks to a Stackoverflow thread for hinting in the correct direction) Remember that NetBeans might be tied to a particular version of the JDK (either in the command line arguments or in netbeans.conf in the etc/ directory of the NetBeans installation directory). I uninstalled any older version, which gave me an error about the value of jdkhome being wrong, and asking if I wanted to use the default path instead. That worked, but the error shows up each time. Comment out the jdkhome-line in netbeans.conf and it’ll guess automagically each time (if guessing works for you), or if guessing doesn’t work, add the new path to the JDK in netbeans.conf.

SEVERE: org.apache.solr.common.SolrException: can not sort on unindexed field: geodist()

This error may occur if you’re using sort=geodist() in your Solr Spatial / Geographic Search. The reason is probably that you have an empty pt= value or that the parameter is missing all together.

You might also want to make sure that your Solr version is new enough to support sorting by functions, but if you’re doing anything useful with spatial searches you’re probably updated enough – at least for geodist(). :-)

slice2php and Ubuntu: /usr/share/slice/ error: Can’t open include file “Ice/”

Trying to generate Murmur.php for the server component of Mumble (named Murmur (which is the only place I’ve ever encountered Ice)), slice2php gave the error:

/usr/share/slice/ error: Can't open include file "Ice/"
1 error in preprocessor.

To fix this I had to run slice2php with a -I statement, to tell it where to find the SliceChecksumDict file (which you can locate using locate or find or the packages search):

slice2php -I/usr/share/Ice-3.4.2/slice /usr/share/slice/

dpkg: /etc/resolvconf/update-libc.d/sendmail: 7: .: Can’t open /usr/share/sendmail/dynamic

While apt-get upgrade-ing a server that apparently had bind9 installed, it barfed out complaining about something about sendmail. Weird, as sendmail isn’t installed (at least not any longer), but since sendmail isn’t installed, it couldn’t be removed either.

The solution: mv /etc/resolvconf/update-libc.d/sendmail /tmp — and run dpkg / apt-get / aptitude again. If it works now (and you don’t have sendmail installed either), delete the file from /tmp.

/etc/resolvconf/update-libc.d/sendmail: 7: .: Can't open /usr/share/sendmail/dynamic
run-parts: /etc/resolvconf/update-libc.d/sendmail exited with return code 2
run-parts: /etc/resolvconf/update.d/libc exited with return code 1
invoke-rc.d: initscript bind9, action "restart" failed.
dpkg: error processing bind9 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:

alt+<number key> stops working in irssi and putty under Windows

I have no idea why this happens. I have not been able to fix the underlying issue, but .. do you have photoshop open?

It turns out photoshop interrupts the alt+number keys globally, so even if you have putty open, changing windows with alt+<number key> won’t work. Closing photoshop makes everything work again.