Skip to content

Instantly share code, notes, and snippets.

@webtweakers
webtweakers / models.py
Last active April 1, 2021 21:28 — forked from parhammmm/models.py
Encrypt and decrypt Django model primary key values (useful for publicly viewable unique identifiers) [python3 version]
# This code is under the MIT license.
# Inspired by this StackOverflow question:
# http://stackoverflow.com/questions/3295405/creating-django-objects-with-a-random-primary-key
# Python 3.x version
import struct
from Crypto.Cipher import DES
from django.db import models
def base36encode(number):
@webtweakers
webtweakers / cert_renew.py
Last active June 19, 2018 21:56 — forked from squatto/certificate_renewal.py
Webfaction letsencrypt automatic certificate renewal and installation
#!/usr/bin/env python3
# Python3 script to renew HTTPS certificates, using acme script and Webfaction's API.
# See: https://manikos.github.io/webfaction-letsencrypt-django (original version, plus docs)
# See: https://gist.github.com/squatto/69d81ab4790f21a94828041c9295e8da (updated version)
# See: https://github.com/Neilpang/acme.sh (acme script)
# Usage: ./cert_renew.py domain.tld cert_name
# Run this script as a cron job every day in order for the certs to be renewed when appropriate: