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():
@phpdude
phpdude / Boot log
Last active August 29, 2015 13:56
Django Settings Splitter
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
phpdude / jquery.ezPhotoUploader.js
Created September 1, 2014 15:52
@md5 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 October 10, 2014 20:24
JSONRequestMiddleware
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 August 29, 2015 14:10
Auto activate virtualenv & activate_env alias
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 August 29, 2015 14:10
How to install Skype poll fix into skype autoload libraries
<key>LSEnvironment</key>
<dict>
<key>DYLD_INSERT_LIBRARIES</key>
<string>/path/to/dylib/skype-poll-fix.dylib</string>
</dict>
@phpdude
phpdude / senfgift.sh
Created December 31, 2014 20:29
Send a gift in vk.com myself :)
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.
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 April 13, 2015 01:38
Lifehack! Nginx proxy django static files with DEBUG=True.
location /static {
root /path/to/project/;
try_files $uri @django;
}
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 = [