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
# -*- coding: utf-8 -*- | |
# REQUIRES pillow-simd or pillow | |
from __future__ import absolute_import, division, print_function, unicode_literals | |
# import cProfile | |
# import cStringIO | |
import datetime | |
import itertools | |
import os | |
# import pstats |
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
function encodeJSONURIComponent(obj) { | |
return btoa(encodeURIComponent(JSON.stringify(obj))).replace('+', '-').replace('/', '_').replace(/=+$/, ''); | |
} | |
function decodeJSONURIComponent(str) { | |
return JSON.parse(decodeURIComponent(atob(str.replace('-', '+').replace('_', '/')))); | |
} |
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
# -*- coding: utf-8 -*- | |
from __future__ import absolute_import, division, print_function, unicode_literals | |
import sys | |
from django.http import Http404 | |
from django.views.debug import technical_500_response | |
class SuperuserTechnical500Middleware(object): |
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 __future__ import absolute_import, division, print_function, unicode_literals | |
from collections import namedtuple | |
from itertools import chain | |
class Rule(namedtuple('Rule', ['lhs', 'rhs'])): | |
def __new__(cls, lhs, rhs): | |
return super(Rule, cls).__new__(cls, lhs, tuple(rhs)) # ensure hashable |
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 __future__ import absolute_import, division, print_function, unicode_literals | |
import re | |
from django.utils import six | |
from django.utils.functional import lazy, SimpleLazyObject | |
from django.utils.translation import ugettext | |
URL_SLUG_RE = SimpleLazyObject(lambda: re.compile(r'^[a-zA-Z0-9\-]+$')) |
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
# -*- coding: utf-8 -*- | |
from __future__ import (absolute_import, division, print_function, | |
unicode_literals) | |
import re | |
import unittest | |
from collections import namedtuple | |
class TokenError(Exception): |
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 __future__ import absolute_import, division, print_function, unicode_literals | |
from collections import OrderedDict | |
def flatten_xml(node): | |
""" | |
Produce an ordered dictionary of elements enountered. | |
Keys are valid xpath selectors. |
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 __future__ import absolute_import, division, print_function, unicode_literals | |
from django import template | |
from django.template.loader_tags import BlockNode, ExtendsNode | |
register = template.Library() | |
@register.simple_tag(takes_context=True) |
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
""" | |
Install via: | |
from __future__ import absolute_import, division, print_function, unicode_literals | |
from wagtail.wagtailcore import hooks | |
from wagtail.wagtailimages.models import Filter | |
from .crop import CropOperation |
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 __future__ import absolute_import, division, print_function, unicode_literals | |
import six | |
from django.contrib.gis.geos import Point | |
from haystack import indexes | |
from haystack.exceptions import SpatialError | |
from haystack.utils.geo import ensure_geometry, ensure_point | |