This file contains 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
# subl is a command line interface (cli) for a program called sublime text 2 | |
# http://www.sublimetext.com/docs/2/osx_command_line.html | |
alias subl="'/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl'" | |
alias nano="subl" | |
export EDITOR="subl" | |
alias edit_bash="subl ~/.bash_profile" | |
alias rebash=". ~/.bash_profile" |
This file contains 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
def clean_username(un): | |
import re | |
# clean username | |
un = re.sub(r'[^a-zA-Z0-9._]+', '', un) | |
# soft truncate | |
if len(un) > 30: | |
un = un.split('@')[0] # pray for email address |
This file contains 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.core.management import setup_environ | |
try: | |
import settings | |
except ImportError: | |
import sys | |
sys.stderr.write("Couldn't find the settings.py module.") | |
sys.exit(1) | |
setup_environ(settings) |
This file contains 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 re | |
import HTMLParser | |
from django.core.management.base import BaseCommand | |
class Command(BaseCommand): | |
""" | |
Converts title and content html entities to unicode | |
""" |
This file contains 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.core.validators import email_re | |
def is_email_valid(email): | |
""" Check if valid email via Django regex """ | |
return bool(email_re.match(email)) |
This file contains 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 | |
from django.db.models.fields import FieldDoesNotExist | |
# Used for user import feature. | |
# There's no form validation; so we validate max_length this way. | |
# loop through user properties; truncate at max_length | |
for key, value in user.__dict__.items(): | |
max_length = None | |
try: |
NewerOlder