Skip to content

Instantly share code, notes, and snippets.

View prestontimmons's full-sized avatar

Preston Timmons prestontimmons

View GitHub Profile
@prestontimmons
prestontimmons / proposal.md
Last active August 29, 2015 14:22
Template-based widget rendering proposal

Template-based widget rendering

Goal

Enable form widgets to be rendered with user customizable template engines.

Requirements

  • Rendering should be customizable. User's should be able to use Jinja2, DTL or any custom loader they wish. It should be easily configurable.
import json
request = RequestFactory().post(
"/url/",
content_type="application/json",
data=json.dumps([1,2,3]),
)
# or
@prestontimmons
prestontimmons / README.md
Last active December 13, 2016 15:46
Gunicorn init script

Includes a reload and update command.

Reload sends a SIGHUP to the gunicorn process. This does a graceful reload if the preload option isn't set.

Update sends a SIGUSR2 which starts a new master process. It then sends a QUIT to the old process, which gracefully shuts it down after all connections are closed. This works with the preload option.

I got the idea from Benoit's comment, here:

benoitc/gunicorn#402 (comment)

@prestontimmons
prestontimmons / gist:3800756
Created September 28, 2012 16:19
Django test with test template loader
from django.template import Template
from django.test import TestCase
from django.test.client import RequestFactory
from django.test.utils import (
setup_test_template_loader,
restore_template_loaders,
override_settings,
)
class TemplateTest(TestCase):
@prestontimmons
prestontimmons / gist:3004647
Created June 27, 2012 15:02
CSS transition example
/* -- boxel --------------------------- */
.boxel {
background-color: #eee;
border-radius: 4px;
padding: 10px 0;
color: #666;
text-align: center;
-webkit-transition: background-color 0.25s linear;
-moz-transition: background-color 0.25s linear;

Install a .deb file

dpkg -i package_file.deb

Uninstall a .deb file

dpkg -r package_name
@prestontimmons
prestontimmons / gist:2638529
Created May 8, 2012 19:02
Posting data with curl

Posting data to a url

curl -d "param1=123&param2=456" http://example.com

Posting a multi-part request with a photo attachment

@prestontimmons
prestontimmons / gist:2636865
Created May 8, 2012 16:16
Convert mercurial repository to git
git clone git://repo.or.cz/fast-export.git
git init git_repo
cd git_repo
~/Desktop/fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo
git checkout HEAD
@prestontimmons
prestontimmons / gist:2636566
Created May 8, 2012 15:53
Overriding Django template loaders within tests
from django.test.utils import (
setup_test_template_loader,
restore_template_loaders,
)
class MyTest(TestCase):
def setUp(self):
setup_test_template_loader({
"basic.html": "Basic",
@prestontimmons
prestontimmons / Manifest.in
Created May 8, 2012 15:25
Minimal setup.py file
include README.md
global-include *.html
global-include *.js
global-include *.css
global-include *.json
global-include *.txt
global-include *.sql