This file contains hidden or 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.template.defaultfilters import slugify as django_slugify | |
class MyModel(models.Model): | |
def save(*args, **kwargs): | |
# Build our slug from the name, keeping it short for | |
# linkability, but still guarantee uniqueness | |
if not self.pk and self.slug: | |
self.slug = self.slugify(self.slug) |
This file contains hidden or 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
sudo curl "http://phildawson.co.uk/ssh-copy-id" -o /usr/bin/ssh-copy-id | |
sudo chmod +x /usr/bin/ssh-copy-id |
This file contains hidden or 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
""" | |
Decrease the verbosity of writing view tests. | |
Old way: | |
self.client.get(reverse("my-view")) | |
self.client.post(reverse("my-view"), data={"key": "value"}) | |
self.client.login("username", "password") | |
self.client.get(reverse("my-other-view")) | |
self.client.logout() |
This file contains hidden or 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
# http://distributedaweso.me/past/2011/5/4/pip_workaround_for_no_ppc_support_in_xcode4/ | |
ARCHFLAGS="-arch i386 -arch x86_64" pip install fabric | |
This file contains hidden or 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
#! /bin/bash | |
# /etc/init.d/uwsgi | |
# | |
daemon=/path/to/uwsgi | |
pid=/path/to/uwsgi.pid | |
args="-x /path/to/uwsgi.xml" | |
# Carry out specific functions when asked to by the system | |
case "$1" in |
This file contains hidden or 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
pip install https://vnvault.trustcommerce.com/downloads/tclink-3.4.4-python.tar.gz | |
Docs: | |
https://vnvault.trustcommerce.com/downloads/TC_Developers_Guide_v4.0.pdf |
This file contains hidden or 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
UTF8 := $(shell locale -c LC_CTYPE -k | grep -q charmap.*UTF-8 && echo -utf8) | |
SERIAL=0 | |
.PHONY: usage | |
.SUFFIXES: .key .csr .crt .pem | |
.PRECIOUS: %.key %.csr %.crt %.pem | |
usage: | |
@echo "This makefile allows you to create:" | |
@echo " o public/private key pairs" |
This file contains hidden or 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
find /my/directory/ -type d -exec chmod 755 {} \; |
This file contains hidden or 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 functools import wraps | |
from json import dumps | |
from django.http import HttpResponse | |
def json_view(view_func): | |
@wraps(view_func) | |
def inner(request, *args, **kwargs): | |
response = view_func(request, *args, **kwargs) | |
if request.GET.get("format") == "json" and hasattr(response, "context_data"): |
This file contains hidden or 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
""" Usage: python grid.py > grid.css """ | |
MAX = 960 | |
COL = 10 | |
rules = [] | |
rules.append(".column { float: left; min-height: 1px; }") | |
for x in range(COL, MAX + COL, COL): | |
rules.append(".column-%s { width: %spx; }" % (x, x)) |