Skip to content

Instantly share code, notes, and snippets.

View emperorcezar's full-sized avatar

Adam "Cezar" Jenkins emperorcezar

  • SpotHero
  • Mokena, IL
View GitHub Profile
# Try and generate a unique username. Hopefully they never see this.
for count in itertools.count(1):
# Get the first part of the email and use 30 characters
username = request.POST['email'].split('@')[0][:30]
if not User.objects.filter(username = username).exists():
break
else:
# Try and append a number in the last postion of the username
username = username[:30-len(str(count))] + str(count)
continue
@emperorcezar
emperorcezar / gist:4644924
Last active December 11, 2015 18:58
My zshell setup
export ARCHFLAGS="-arch x86_64"
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
# Path to oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
@emperorcezar
emperorcezar / gist:4644435
Created January 26, 2013 20:27
bash function to start development on a project.
startdev() {
# Try installing the requirements
# Only check this directory or the one above it
if [ -e ./requirements.txt ]; then
${VIRTUAL_ENV}/bin/pip install -r ./requirements.txt || true
elif [ -e ../requirements.txt ]; then
${VIRTUAL_ENV}/bin/pip install -r ../requirements.txt || true
fi
MANAGE=`find . -name 'manage.py'`
def getnums():
for i in range(0, 101):
print i
yield i
if 4 in getnums():
print('yes')
else:
print('no')
>>> def a(user, *args, **kwargs):
... print user
...
>>> b = {'user':'stuff'}
>>> a(**b)
stuff
@emperorcezar
emperorcezar / default.rb
Created June 12, 2012 18:47
Django-lms chef recipe
#
# Cookbook Name:: django-lms
# Recipe:: default
#
# Copyright 2012, Illinois Institute of Technology
#
# All rights reserved
packages = ["byobu",
"python-dev",
Downloading/unpacking requests==0.10.1 (from -r requirements/production.txt (line 19))
Running setup.py egg_info for package requests
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/code/mayan/venv/build/requests/setup.py", line 10, in <module>
import requests
File "requests/__init__.py", line 25, in <module>
from . import utils
File "requests/utils.py", line 257
return b"".join(L)
#
# Cookbook Name:: website
# Recipe:: default
#
# Copyright 2012, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
include_recipe "mysql"
@emperorcezar
emperorcezar / default.rb
Created February 5, 2012 21:22
Flourish gist
#
# Cookbook Name:: flourish
# Recipe:: default
#
python_virtualenv "#{node[:flourish_dir]}" do
owner "#{node[:flourish_owner]}"
group "#{node[:flourish_group]}"
action :create
end
@emperorcezar
emperorcezar / test.py
Created November 4, 2011 20:19
Test model insert
from django.contrib.auth.models import Group
group = Group.objects.all()[0]
application = IntranetApplication.objects.create(title = 'Test', groups = [group])
application.save()