Skip to content

Instantly share code, notes, and snippets.

View brandenhall's full-sized avatar

Branden Hall brandenhall

View GitHub Profile
@brandenhall
brandenhall / Customizing the Date & Time Format in Django with USE_L10N enabled.md
Last active December 10, 2022 15:49
Customizing the Date & Time Format in Django with USE_L10N enabled

With the USE_L10N setting enabled (which is the default in Django 4) you can't override date/time formatting in your settings.py - it has to be done at the locale level.

The default date/time formatting for English uses 24-hour time. But, if you're in the US you commonly need to change it use 12-hour time. This is how you do that without disabling USE_L10N.

See https://docs.djangoproject.com/en/4.1/ref/settings/#format-module-path for more details.

Within your site's main folder (where your settings.py lives), create this structure:

formats /
 __init__.py
@brandenhall
brandenhall / apa102.py
Created September 13, 2016 21:44
Library for talking to APA102 "DotStar" RGB LED strips via SPI
"""
Library for talking to APA102 "DotStar" RGB LED strips via SPI
Requires external package spidev
Developed by Branden Hall (bhall@automatastudios.com)
"""
import math
import spidev

Keybase proof

I hereby claim:

  • I am brandenhall on github.
  • I am brandenhall (https://keybase.io/brandenhall) on keybase.
  • I have a public key whose fingerprint is 64AD 87C5 50A3 56DA C192 272C 05A5 9F29 F552 8888

To claim this, I am signing this object:

@brandenhall
brandenhall / Sample Usage
Created December 7, 2011 20:28
Secret Knock Detector module
// Shave-and-a-haircut, two bits! In the upper left corner
var secret = [{delay:0.5, x:0, y:0, radius:200},
{delay:0.25, x:0, y:0, radius:200},
{delay:0.25, x:0, y:0, radius:200},
{delay:0.5, x:0, y:0, radius:200},
{delay:1, x:0, y:0, radius:200},
{delay:0.5, x:0, y:0, radius:200},
{delay:0, x:0, y:0, radius:200}];
function allowInside() {