Skip to content

Instantly share code, notes, and snippets.

Working from home

Alexandr Shurigin phpdude

Working from home
View GitHub Profile
phpdude / example.js
Last active Jun 9, 2018
PhantomJS: hellper for writing scripts waiting full page load (DOMContentLoaded event)
View example.js
var system = require("system");
var url = system.args[1];
require('./phantom-full-load')(phantom, url, function (page, logs) {
logs.forEach(function (i) {
console.log('> ' + i);
result = page.evaluate(function () {
return $('body *').attr('class');
phpdude / docker-compose.yml
Created Mar 9, 2016
Docker Composer Django \w NGINX \w uWSG \w PostgreSQL In Production
View docker-compose.yml
version: '2'
restart: always
image: postgres
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.
phpdude / apiblueprint.cson
Created Mar 1, 2018
API Blueprint fix for syntax highlighting in Request and extra coloring for better reading documentation files (~/.atom/packages/language-api-blueprint/grammars/apiblueprint.cson)
View apiblueprint.cson
fileTypes: [
foldingStartMarker: '''
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 /
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:
import os
import sys
import requests
import re
from json import loads
from HTMLParser import HTMLParser
import shutil
from lxml.html import fromstring
from time import sleep
phpdude / pre-commit
Created Apr 6, 2016 — forked from wolfhechel/pre-commit
Auto add Django migrations before commit
View pre-commit
find . -type d -name migrations -not -exec git check-ignore -q {} \; -exec git add {} \;
phpdude / Result.example.log
Last active Mar 17, 2016
Find used python packages list needed to be installed (or used in requirements.txt)
View Result.example.log
phpdude / wkhtmltopdf.tablesplit.js
Created Jan 17, 2016 — forked from niflostancu/wkhtmltopdf.tablesplit.js
WkHtmlToPdf Table Splitting Hack
View wkhtmltopdf.tablesplit.js
* WkHtmlToPdf table splitting hack.
* Script to automatically split multiple-pages-spanning HTML tables for PDF
* generation using webkit.
* To use, you must adjust pdfPage object's contents to reflect your PDF's
* page format.
* The tables you want to be automatically splitted when the page ends must
* have a class name of "splitForPrint" (can be changed).