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
from __future__ import absolute_import
import logging
import celery
from django.conf import settings
class NoHardTimeoutFilter(logging.Filter):
def filter(self, record):
data = sorted(data)
times = {}
for single in data:
try:
times[single] += 1
except KeyError:
times[single] = 1
@emperorcezar
emperorcezar / jquery-pcollapse.js
Created December 14, 2010 20:16
This is a small jquery plugin that allows a div that partially collapses
(function( $ ){
$.fn.pCollapse = function( options ) {
var settings = {
'start': '100px',
};
// there's no need to do $(this) because
// "this" is already a jquery object
// $(this) would be the same as $($('#element'));
@emperorcezar
emperorcezar / tests.py
Created March 31, 2011 19:43
Authenticated Test
class AuthenticatedTest(unittest.TestCase):
def setUp(self):
self.c = Client()
# create login
user = User(username = 'test', password = 'test123', first_name = 'Test', last_name = 'McTesterson', email = 'test@test.com')
user.save()
# login
response = self.c.post('/accounts/login/', {'username': 'test', 'password': 'test123'})
@emperorcezar
emperorcezar / jquery.LImenuPadding.js
Created June 15, 2011 16:07
Small plugin that justifies a menu using jquery
/*
Tested with http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js
in FF Mac, Safari Mac, Chrome Mac, Opera Mac, FF PC, IE 7 and 8, IE 6 works with css hack on LIs _width:3px;
Requirements: Menu structure has to be <ul><li><a...
<ul> must have a class or id
*/
/* PAD LIs EVENLY */
(function($){
$.fn.limenupadding = function(options) {
@emperorcezar
emperorcezar / start_project.sh
Created June 15, 2011 22:49
Quick start project script
#!/bin/bash
virtualenv --no-site-packages "$1"
cd "$1"
source bin/activate
git clone 'git://github.com/zacharyvoase/django-zskel-project.git' "$1"
mkdir db
cd "$1"
find . -name '.empty' -exec rm {} \;
git config --unset remote.origin.url
@emperorcezar
emperorcezar / gplaces.py
Created June 17, 2011 12:17
Quick library for Google Place API
import urllib2
import simplejson
class GPlaces(object):
def __init__(self, key):
self.key = key
self.search_url = "https://maps.googleapis.com/maps/api/place/search/json"
def search(self, location, radius, sensor, **kwargs):
# Build the url
@emperorcezar
emperorcezar / django_utils.py
Created June 23, 2011 19:54
Pass the request every time
from django.shortcuts import render_to_response as render
from django.template import RequestContext
from django.conf import settings
def render_to_response(*args, **kwargs):
kwargs['context_instance'] = RequestContext(args[1]['request'])
return render(*args, **kwargs)
@emperorcezar
emperorcezar / gist:1165287
Created August 23, 2011 14:34
Turns on mouse scrolling and interaction using iterm2 (and others).
;; turn on mouse wheel scrolling
(defun sd-mousewheel-scroll-up (event)
"Scroll window under mouse up by five lines."
(interactive "e")
(let ((current-window (selected-window)))
(unwind-protect
(progn
(select-window (posn-window (event-start event)))
(scroll-up 2))
(select-window current-window))))
@emperorcezar
emperorcezar / gist:1168034
Created August 24, 2011 13:20 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job:
Web Developer for the IIT Institute of Design
Favorite Python project:
Pip. I love what it and Virtualenv have done for my development in Django.
Favorite Conference: