Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Alexandr Shurigin phpdude

🏠
Working from home
View GitHub Profile
@phpdude
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
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'
services:
db:
restart: always
image: postgres
environment:
- POSTGRES_USER=project
- POSTGRES_PASSWORD=project
volumes:
@phpdude
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 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 / 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: [
"apib"
]
foldingStartMarker: '''
(?x)
(<(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|form|dl)\\b.*?>
|<!--(?!.*-->)
|\\{\\s*($|\\?>\\s*$|//|/\\*(.*\\*/\\s*$|(?!.*?\\*/)))
)
'''
@phpdude
phpdude / asyncemail.py
Created Mar 9, 2014
Django Simple asynchronous email backend (Celery 3.1+)
View asyncemail.py
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 Oct 11, 2017
Django LocaleByDomainMiddleware - Locale By Domain Middleware
View middleware.py
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:
View download.py
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
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
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
GcsManager
Robot
WitInterface
WitResponse
XmppReporter
cjson
cloudsql
cloudsql.beans
cloudsql.dao
cloudsql.dao.dialogdao
@phpdude
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).