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
Adds Django full subdomains urls upport for urlpatterns and reverse resolving. | |
Requires installation into settings.py | |
Allows you route and generate views various urls. | |
''' | |
Example: | |
'domain.com' -> '' | |
'domain.com/doc' -> 'doc' |
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
location /resize { | |
alias /tmp/nginx/resize; | |
set $width 150; | |
set $height 100; | |
set $dimens ""; | |
if ($uri ~* "^/resize_(\d+)x(\d+)/(.*)" ) { | |
set $width $1; | |
set $height $2; | |
set $image_path $3; |
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
[{"distance": "0.14 miles", "statezip": "New York, NY 10012", "name": "St. Anthonys School", "url": "http://www.greatschools.org/new-york/new-york-city/5320-St.-Anthonys-School/", "grade": "n/a", "address": "60 Mac Dougal Street", "type": "Private"}, {"distance": "0.17 miles", "statezip": "New York, NY 10013", "name": "Chelsea Career and Technical Education High School", "url": "http://www.greatschools.org/new-york/new-york-city/1948-Chelsea-Career-And-Technical-Education-High-School/", "grade": "9-12", "address": "131 Ave of the Americas", "type": "Public"}, {"distance": "0.17 miles", "statezip": "Manhattan, NY 10013", "name": "NYC Ischool", "url": "http://www.greatschools.org/new-york/manhattan/13270-NYC-Ischool/", "grade": "9-11", "address": "131 Ave of the Americas", "type": "Public"}, {"distance": "0.25 miles", "statezip": "New York, NY 10012", "name": "University Plaza Nursery School", "url": "http://pk.greatschools.org/new-york/new-york-city/preschools/University-Plaza-Nursery-School/11467/", "grade": |
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.utils import timezone | |
import pygeoip | |
import pytz | |
db_loaded = False | |
db = None | |
def load_db(): |
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
Loading project.settings submodules: env, paths, apps, assets, cache, celery, compressor, crispy, db, emails, facebook, geoip, i18n, logging, middleware, paypal, portal, security, sessions, template, urls, wsgi |
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.utils import translation | |
class LocaleByDomainMiddleware(): | |
def process_request(self, request): | |
host = request.META['HTTP_HOST'].lower() | |
locales = dict(settings.LOCALE_DOMAINS) | |
if not host in locales: |
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 celery import shared_task | |
from celery.contrib.methods import task_method | |
from django.core.mail.backends.smtp import EmailBackend as BaseEmailBackend | |
class FakeLock(object): | |
__enter__ = lambda x: None | |
__exit__ = lambda a, b, c, d: 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
Git hook post-merge and post-checkout for sync modification time to last commit time. | |
You can download scripts manually and install them yourself, or you can install it with command | |
> curl -s https://gist.githubusercontent.com/phpdude/9464925/raw/install | sh | |
This command will download post-merge script, chmod it, and create post-checkout symlink to post-merge hook. | |
You can also start this script manually with environment variable $GIT_MERGE_LIMIT=100 to updated timestamp of last 100 commits for example. |
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($) { | |
var defaults = { | |
'buttonTitle':'загрузить фотографию', | |
'url':'/ajax/upload/', | |
'urlDelete':'/ajax/delete/', | |
'filesDir':'/upload/', | |
'allowedExtensions':'jpg,jpeg,png,gif,bmp', | |
'limit':5, // number of files | |
'limitSize':4, // filesize limit in Mb | |
'data':null, // additional data |
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 json | |
from django.http import QueryDict | |
class JSONMiddleware(object): | |
""" | |
Process application/json requests data from GET and POST requests. | |
""" |
OlderNewer