Graham Knapp

AI design patterns django e57 feature flags pointcloud python Rhino 3D talks TypeScript wind engineering

Any way the wind blows 🔗

written by Graham Knapp on 2019-03-20

Adding leading zeros with Python

Various ways to add leading zeros to a number, for instance a wind direction, using Python. Available as a Jupyter Notebook

Generate a list of wind directions

First some definitions. The wind direction is measured in degrees clockwise from north and represents the direction the wind is blowing from. For instance an easterly wind, i.e. wind blowing from the east has a direction of 90 degrees. Let's generate 16 wind directions from 0 (north) to 337.5 (north by northwest).

```python interval = 22.5 # degrees assert 360 % interval < 0.001 n = int(360/interval)

directions = [interval * x for x in range(n)] print(directions) ```

Read Full Post


Building a blog 🔗

written by Graham Knapp on 2019-03-18

I have had a few ideas for content to share recently and wanted a good way to do so. I wanted to find a good solution for blog publishing with a few criteria:

  • Built using Python, editable in markdown so I can develop my skills.
  • Simple to build and maintain - I am not a web developer and have no desire to become one. That said, I have been building websites on an amateur basis since the 1990s so I'm not afraid of writing a little html if I have to.
  • Capable of incorporating Jupyter Notebooks
  • Simple to deploy, preferably for free. I am hoping to do this via my internet provider but might go via GitHub failing that or even pay for a small cloud server.
  • No initial need for interractive content.

I saw that the static site generators Pelican and Lektor were available. That sounds like a good solution as it should be quick and have few moving parts which could break. Lektor looked simple, welcoming and modern enough so I downloaded and installed it. I listened to Talk Python episode 160 as I did so and that encouraged me that I was on a good path.

Listen to Talk Python Episode 160 - Lektor (2018)

My initial experience has been great - I got going with no problem except that at the time of writing I have been waiting over a week for free to get around to setting up my personal web space so I can deploy the site. At least that has given me enough time to configure a basic blog and write my first 2 posts.

Post-deployment update

OK so I have gone for GitHub pages for hosting with a custom web domain - buying the domain name and specifying it in Lektor and in GitHub pages was enough to get it working properly with https - no need to update certificates every few months !