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
# Example Usage | |
from .settings_s3 import * |
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.contrib import admin | |
from django.db.models import Q | |
from filer.admin import FolderAdmin | |
from filer.models import Folder | |
class CustomUserModelFilerAdmin(FolderAdmin): | |
@staticmethod | |
def filter_folder(qs, terms=[]): |
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
class View(object): | |
# ... | |
def __init__(self, request, args, kwargs): | |
self.request = request | |
self.args = args | |
self.kwargs = kwargs | |
@classonlymethod | |
def as_view(cls, **initkwargs): | |
""" |
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
2013-08-07 08:36 enabled | |
2013-08-07 08:36 12,992 | |
2013-08-07 08:36 16,836 | |
2013-08-07 08:37 19,888 | |
2013-08-07 08:37 22,680 | |
2013-08-07 08:39 24,556 | |
2013-08-07 10:07 188,036 | |
2013-08-07 10:12 195,804 | |
2013-08-07 10:34 225,264 | |
2013-08-07 11:18 297,664 |
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
#!/usr/bin/env python | |
""" | |
A command to check redirects. | |
Expects stdin in to look like this: | |
http://example.com/old-url,http://example.com/new-url | |
Outputs to stderr: |
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
{ | |
"Statement":[ | |
{ | |
"Effect":"Allow", | |
"Action":[ | |
"s3:ListAllMyBuckets" | |
], | |
"Resource":"arn:aws:s3:::*" | |
}, |
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 re | |
from django import template | |
register = template.Library() | |
leading_whitespace_re = re.compile(r'^\s+', flags=re.MULTILINE) | |
@register.tag(name='dedent') | |
def do_dedent(parser, token): |
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.conf import settings | |
from django.core.serializers import serialize | |
def backupmodel(model_class): | |
""" | |
Takes a model class and backs up all of the rows in a JSON file. | |
""" | |
log.info("Backing up %s", model_class) |
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.template import Template, Context | |
>>> Template('{{ foo|default:bar|default:"test" }}').render(Context({'bar': 1})) | |
u'1' | |
>>> Template('{{ foo|default:bar.baz|default:"test" }}').render(Context({'bar': 1})) | |
Traceback (most recent call last): | |
File "<input>", line 1, in <module> | |
File "/XXX/site-packages/django/template/base.py", line 140, in render | |
return self._render(context) | |
File "/XXX/site-packages/django/template/base.py", line 134, in _render | |
return self.nodelist.render(context) |
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
\usepackage{xspace} | |
\newcommand\bs{{\textbackslash}\xspace} | |
%% in content later on | |
``Look at her, a prisoner of the gutter \bs condemned by every syllable she utters'' |