Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Alexandr Shurigin phpdude

🏠
Working from home
View GitHub Profile
@phpdude
phpdude / middleware.py
Last active Aug 29, 2015
Django user timezones
View middleware.py
from django.conf import settings
from django.utils import timezone
import pygeoip
import pytz
db_loaded = False
db = None
def load_db():
@phpdude
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
View jquery.ezPhotoUploader.js
(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
@phpdude
phpdude / jsonrequest.py
Created Oct 10, 2014
JSONRequestMiddleware
View jsonrequest.py
import json
from django.http import QueryDict
class JSONMiddleware(object):
"""
Process application/json requests data from GET and POST requests.
"""
@phpdude
phpdude / .profile
Last active Aug 29, 2015
Auto activate virtualenv & activate_env alias
View .profile
alias activate_env='ENVDIR=""; for d in *; do if [ -f $d/bin/activate ]; then ENVDIR="$d/bin/activate"; fi; done; if [ "$ENVDIR" ]; then source $ENVDIR; else echo Virtualenv dir not found; fi'
ENVDIR=""; for d in *; do if [ -f $d/bin/activate ]; then ENVDIR="$d/bin/activate"; fi; done; if [ "$ENVDIR" ]; then source $ENVDIR; fi
@phpdude
phpdude / Info.plist
Last active Aug 29, 2015
How to install Skype poll fix into skype autoload libraries
View Info.plist
<key>LSEnvironment</key>
<dict>
<key>DYLD_INSERT_LIBRARIES</key>
<string>/path/to/dylib/skype-poll-fix.dylib</string>
</dict>
@phpdude
phpdude / senfgift.sh
Created Dec 31, 2014
Send a gift in vk.com myself :)
View senfgift.sh
curl -H 'Cookie: YOUR COOKIES HERE' 'https://vk.com/al_gifts.php' -d act=do_send -d al=1 -d confirm=1 -d from=profile -d hash=$HASH_FROM_AJAX_REQUESTS -d mids=$YOUR_ID -d need_module=0 -d number=$GIFT_ID -d tab=new_year -d text= -d type=0 | iconv -f cp1251
# You can get cookie from your browser by any developer browser extension
# $HASH_FROM_AJAX_REQUESTS you can get from nay ajax request.
# $GIFT_ID - Gift ID. Can get it with developer tools from gift select box.
# $YOUR_ID - Your vk.com ID.
View pyha.ru
server {
listen 80;
server_name *.pyha.ru pyha.ru;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@phpdude
phpdude / nginx.conf
Created Apr 13, 2015
Lifehack! Nginx proxy django static files with DEBUG=True.
View nginx.conf
location /static {
root /path/to/project/;
try_files $uri @django;
}
View gulpfile.coffee Gulp + Browserify & Watchify & Externals
gulp = require 'gulp'
watchify = require 'watchify'
browserify = require 'browserify'
source = require 'vinyl-source-stream'
buffer = require 'vinyl-buffer'
gutil = require 'gulp-util'
assign = require 'lodash.assign'
rename = require 'rename'
EXTERNALS = [