This file contains 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
import time | |
import inspect | |
from redis.exceptions import ResponseError | |
class MockRedis(object): | |
def __init__(self, database=None): | |
self.database = database or {} | |
def _set(self, key, value, ttl=None): | |
self.database[key] = (value, time.time(), ttl) |
This file contains 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
""" | |
An abstract syntax tree visitor for building control flow graphs for ECMAScript | |
programs and functions. | |
""" | |
from bigrig.visitor import NodeVisitor | |
from bigrig.node import Node | |
from bigrig import ast | |
from .graph import Digraph |
This file contains 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.core.management.commands.runserver import BaseRunserverCommand | |
from django.conf import settings | |
from dozer import Dozer | |
class Command(BaseRunserverCommand): | |
def get_handler(self, *args, **options): | |
""" | |
Returns the normal handler wrapped in a warm Dozer embrace. | |
""" |
This file contains 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_filters.filterset import FilterSet, FilterSetMetaclass | |
def filterset_factory(model, filterset=FilterSet, fields=None, exclude=None, | |
filter_for_field=None): | |
""" | |
Build a ``FilterSet`` class for a specified model with the specified | |
options. | |
""" | |
attrs = {'model': model} | |
if fields is not None: |
This file contains 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
try: | |
from cStringIO import StringIO | |
except ImportError: | |
from StringIO import StringIO | |
import datetime | |
import decimal | |
from django.core.serializers.python import Serializer as PythonSerializer | |
from django.core.serializers.json import DjangoJSONEncoder | |
from django.utils.encoding import is_protected_type, smart_unicode |
This file contains 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 import template | |
register = template.Library() | |
TOKEN_PAIRS = { | |
template.TOKEN_VAR: (template.VARIABLE_TAG_START, template.VARIABLE_TAG_END), | |
template.TOKEN_BLOCK: (template.BLOCK_TAG_START, template.BLOCK_TAG_END), | |
template.TOKEN_COMMENT: (template.COMMENT_TAG_START, template.COMMENT_TAG_END), | |
} |
This file contains 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 import template | |
from django.conf import settings | |
if settings.USE_I18N: | |
from django.utils.translation.trans_real import translation | |
def get_translation(msgid, lang): | |
t = translation(lang) | |
return t.gettext(msgid) | |
else: | |
def get_translation(msgid, lang): |
This file contains 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
{% comment %} | |
Include this template from your site base template like so: | |
{% if user.is_anonymous %} | |
{% include "login_form.html" %} | |
{% endif %} | |
{% endcomment %} | |
{% load i18n %} |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Oh snap!</title> | |
<style> | |
* { | |
font: 1em monospace; | |
} | |
</style> | |
</head> |