Skip to content

Instantly share code, notes, and snippets.

Working from home

Alexandr Shurigin phpdude

Working from home
View GitHub Profile
phpdude /
Created Dec 4, 2011
Django subdomains Full support
Adds Django full subdomains urls upport for urlpatterns and reverse resolving.
Requires installation into
Allows you route and generate views various urls.
'' -> ''
'' -> 'doc'
phpdude / nginx.conf
Last active Nov 19, 2022
Nginx image filter + caching of results.
View nginx.conf
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;
View schools example
[{"distance": "0.14 miles", "statezip": "New York, NY 10012", "name": "St. Anthonys School", "url": "", "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": "", "grade": "9-12", "address": "131 Ave of the Americas", "type": "Public"}, {"distance": "0.17 miles", "statezip": "Manhattan, NY 10013", "name": "NYC Ischool", "url": "", "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": "", "grade":
phpdude /
Last active Aug 29, 2015
Django user timezones
from django.conf import settings
from django.utils import timezone
import pygeoip
import pytz
db_loaded = False
db = None
def load_db():
phpdude / Boot log
Last active Aug 29, 2015
Django Settings Splitter
View Boot log
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
phpdude /
Last active Oct 11, 2017
Django LocaleByDomainMiddleware - Locale By Domain Middleware
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:
phpdude /
Created Mar 9, 2014
Django Simple asynchronous email backend (Celery 3.1+)
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
phpdude / Git hook sync modification time to last commit time
Last active May 20, 2018
Git post-merge & post-checkout hook for sync changed files timestamps with last commit time (Linux, FreeBSD, Mac OS)
View Git hook sync modification time to last commit time
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 | 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.
View jquery.ezPhotoUploader.js
(function($) {
var defaults = {
'buttonTitle':'загрузить фотографию',
'limit':5, // number of files
'limitSize':4, // filesize limit in Mb
'data':null, // additional data
phpdude /
Created Oct 10, 2014
import json
from django.http import QueryDict
class JSONMiddleware(object):
Process application/json requests data from GET and POST requests.