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
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
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" }}
{% 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 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
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',
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).\
@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
<html>
<head>
<script type="text/javascript">;
function mainLoop(){
ctx.clearRect(0,0,500,410);
playerPaddle.shape()
enemyPaddle.shape()
ball1.drawBall()
Jquick7490MLA:force jquick$ mkvirtualenv force
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.5.1', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.6/site-packages/virtualenv.py", line 558, in main
prompt=options.prompt)
File "/Library/Python/2.6/site-packages/virtualenv.py", line 647, in create_environment
site_packages=site_packages, clear=clear))
File "/Library/Python/2.6/site-packages/virtualenv.py", line 771, in install_python
copy_required_modules(home_dir)
@justquick
justquick / fabfile.py
Created May 9, 2011 01:33
Simple fabfile to deploy my django projects on a gunicorn + nginx setup
import os
import sys
from fabric.api import abort, run, sudo, env, cd
from fabric.colors import red, green
from fabric.contrib.files import exists, put, upload_template
ROOT = '/home/jquick/code/'
WORKON = '/home/jquick/.virtualenvs'
VENVS = {