Skip to content

Instantly share code, notes, and snippets.

View phpdude's full-sized avatar
🏠
Working from home

Alexandr Shurigin phpdude

🏠
Working from home
View GitHub Profile
@phpdude
phpdude / middleware.py
Last active August 29, 2015 13:56
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():
[{"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":
@phpdude
phpdude / nginx.conf
Last active February 28, 2024 04:36
Nginx image filter + caching of results.
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;
@phpdude
phpdude / middleware.py
Created December 4, 2011 14:15
Django subdomains Full support
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'