Replacing dead links for the Dutch Royal Library (Koninklijke Bibliotheek)

Posted on 12 September 2015 in wikimedia • Tagged with python, wikimedia

This is mostly a set of notes to allow others to perform these replacements as well. They are written for the specific case of the KB, but should be applicable to URL replacements in general.

The original requests can be found at 1 and 2.


  • a working pywikibot installation …

Continue reading

Using LiveReload with Pelican

Posted on 16 June 2015 in misc • Tagged with pelican, python

LiveReload is magic. As the authors describe it:

The Web Developer Wonderland

(a happy land where browsers don't need a Refresh button) -- LiveReload

What does it do? It's a browser plugin that automatically refreshes a page when the server tells it to. On the other side, we have a web …

Continue reading

Building a Flask project with OAuth enabled on Tool Labs

Posted on 15 May 2015 in wikimedia • Tagged with python, wikimedia

This is a guide to building a simple Flask project on Tool Labs. Tool Labs is the Wikimedia shared hosting project, for projects ('tools') related to Wikipedia or one of the other Wikimedia projects.

This guide assumes you have a Tool Labs account and some knowledge of getting around. The …

Continue reading

Adding a colormap to a figure without imshow/countour set

Posted on 25 March 2015 in matplotlib • Tagged with python, matplotlib

Example: plot a packing using circles, and use the foreground color to show some value for each particle, for example the contact number Z:

The trick to this is to call plt.scatter() to plot a single point outside the axis range. This allows plt.colorbar() to find cmap and …

Continue reading

raw_input in matplotlib with plot interaction

Posted on 08 August 2012 in misc • Tagged with python, matplotlib

When working with data, you sometimes need to view the data and give input on how to continue. However, a simple

answer = raw_input()
will not work: the plot GUI will block while the raw_input() is waiting. The following is a (admittedly hacky) solution to this problem: run raw_input() in a seperate thread, and poll the GUI using waitforbuttonpress():

Continue reading