Blog

Viewing posts by christian

The Square Roots of Integers Visualized as Sharks Teeth

The Spiral of Theodorus (also known as the Snail of Pythogoras), illustrated below, is a well-known visualization of the square roots of the integers as the length of the hypotenuses of a sequence of right triangles, placed edge-to-edge.

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.