Windows / PHP / ImageMagick / php_imagick: ‘no decode delegate for this image format’ or ‘ImageMagick number of supported formats: => 0′

March 15th, 2014

After spending quite some time to install imagick for PHP under Windows, I’ve finally gotten a solution that work. Fetch the prebuilt binary files from pecl (select the newest one with a windows icon behind it), and download the version for your platform. If you’re not sure, you probably want Thread Safe (if running under Apache) and x86 (you can see which platform your PHP is compiled for at the top of the phpinfo() output).

After enabling the extension, you’ll probably get a few error message about missing DLLs. This is where it gets interesting – quite a few sources on the internet will tell you to install the ImageMagick distribution for Windows, but the current version of php_imagick uses a few deprecated functions in wand, etc. Previously the dll-s bundled with imagick in the same library could be copied into the installed version of imagick, but this doesn’t seem to work any longer.

However, hidden in a PHP bug report, there’s a path to a repository of dependencies for running php_imagick under Windows, which is the complete set of compiled dll files it expects. Download the correct version of ImageMagick (something like ImageMagick-6.8.8-…) and unpack it. I ended up copying everything from bin/ into my ImageMagick installation dir, but that’s .. rather overkill and will probably cause some mystery error in the future. Copy them to a separate location that you add to your path and test PHP from the command line. Hopefully you’ll see more supported image formats now!

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

February 11th, 2014

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 globalindex.py for Sphinx

December 28th, 2013

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!).

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

The lines around line 59 should then look like:

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

Apache 2.4 Failing to Recognize Virtual Hosts

December 27th, 2013

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 ’127.0.0.1′ to /xxx/ failed, reason: unable to get the remote host name

December 27th, 2013

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 127.0.0.1 instead of the correct Require ip 127.0.0.1. Switched it, and ahoy! It now works.

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

May 22nd, 2013

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

April 26th, 2013

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()

April 26th, 2013

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/Murmur.ice:9: error: Can’t open include file “Ice/SliceChecksumDict.ice”

April 13th, 2013

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/Murmur.ice:9: error: Can't open include file "Ice/SliceChecksumDict.ice"
    #include 
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/Murmur.ice

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

April 13th, 2013

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:
 bind9