Skip to content

Instantly share code, notes, and snippets.

@irneh
irneh / gist:5568229
Last active December 17, 2015 06:49

1

2

One good sentence.

def randstr(length):
return ''.join(chr(random.randint(0,255)) for i in range(length))
def hash_password(password, maxtime=0.5, datalength=64):
return scrypt.encrypt(randstr(datalength), password, maxtime=maxtime)
def verify_password(hashed_password, guessed_password, maxtime=0.5):
try:
scrypt.decrypt(hashed_password, guessed_password, maxtime)
return True
ooh la la
#!/usr/bin/perl -wT
# Upgrade a PostgreSQL cluster to a newer major version.
#
# (C) 2005-2009 Martin Pitt <mpitt@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
expires = datetime.utcnow() + timedelta(days=(25 * 365))
expires = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
file.seek(0)
k.set_contents_from_string(file.read(), headers={
'Content-Type': 'image/jpeg',
'Cache-Control': 'public',
'Expires': expires,
})