Facebook Graph API: (#324) Missing or invalid image file

If you keep getting errors when trying to set a custom page tab icon when adding an app to a page – make sure that the application is actually published. You can add it – and the icon will change, but will still generate an error – if the application isn’t published yet. No idea why it’d give an error like that, but hey.

There’s quite a few other reasons for the error as well, but Google have probably already told you about those.

Old Ubuntu-releases in APT / etc.

We have an old VM (Ubuntu 14.10) that we just have running – it does a very specific job, isn’t connected to anything important and just shugs along. But because of a dependency issue with external software, we needed to install a new library to it – and because of dependencies when we first set up the VM, Ubuntu was the distro selected.

Sadly all the old URLs for apt-get in sources.list had stopped working, as the mirrors no longer had that specific Ubuntu (utopic) version available.

Luckily – after a bit of using our old friend Google – I found old-releases.ubuntu.com. This is also available as an archive for content through APT, so if you prefix your old addresses with old-releases.ubuntu.com instead of whatever mirror you’re used to fetching images from, you can get last version of the packages made available when you first set up your distro.

Saved the day!

“python.exe has stopped working” suddenly appeared under Windows 10

When attempting to start python tonight, Windows 10 suddenly produced the “python.exe has stopped working” error. Examining the event in the Event Viewer didn’t provide any more useful information, but surprisingly everything worked if I launched python.exe directly from Explorer – or through bash (cygwin), but not if I launched it through the regular command line (cmd.exe).

What solved it? Removing the old directory again (even after trying a fresh install) and then explicitly finding the 64-bit version from the python download page (it gives you the 32-bit version by default, it seems). Reinstalling with the new archive fixed everything, and now it works again (and I checked “pre-compile the standard library, but that shouldn’t change anything)! Woho! Now to just reinstall quite a few virtualenvs..

Android: Changing the Title of an Activity – setTitle works – android:label does not?

To change the title of an activity (to show a more custom title for a certain activity than the application title), you can set the new title either through calling setTitle("foo") on the activity or by setting android:label="@string/price_after_rebate" in your activity style.

The problem was that the latter didn’t work, while the first one did. I try to keep any static definitions related to the activities outside of the code itself, but that’s hard when it doesn’t work as expected.

Turns out that if there’s a title set in the AndroidManifest.xml file (located under app/manifests/ in the standard layout / Android Studio), it’ll override any title set elsewhere in the definitions. You can change the specific titles by setting android:label="@string/price_after_rebate" on the activity definitions in the manifest instead of the activity xml file:

        android:value="xyz.MainActivity" />

Enabling OpenVPN configuration / autostart on Ubuntu

This assumes that you’ve already made sure that your configuration is valid and is able to connect (you can do this by calling openvpn --config /etc/openvpn/FILENAME.conf directly. It won’t be daemonized, but it will give you any errors on the console directly).

There’s a few details you’ll have to get right before the openvpn daemon starts your configuration automagically under Ubuntu:

  1. Your configuration has to be under /etc/openvpn/FILENAME.conf. The .conf part is important. If it ends with .ovpn or anything else, it won't be loaded.
  2. Ubuntu isn't set to start all configurations by default. You can change this by editing /etc/default/openvpn. Change the AUTOSTART variable to the configurations you want to start when the daemon starts. The example in the file says "all", which means that all defined configurations will start. This is OK if you want to keep openvpn up at all times.
  3. You have to tell systemd that you've changed the default file. If you don't do this, nothing will have appeared to change for openvpn - unless you restart the OS. And you don't want to restart your server just to make a setting visible. Do systemctl daemon-reload to make systemd reload the settings (this is also in the comments in the file, but hey, you don't have time to read those, so now you're searching Google instead).
  4. Restart openvpn: service openvpn restart
  5. Confirm that everything went OK by looking in /var/log/syslog

Installing Intel RST – Error Message “This platform is not supported”

While trying to find out why my Intel RAID had disappeared after upgrading to Windows 10 (but I still had the disks visible), I was trying to install Intel RST to be able to configure my RAID and see if there was any configuration left. The Intel RST installer did however refuse to install, and just gave the cryptic message “This platform is not supported”. It didn’t say .. which platform or what a platform was or .. anything usable (and the log file didn’t tell me much more).

The reason? My motherboard had the SATA mode set to ACHI and not to “RAID”. Went into the bios, changed AHCI to RAID in the advanced / SATA configuration, and rebooted. Intel RST installed as it should! And I had to recreate my RAID1 – but Intel RST allows you to say “this is the disk you should keep, so mirror this to the other disk” when creating (be sure to check the LUN/BUS/etc. IDs in the properties for each disk so you can provide the correct disk as the master copy if they’re out of sync).

So: BIOS -> Advanced -> SATA -> SATA MODE -> RAID.

Mounting / Serving a Pyramid Application From Several Paths / URLs

One of the requirements for an application we’re developing is that the same application should be served from different endpoints. The application currently lives at / at one of our servers, but should also be available at /foo/bar – which is served through a 3rd party varnish with our server as the backend, pulling the application into a different domain name space.

mod_wsgi in Apache supports this, but for those of us who are not using the Apache version, you can also handle it directly in the Pyramid configuration by using the urlmap handler, available in the Paste library.

Our old configuration:

use = egg:applicationname

First, we’ll have to require paste in setup.py, so add:


to the requires = [ ... ] list in your setup.py (and rerun setup.py develop).

Second, use urlmap as your main application in your configuration (development.ini, production.ini). urlmap will then route the request internally to the required application (which also means that the endpoints may point to different applications, but we’re not using that yet):

use = egg:Paste#urlmap
/ = applicationname
/foo/bar = applicationname
/spam/ham = applicationname

use = egg:applicationame

The composite app is now the main entry point for the WSGI application, which then hands the request off to the actual application, applicationname.

Adding click tracking / clicktags to iframes / HTML-ads in Adtech / Helios

After producing an HTML5 banner, living in an iframe, delivered through Adtech / Helios, we had a case where the clicks weren’t tracked by the advertising platform. That’s as expected, since the content hosting the iframe is unable to manipulate any content within the iframe (unless they’re on the same originating host, and we’re serving our content by ourselves to make it dynamic and without a huge setup cost (in time)).

Turns out Adtech / Helios has a few variables that it can replace when delivering the URL or the HTML of the iframe (similar to the function of a clickTAG for Flash content):

_ADCLICK_: Standard variable for click tracking
_ADCLICKESC_: URL is escaped by the ad server
_ADCLICKDEC_: Decoded target URL
_ADCLICKDECESC_: Decoded and escaped URL

We went with _ADCLICK_, which will be replaced by the URL to prefix any link in your own content with. That way the click will be routed through the tracking code at the ad server, and the counts should match what we’re actually seeing on the other side (through analytics and events).

Luckily the link to prefix does not contain any special characters that need to be escaped (they use ; as a separator) when used in as GET arguments in an URL, so you can add an argument to the existing URL:

<iframe src="http://www.example.com/?ad=1&clicktrack=_ADCLICK_"></iframe>

You can then pick this up in your server side language and prefix all urls, or you can extract it in JavaScript and add it to any link available in dynamic content.

This also works in data- attributes for the iframe, allowing you to retrieve the click prefix through javascript from that parameter as well.

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

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)

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