Skip to content

Instantly share code, notes, and snippets.

View justquick's full-sized avatar
⚙️
Contemplating the Infinite

Justin Quick justquick

⚙️
Contemplating the Infinite
View GitHub Profile
@justquick
justquick / fabfile.py
Created October 11, 2010 18:58
Ubuntu update manager for Fabric. Checks for updates, installs them and reboots if needed across multiple servers
"""
Ubuntu update manager for Fabric
Checks for updates, installs them and reboots if needed across multiple servers
Create a "hosts" file alongside this fabfile and put your hosts in there one per line
Updating package list::
fab update
from django.conf import settings
from django.db.models import get_models, FileField
from django.core.files.storage import get_storage_class
STORAGE = get_storage_class(getattr(settings, "STORAGE", settings.DEFAULT_FILE_STORAGE))
for model in get_models():
for field in model._meta.fields:
if isinstance(field, FileField) and not isinstance(field.storage, STORAGE):
FileField(verbose_name=field.verbose_name, upload_to=field.upload_to, name=field.name).\
NATIVE_LIBRARY = {
'function':{ 'add': lambda x, y: x + y },
'comparison':{ 'is_in': lambda x, y: x in y },
...
}
NATIVE_TAGS = (
'native_tags.contrib.hash',
'native_tags.contrib.serializers',
def do_add(x, y):
return x + y
do_add.function = True
do_add.name = 'add'
{% add 1 9 as ten %}
1 + 9 = {{ ten }}
def less(x, y):
return x < y
{% ifnotequal blog.slug "belief-blog" %}
{% ifnotequal blog.slug "bellantoni" %}
{% ifnotequal blog.slug "billups" %}
{% ifnotequal blog.slug "blog-rings" %}
{% ifnotequal blog.slug "chatter" %}
{% ifnotequal blog.slug "d1scourse" %}
{% ifnotequal blog.slug "dinan" %}
{% ifnotequal blog.slug "fishwrap" %}
{% ifnotequal blog.slug "in-the-room" %}
def format_time(date_to_be_formatted, format_string):
return date_to_be_formatted.strftime(format_string)
format_time.function = True
format_time.filter = True
{% format_time entry.pub_date "%a, %d %b %Y" as pub_date %}
{{ entry.pub_date|format_time:"%a, %d %b %Y" }}
from django import template
register = template.Library()
class FormatTimeNode(template.Node):
def __init__(self, date_to_be_formatted, format_string):
self.date_to_be_formatted = template.Variable(date_to_be_formatted)
self.format_string = format_string
Environment:
Request Method: POST
Request URL: http://comstage.washingtontimes.com/admin/blog/entry/add/
Django Version: 1.2.1
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
Environment:
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.1.1
Python Version: 2.6.1
Installed Applications:
['south',
'wpf',
'nggm.cacheplus',
...
install_dir /Users/jquick/Projects/Python/wpf/develop-eggs/tmpBVv0pebuild
Generated script '/Users/jquick/Projects/Python/wpf/bin/project-content'.
Generated script '/Users/jquick/Projects/Python/wpf/bin/project-content.wsgi'.
Generated script '/Users/jquick/Projects/Python/wpf/bin/project-content.fcgi'.
Installing docs-epydoc.
Generated script '/Users/jquick/Projects/Python/wpf/bin/docs-epydoc'.
Installing docs-sphinx.
Getting distribution for 'Sphinx'.
Got Sphinx 0.6.3.