Recently I switched this website from Django to a static site. This article gives an overview of the core concepts of Pelican, covering areas that are not directly captured in the official docs. This is written primarily to solidify my own understanding and also act as a reference for myself …
Random strings are used everywhere in computing -- mostly as keys for cryptographic signing sensitive data. So how does one go about creating one? My first thinking was to use Python code and its random library. I came up with this import string import random def gen_random_string(length=32, charset=string …
One of Python's strengths is its exhaustive library. And date and time management is an integral part of this, provided by the datetime. Logic suggests that timedelta. That is code like this would produce an error: >>> from datetime import datetime, date, time, timedelta >>> dt1 = datetime.now() >>> td1 = timedelta(hours=1 …
I'm still finding my way around the rather vast Python standard library. And today, I discovered a quick way to convert a pure time string (of format HH:MM[:SS]) into a standard datetime.time object. datetime.strptime('08:00', '%H:%M').time() That's it! A single, rather short line …
This is more for my own reference as I often forget the various steps that I followed to get an environment set up. This post lists the steps that I followed to setup an Ubuntu Server for Python/Django/MySQL environment. The steps are drawn from various resources on the …