Skip to content

Instantly share code, notes, and snippets.

View ads901119's full-sized avatar

Alan Sha ads901119

View GitHub Profile
@ads901119
ads901119 / models.py
Created July 31, 2012 06:11 — forked from treyhunner/models.py
Encrypt and decrypt Django model primary key values (useful for publicly viewable unique identifiers)
# 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
import struct
from Crypto.Cipher import DES
from django.db import models
def base36encode(number):
@ads901119
ads901119 / sift3.py
Created July 8, 2012 11:07 — forked from fjorgemota/sift3.py
Sift3 in Python
def sift3(s1,s2, maxOffset):
s1L = len(s1)
s2L = len(s2)
if not s1:
return (not s2 and 0 or s2L)
if not s2:
return s1L
c1 = 0
c2 = 0
lcs = 0
@ads901119
ads901119 / playlist-dl.py
Created May 1, 2012 08:18 — forked from FiloSottile/playlist-dl.py
Download a youtube playlist using rg3/youtube-dl by @orschiro
import shutil
import os
import sys
import subprocess
import re
# Settings
root_folder = 'C:/Users/Robert/Videos/YouTube/Playlists/'
destination_regex = re.compile(r'^\[download\] Destination: (.*)$', re.M)