Skip to content

Instantly share code, notes, and snippets.

View jacklinke's full-sized avatar
Making new things ✨

Jack Linke jacklinke

Making new things ✨
View GitHub Profile
@jacklinke
jacklinke / info.md
Created October 22, 2024 19:35
A management command to list all templates in the project.

A management command to list all templates in the project.

This command will list all templates in the project, depending on the template engines and loaders that are configured in the Django settings, and display them in the way you should add them to a {% url "" %} template tag or for rendering in a view.

By default, it will scan all directories in the TEMPLATES setting for template files.

@jacklinke
jacklinke / README.md
Created August 4, 2024 22:54
A script to help with gaining intuition about Python decimals

Python decimal intuition

This script helps provide an intuitive understanding of how the precision of a number affects the result of mathematical operations when using the decimal module in Python. The script uses the pint library to handle conversion between units and the rich library to display the results in a table format.

It starts with a set of example values that are converted to float, decimal.Decimal, and pint Quantity (using decimals).

  • The first output is a set of tables showing each of these example values rendered with different precision levels,
@jacklinke
jacklinke / add_created_property.py
Created July 15, 2024 23:13
Script to add a `created` frontmatter property to any markdown file missing one
"""This script processes markdown files in the current directory and all subdirectories,
adding a `created` property to the frontmatter if it does not already exist.
Process:
1. Recursively identify markdown files (*.md) in the current folder and all subfolders.
2. Skip any directories specified in the `DIRS_TO_SKIP` tuple.
3. For each markdown file:
a. Check if the frontmatter has a 'created' property.
b. If 'created' exists, move on to the next file.
c. If 'created' does not exist:
@jacklinke
jacklinke / cheatsheet.py
Created January 13, 2021 14:41
Django models cheatsheet
import uuid
from django.db import models
# Use the import below instead, if using GeoDjango fields
# from django.contrib.gis.db import models
from django.utils.translation import ugettext_lazy as _
from django.contrib.postgres.fields import (
ArrayField,
CICharField,
CIEmailField,