Skip to content

Instantly share code, notes, and snippets.

@doctaphred
doctaphred / django-secret-key
Last active March 7, 2018 18:25
Generate a secret key suitable for use with Django
#!/usr/bin/env python
"""Generate a new secret key suitable for use with Django.
Uses the same process as django.core.management.utils:get_random_secret_key.
"""
from random import SystemRandom
random = SystemRandom()
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
print(''.join(random.choice(chars) for _ in range(50)))
@luzfcb
luzfcb / uuid4_python_regex.md
Last active September 3, 2022 06:42
uuid4 python regex . django slug

A UUID-4 has five groups of lowcase hexadecimal characters, the first has 8 chars, the second 4 chars, the third 4 chars, the fourth 4 chars, the fifth 12 chars.

However to make it a valid UUID4 the third group (the one in the middle) must start with a 4:

00000000-0000-4000-0000-000000000000
              ^
@ke4roh
ke4roh / git-show-big
Last active April 22, 2017 12:11
Show large objects in the git repo for cleaning cruft
$ cat git-show-big
#!/bin/bash
# Ref http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history
SHAS=$(git rev-list --objects --all | sort -k 2)
BIGOBJS=$(git gc && git verify-pack -v .git/objects/pack/pack-*.idx | egrep "^\w+ blob\W+[0-9]+ [0-9]+ [0-9]+$" | sort -k 3 -n -r)
join <(echo "$BIGOBJS" | sort ) <(echo "$SHAS" | sort ) | sort -k 3 -n -r | cut -f 1,3,6- -d\
@mixxorz
mixxorz / waveform.py
Last active January 19, 2023 15:46
Generate waveform images from audio files
# Requires pydub (with ffmpeg) and Pillow
#
# Usage: python waveform.py <audio_file>
import sys
from pydub import AudioSegment
from PIL import Image, ImageDraw
@ipmb
ipmb / Dockerfile
Created May 24, 2015 21:23
Example wheel upload to simple PyPI on S3
FROM ubuntu:14.04
ENV BUCKET your-s3-bucket
RUN apt-get update && apt-get install -y wget \
build-essential python-dev \
libssl-dev libffi-dev \
libpcre3-dev \
libmemcached-dev \
libpq-dev \
(Chapters marked with * are already written. This gets reorganized constantly
and 10 or so written chapters that I'm on the fence about aren't listed.)
Programmer Epistemology
* Dispersed Cost vs. Reduced Cost
* Verificationist Fallacy
* Mistake Metastasis
The Overton Window
Epicycles All The Way Down
The Hyperspace Gates Were Just There
@jcyamo
jcyamo / i3-exit
Last active October 9, 2020 10:26
Exit script for the i3 window manager based off of exit script from CrunchBang Linux.
#!/usr/bin/env python
# based on cb-exit used in CrunchBang Linux <http://crunchbanglinux.org/>
import pygtk
pygtk.require('2.0')
import gtk
import os
import getpass
@gavinwahl
gavinwahl / tags.py
Created May 8, 2013 23:00
`map` template tag
import uuid
from django import template
from django.template.base import Token, TOKEN_BLOCK
register = template.Library()
class MapNode(template.Node):
def __init__(self, var_name, tag, list):
@dezinezync
dezinezync / logentries.stream.js
Last active November 28, 2018 01:04
Streaming Express.logger's output to logentries
var logStream = {
write: function(message,encoding) {
log.info(message.replace('\n', ''));
}
};
//Application's configuration
app.configure(function() {
//Your base config methods
@toastdriven
toastdriven / requiredreading.txt
Created December 5, 2012 20:59 — forked from adamfast/requiredreading.txt
Preserved for #lawrence history, this was the "required reading" list of totally-non-work-related inside jokes of the World Online crew.
DJ Ango, yo!
http://railsenvy.com/2007/9/10/ruby-on-rails-vs-django-commercial-7
The Whistles
[now broken] http://www.youtube.com/watch?v=ccgXjA2BLEY
http://www.youtube.com/watch?gl=US&hl=en&client=mv-google&v=Nnzw_i4YmKk
Do it live!
http://www.youtube.com/watch?v=2tJjNVVwRCY
REMIX: http://www.youtube.com/watch?v=5j2YDq6FkVE&NR=1