This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from circuits.models import Circuit | |
from user_profile.models import UserProfile | |
circuits = Circuit.objects.all() | |
profiles = UserProfile.objects.all() | |
countdown = 100 | |
while countdown > 0: | |
circuit = random.choice( circuits ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User | |
user = User.objects.get(username='admin') | |
user.set_password("admin") | |
user.save() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User | |
another_admin = User( | |
username='admin2', | |
email='[email protected]', | |
is_superuser=True, | |
is_staff=True | |
) | |
another_admin.set_password('password') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import urandom | |
from base64 import b64encode | |
DEFAULT_SALT_LENGTH = 12 | |
def generate_salt(length=DEFAULT_SALT_LENGTH): | |
salt = b64encode(urandom(length)) | |
return salt | |
if __name__ == '__main__': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Proper password hashing for storing in a web app. | |
You will need the "simple-pbkdf2" package from PyPi with either | |
"pip install simple-pbkdf2" or "easy_install simple-pbkdf2" | |
(c) 2012 - Antonio Ognio <[email protected]> | |
""" | |
from os import urandom |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## app1/constants.py | |
MY_VAR = 100 | |
## app1/settings.py | |
from django.conf import settings | |
from app1 import constants | |
MY_VAR = getattr(settings, 'MY_VAR', constants.MY_VAR) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax on | |
set tabstop=2 | |
set shiftwidth=2 | |
set softtabstop=2 | |
set smarttab | |
set expandtab | |
set nobackup | |
" auto indent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.contrib.gis.db import models | |
from smart_selects.db_fields import ChainedForeignKey | |
from common.models import AuditableModel | |
from ubigeos import strings | |
class Department(models.Model): | |
""" | |
A peruvian department. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import string | |
>>> string.digits | |
'0123456789' | |
>>> string.hexdigits | |
'0123456789abcdefABCDEF' | |
>>> string.ascii_uppercase | |
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | |
>>> string.ascii_lowercase | |
'abcdefghijklmnopqrstuvwxyz' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script helps when you're getting this kind of error on a Mac: | |
# | |
# "The volume can’t be ejected because it’s currently in use." | |
# | |
# Just copy this script to /usr/bin/free-volume or somewhere else you | |
# want and then call it passing the path to the volume you want | |
# to free. | |
# | |
# Example: free-volume /Volumes/Iomega_HDD |