Skip to content

Instantly share code, notes, and snippets.

View AlekseyKorzun's full-sized avatar
🤠
Doing it live

Aleksey Korzun AlekseyKorzun

🤠
Doing it live
View GitHub Profile
@AlekseyKorzun
AlekseyKorzun / tabstospaces
Created February 14, 2013 17:11
Convert all tabs to spaces within PHP files
find . -name *.php ! -type d ! -name _tmp_ -exec sh -c 'expand -t 4 {} > _tmp_ && mv _tmp_ {}' \;
@AlekseyKorzun
AlekseyKorzun / gist:6099219
Last active February 2, 2021 11:23
Pre-commit hook that supports PHPCS and PHPDOC
#!/bin/bash
################################################################
# Pre commit hook for git
#
# @package: utilities
# @subpackage: utilities\git
# @author: Aleksey Korzun <al.ko@webfoundation.net>
################################################################
@AlekseyKorzun
AlekseyKorzun / gist:6444589
Created September 5, 2013 00:33
Proof of concept, segmentation fault (spl_array.c/igbinary.c) when using nested objects.
<?php
/**
* Proof of concept, segmentation fault (spl_array.c/igbinary.c)
* when using nested objects.
*
* PHP 5.3.6, PECL-Memcached 1.x, Igbinary 1.x
*
* @author Aleksey Korzun
*/
@AlekseyKorzun
AlekseyKorzun / gist:9898360
Created March 31, 2014 18:03
Delete local/remove git branches
; Upstream
git branch | grep -v "master" | xargs git push origin --delete
; Local
git branch | grep -v "master" | xargs git branch -D
@AlekseyKorzun
AlekseyKorzun / gist:9901938
Last active August 29, 2015 13:57
Automaticly purge build tags that were cut by Jenkins
# Purge old tags
tag_limit=8
tag_current=`git tag -n |grep -i "jenkins-${JOB_NAME}" | wc -l`
if [ $tag_limit -lt $tag_current ]; then
tag_difference=`expr $tag_current - $tag_limit `
git tag |grep -i "jenkins-${JOB_NAME}" | head -$tag_difference | xargs git push --delete origin
git tag |grep -i "jenkins-${JOB_NAME}" | head -$tag_difference | xargs git tag -d
fi
# Create tag
@AlekseyKorzun
AlekseyKorzun / gist:9901982
Last active August 29, 2015 13:57
MySQL replication monitoring script
#!/bin/bash
#
# Author: Aleksey Korzun
email='alert@domain.com'
default_max=60
echo "=========================================================================="
echo " Replicator Man v1.0.2 "
echo "=========================================================================="
@AlekseyKorzun
AlekseyKorzun / gist:8e75021a4d045c9420a5
Created May 28, 2014 21:23
Magento Data Segmentator
#!/bin/bash
#
# Author: Aleksey Korzun
echo "=========================================================================="
echo " Magento Data Segmentator v1.0.1 "
echo "=========================================================================="
help() {
echo "Usage: -s schema [-f filename] [-e '(baublebar.com|aleksey.v.korzun@gmail.com)'] [-d 7] [-l 1000] [-r 1]" 1>&2;
Credit to Paul Moore / @Paul_Reviews:
1. Navigate to http://www.roboform.com/have-i-been-hacked
2. Replace 'Enter account to test' with following: <script type="text/javascript">$('img').attr('src', 'https://lastpass.com/images/lastpass-logo.png');</script>
3. Click on 'Check Now'
In action:
http://g.recordit.co/oBk26XEv0P.gif
@AlekseyKorzun
AlekseyKorzun / lighttpd-lua-example
Last active October 24, 2015 15:41
Static bandwidth limiting and blacklisting with Lighttpd + Lua
# Lighttpd
$HTTP["referer"] !~ "^($|http://([^/]*\.)?imagesocket\.(com|net|org)/)" {
magnet.attract-physical-path-to = ("/www/sites/conf/imagesocket/bandwidth.lua")
}
# Lua check for images that exceeded limit(S)
# Path - Flag - Expiration
local url_check =
{
["/images/2012/08/20/1.png"] = true, -- 1352167206
@AlekseyKorzun
AlekseyKorzun / update-pingdom-iptables-centos.sh
Last active October 28, 2015 18:08 — forked from mickm/update-pingdom-iptables.sh
Whitelist Pingdom probe-servers in iptables on CentOS.
#!/bin/bash
#
# Whitelist Pingdom probe-servers in iptables.
#
# Create a chain called "PINGDOM" and jump to it somewhere before
# the final REJECT/DROP, e.g.
#
# # New chain for Pingdom rules
# :PINGDOM - [0:0]
#