Fixing 1_6.W001 when upgrading from Django 1.5 to 1.7

After upgrading a Django project from Django 1.5 to the current beta of Django 1.7, running the tests triggered a warning:

System check identified some issues:

WARNINGS:

?: (1_6.W001) Some project unittests may not execute as expected.
	HINT: Django 1.6 introduced a new default test runner. It looks like this project was generated using Django 1.5 or earlier. You should ensure your tests are all running & behaving as expected. See https://docs.djangoproject.com/en/dev/releases/1.6/#discovery-of-tests-in-any-test-module for more information.

This warning is printed by the System Check Framework, which is new in Django 1.7 and checks your project for common problems. You can run it manually with the “check” management command.

python manage.py check

After verifying that all my tests are run, I was left wondering how I can silence the warning after reading (okay, let’s be honest: skimming) the release notes of 1.6. The answer is simple, but I had to look in the source of the system check framework to find it. Apparently you have to explicitly define a test runner starting from Django 1.6. To do so, add the following line to your settings:

TEST_RUNNER = 'django.test.runner.DiscoverRunner'

Change order of PATH entries on Mac OS X

I wanted to have /usr/local/bin to be listed before /usr/bin in my PATH environment variable.

One way to achieve this would be to add a ~/.profile file with a line like this:

export PATH=/usr/local/bin:$PATH

This would result in /usr/local/bin being listed twice. It wouldn’t hurt but it’s not pretty either.

If you look at /etc/profile, you will see that the initial value of PATH is set by path_helper(8).

The right way to change the order of default paths is to edit /etc/paths. It contains one path per line, in descending order. Mine looks like this:

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

Howto clear Solr index


If you want to delete all items from Solr index, use the query

<delete><query>*:*</query></delete>

as described in the FAQ on the Solr Wiki.

But how do you actually send this query? You can use this command:

curl http://<host>:<port>/<solr_base>/update?commit=true -d '<delete><query>*:*</query></delete>'

Just replace the placeholders with the right values, e.g.

curl http://localhost:8983/solr/update?commit=true -d  '<delete><query>*:*</query></delete>'

If Solr responds with something like this:

HTTP Status 400 - missing content stream
Status report
message missing content stream
description The request sent by the client was syntactically incorrect (missing content stream).

then you are probably missing the commit parameter i.e. ?commit=true

How to solve the 36 Cube puzzle – hints & solution

For Christmas, I got the ThinkFun 36 Cube. It is consists of 36 towers in 6 colors and 6 different sizes and a base plate with 6 by 6 slots to plug in the towers. These slots are of different heights. The goal is to place one towers of every color in each row and column. And the  towers must fit to form a level cube.

After some tries, I came to the conclusion that this puzzle is the work of the devil and that I should not waste more brain cycles on solving it. So I wrote a little python script to solve the puzzle for me.

Show sourcecode

My program quickly came up with a correct placement for 34 towers – but it failed to find the complete solution.

[('P', 5), ('Y', 3), ('O', 2), ('B', 1), ('R', 4), ('G', 6)]
[('Y', 4), ('O', 1), ('P', 6), ('R', 2), ('G', 5), ('B', 3)]
[('O', 6), ('B', 5), ('R', 3), ('G', 4), ('P', 1), ('Y', 2)]
[('R', 1), ('G', 2), ('Y', 5), ('P', 3), ('B', 6), ('O', 4)]
[('B', 2), ('P', 4), ('G', 1), ('Y', 6), ('O', 3), ('R', 5)]
[('G', 3), ('R', 6), ('B', 4), ('O', 5), ('X', 2), ('X', 1)]

Legend:
P = Purple, Y = Yellow, O = Orange, B = Blue, R = Red, G = Green, X = Empty
The number is the size of the tower.
As you can see, I didn’t waste much time on making the output pretty ­čÖé

36cube almost solved

So close and yet so far

After spending lots of time verifying that my program was working correctly, I became impatient and googled for help. I found an answer, but it revealed to much, taking all the fun.

Therefore, I split my solution into multiple hints. If you are stuck, reveal just one of them at a time and try to figure it out by yourself. It is way more rewarding!

Hint #1 (show):

Hint #2 (show):

Hint #3 (show):

Hint #4 (show):

Hint #5 (show):

Even if you uncovered all hints, the puzzle is still far from solved. You can still tinker with it forever.

Spoiler alert: Don’t uncover the solution, unless your are really desperate!

Click to show the 36cube solution.

Automatic plugin update problem in WordPress 2.8.x

After upgrading WordPress to the current version, I could no longer automatically update plugins. This is the error message I got:

Downloading update from http://downloads.wordpress.org/plugin/xxx.zip.

Unpacking the update.
Warning: unlink(/…/wp-content/upgrade/xxx.zip) [function.unlink]: No such file or directory in /…/wp-admin/includes/class-wp-upgrader.php on line 146

Incompatible archive PCLZIP_ERR_MISSING_FILE (-4) : Missing archive file ‘/…/wp-content/upgrade/wp-syntax.0.9.8.zip’

After digging through the forums I found a solution to the plugin autoupdate problem in the WordPress Support forum.

Open the file wp-config.php in the root directory of your WordPress installation and remove the definition of the WP_TEMP_DIR variable, i.e. a line that looks like this

define('WP_TEMP_DIR', ABSPATH . "wp-content/upgrade");

WLAN an der Uni Karlsruhe (DUKATH) mit Ubuntu 8.10

Ubuntu hat inzwischen eine ziemlich gute WLAN-Unterst├╝tzung. Lange Zeit konnte DUKATH nur[1] mit einem VPN-Client genutzt werden, inzwischen geht das auch per WPA. Laut Anleitung des Microbit [PDF] soll man ein Skript schreiben um den Zugang zu nutzen. Unter Ubuntu geht es aber auch etwas einfacher:

Auf das Symbol des Netzwerk-Manager-Applet klicken:

Das Netzwerk dukath-??x ausw├Ąhlen.

?? h├Ąngt vom Standort ab. Beim RZ gibt es eine ├ťbersicht ├╝ber die verwendeten SSIDs.

Auswahl DUKATH-Accesspoint

Auswahl DUKATH-Accesspoint

Im darauf folgenden Dialog die richtigen Werte eintragen:

Einstellungen DUKATH

Einstellungen DUKATH

Bei Zertifikat sollte das Deutsche Telekom Root CA 2 Zertifikat ausgew├Ąhlt werden.

Benutzername und Passwort entsprechen denen bei der Verwendung von VPN.

Fertig!

[1] Der Zugang ├╝ber das DUKATH Web-Interface sollte nur in Notf├Ąllen genutzt werden, da die Verbindung nicht verschl├╝sselt wird und deshalb einfach abgeh├Ârt werden kann.