Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Alexandr Shurigin phpdude

🏠
Working from home
View GitHub Profile
@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 / 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 / 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).
@phpdude
phpdude / delete-reposts.js
Last active Nov 18, 2015
Delete reposts from vk.com profile wall.
View delete-reposts.js
setInterval(function () {
var x = $('.post_copy .post_delete_button');
if(x)
{
x.click();
x.remove();
}
}, 500);
setInterval(function() {
@phpdude
phpdude / validate_email.py
Created Nov 9, 2015
Validate Email Address in Python (part of django framework)
View validate_email.py
import re
class ValidationError(ValueError):
def __init__(self, message, code=None):
super(ValidationError, self).__init__(message)
self.code = code
def __str__(self):
@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 / gavnocode.php
Last active Aug 29, 2015
gavnocode.php
View gavnocode.php
<?php
$query = $db->query("SELECT * FROM refer GROUP BY keyword ORDER BY date DESC LIMIT 0,10");
while($row = $db->get_row($query)){
preg_match_all('/([0-9]{4})\/([0-9]{2})\/([0-9]{2})\/(.+?).html/', $row['url'], $request_out);
$first = mb_substr($row['keyword'],0,1); // первая буква
$last = mb_substr($row['keyword'],1); // все кроме первой буквы
$first = mb_strtoupper($first);
$last = mb_strtolower($last);
$keyword = $first.$last;
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 = [
@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;
}