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
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 / 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.
@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 / .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 / 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 / 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 / Git hook sync modification time to last commit time
Last active May 20, 2018 23:56
Git post-merge & post-checkout hook for sync changed files timestamps with last commit time (Linux, FreeBSD, Mac OS)
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.
@phpdude
phpdude / asyncemail.py
Created March 9, 2014 14:54
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
phpdude / middleware.py
Last active October 11, 2017 13:50
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
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