Skip to content

Instantly share code, notes, and snippets.

View garrypolley's full-sized avatar
💭
Code and Stuff

Garry Polley garrypolley

💭
Code and Stuff
View GitHub Profile
@garrypolley
garrypolley / decorators.py
Created September 21, 2012 15:06
Django decorate 3rd party app's views
# -*- coding: utf-8 -*-
from django.conf.urls import include
def decorated_include(urls, decorator)
"""Used to decorate all urls in a 3rd party app with a specific decorator"""
urls_to_decorate = include(urls)
for url_pattern in urls_to_decorate
url_pattern._callback = decorator(url_pattern._callback)
@garrypolley
garrypolley / settings.py
Created October 18, 2012 11:37
django-pipeline settings
import os
# Our django-pipeline settings
PATH_TO_HERE = os.getcwd()
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_CSS = {
'standard': {
'source_filenames': (
@garrypolley
garrypolley / heroku_start.sh
Created October 18, 2012 11:39
get started on heroku
heroku create
heroku addons:add sendgrid:starter
heroku config:add BUILDPACK_URL=git://github.com/jiaaro/heroku-buildpack-django.git
@garrypolley
garrypolley / proc_file
Created October 18, 2012 11:43
heroku proc file
web: python manage.py collectstatic --noinput; python manage.py run_gunicorn -b 0.0.0.0:$PORT
@garrypolley
garrypolley / npm_requirements.txt
Created October 18, 2012 11:44
npm requirements file
less@1.3.0
@garrypolley
garrypolley / key_bindings.json
Last active December 10, 2015 19:08
My sublime text 2 settings
[
{ "keys": ["super+."], "command": "toggle_side_bar" },
{ "keys": ["super+shift+m"], "command": "toggle_minimap"},
{ "keys": ["super+p"], "command": "swap_case"},
{ "keys": ["super+shift+l"], "command": "lower_case" }
]
@garrypolley
garrypolley / gist:4518560
Created January 12, 2013 15:46
This is what you use to collect statics
python manage.py collectstatic --noinput
@garrypolley
garrypolley / formset.py
Created February 20, 2013 02:49
Create X number of extra formsets
def create_form_sets(number_to_make=None):
"""
Use this to make number_to_make form sets.
"""
number = number_to_make or 0
return formset_factory(MyForm,
extra=number)
@garrypolley
garrypolley / mongo_engine_settings.py
Last active December 13, 2015 23:59
sample mongoengine settings
# -*- coding: utf-8 -*-
import os
from mongoengine.connection import connect
DB_NAME = os.getenv('MONGO_DB_NAME') or'local-db'
DB_HOST = os.getenv('MONGO_DB_HOST') or 'localhost'
DB_USER = os.getenv('MONGO_DB_USER') or ''
@garrypolley
garrypolley / cbv_mro.md
Created February 23, 2013 19:14
Thoughts on how to automate creation of MRO for CBVs in Django