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 / .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 = [
@phpdude
phpdude / gavnocode.php
Last active August 29, 2015 14:26
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;
@phpdude
phpdude / example.js
Last active June 9, 2018 20:14
PhantomJS: hellper for writing scripts waiting full page load (DOMContentLoaded event)
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 / validate_email.py
Created November 9, 2015 22:28
Validate Email Address in Python (part of django framework)
import re
class ValidationError(ValueError):
def __init__(self, message, code=None):
super(ValidationError, self).__init__(message)
self.code = code
def __str__(self):
@phpdude
phpdude / delete-reposts.js
Last active November 18, 2015 18:32
Delete reposts from vk.com profile wall.
setInterval(function () {
var x = $('.post_copy .post_delete_button');
if(x)
{
x.click();
x.remove();
}
}, 500);
setInterval(function() {