Blog

Viewing posts by christian

Cool DOIs in Python

A DOI (digital object identifier) is a persistent identifier used to uniquely identify various objects (usually documents or data sets). DOIs are typically presented as a link consisting of a proxy, a prefix and a suffix: for example:

Dyck paths and Catalan numbers

A Dyck path can be described as a sequence of $n$ horizontal steps for which, at each step a vertical step of $+1$ or $-1$ is taken subject to the constraints that the vertical coordinate never decreases below its initial value and the number of "up" and "down" steps is equal. For example,

A QR code generator in Django

The following code is the views.py file for the make_qr app behind this QR code generator app. The qrcode Python package generates a Pillow Image object, which is encoded in base-64 for rendering in the template, saving the need for an intermediate PNG file.

Deleting Gmail messages by label with the Google API

Google's suite of APIs and their Python bindings can be used to delete emails automatically, saving the hassle of navigating page after page of 100 emails at a time. Setting up a Developer project, configuring OAuth access etc. is described on the Google Developers page here. Don't forget to add yourself as a Test User.

Modular arithmetic on a circle

Inspired by David Richeson's applet on GeoGebra the Python script below plots the lines joining pairs of points, evenly spaced on the perimeter of a circle according to the following algorithm: label the $n$ points $k=0, 1, 2, \ldots n-1$; then join point $k$ to point $mk\,\mathrm{mod}\,n$.