Skip to content

Instantly share code, notes, and snippets.

View ilyaevseev's full-sized avatar

Ilya Evseev ilyaevseev

  • Loyaltyplant.com
  • Nazareth, Israel
  • 01:00 (UTC +03:00)
  • LinkedIn in/ilyaevseev
View GitHub Profile
@ilyaevseev
ilyaevseev / fix_nginx_port_on_startup.sh
Last active December 26, 2015 11:59
Script for restarting Django on-the-fly -- creates new instance on another port, switches nginx to it, kills old instance.
#!/bin/sh
# Should be called on system startup from /etc/rc.local
# for restoring default backend ports previously switched by restart_django.sh
fix_nginx_port() {
local nginx_config="/etc/nginx/sites-available/$1.conf"
test -w "$nginx_config" || { logger "ERROR: $nginx_config not writable."; return 1; }
local main_port="$2" backup_port="$3"
grep -q -- ":$backup_port;" $nginx_config || return
@ilyaevseev
ilyaevseev / build_primecoind.sh
Created November 5, 2013 21:05
Building and running Primecoin daemon under Ubuntu 12.10 Quantal
#!/bin/sh
debootstrap quantal /home/builder-sandbox
# Universe repo is needed for libboost-all-dev...
cp -p /etc/apt/sources.list /home/builder-sandbox/etc/apt/
mount -t proc proc /home/builder-sandbox/proc
mount -t devtmpfs udev /home/builder-sandbox/dev
mount -t sysfs sysfs /home/builder-sandbox/sys
@ilyaevseev
ilyaevseev / nginx-devel-antiddos.patch
Last active June 30, 2017 18:43
Support Anti-DDOS modules for nginx under FreeBSD.
diff -urN nginx/Makefile nginx-antiddos/Makefile
--- nginx/Makefile 2013-11-04 17:20:45.000000000 +0400
+++ nginx-antiddos/Makefile 2013-11-16 22:00:49.000000000 +0400
@@ -3,7 +3,7 @@
PORTNAME= nginx
PORTVERSION= 1.4.3
-PORTEPOCH= 1
+PORTEPOCH= 2
CATEGORIES= www
#!/usr/bin/perl
#
# rpmuncovered
#
# Display all files not owned by any package or changed after installation.
# Works on any RPM-based OS (RHEL, CentOS, SL, Fedora, SuSE, Mdk, ALTLinux, ...).
#
# Written by ilya.evseev@gmail at Nov-2013
# Distributed as public domain.
#_______________________________________________________________
@ilyaevseev
ilyaevseev / google-drive-fs-autopassword.patch
Created December 14, 2013 20:20
Batch mode for google-drive-fs
--- gFile.py.orig 2011-10-16 08:36:48.000000000 +0400
+++ gFile.py 2013-12-15 00:17:59.052546863 +0400
@@ -539,7 +539,7 @@
usage = """Google Docs FS: Mounts Google Docs files on a local
filesystem gFile.py email password mountpoint""" + fuse.Fuse.fusage
- passwd = None
+ passwd = os.getenv('GOOGLE_DRIVE_PASSWORD', False)
while not passwd:
passwd = getpass.getpass()
@ilyaevseev
ilyaevseev / mysqldump2databases.pl
Last active January 3, 2016 09:19
Split mysqldump to separate databases or tables
#!/usr/bin/perl
use strict;
use warnings;
my $filenum = 0;
my $fd;
while(<>) {
if (/^-- Current Database: /) {
@ilyaevseev
ilyaevseev / fixeth0.sh
Last active January 4, 2016 20:49
Under Linux, changing a NIC macaddress causes creation of empty eth1 and failure of all eth0-related settings. This init script renames eth1 back to eth0. Works under Redhat/CentOS.
#!/bin/sh
#
# fixeth0 Rebind NIC from eth1 to eth0
#
# chkconfig: 2345 09 91
# description: After changing single NIC, automatically rebind it from eth1 back to eth0.
### BEGIN INIT INFO
# Provides: fixeth0
# Required-Start: $local_fs
@ilyaevseev
ilyaevseev / deb2diffs.sh
Last active August 29, 2015 13:56
For given deb-package, creates list of changed files and line-by-line diff.
#!/bin/sh
Install_me_so='
apt-get install debsums
wget -O /usr/local/bin/deb2diffs https://gist.github.com/ilyaevseev/8818910/raw/67677ef6324554f51aea390e39597ad97140d3de/deb2diffs.sh
chmod +x /usr/local/bin/deb2diffs
'
#set -x
Fail() { echo "$@" 1>&2; exit 1; }
--- sphinxapi.php.orig 2013-07-02 00:55:44.000000000 +0200
+++ sphinxapi.php 2014-03-21 11:52:10.000000000 +0100
@@ -847,2 +847,2 @@
- assert ( is_float($min) );
- assert ( is_float($max) );
+ assert ( is_float($min) || is_numeric($min) );
+ assert ( is_float($max) || is_numeric($max) );
@ilyaevseev
ilyaevseev / pingcsv2stat.pl
Last active August 29, 2015 13:58
Find connectivity failures in collectd reports.
#!/usr/bin/perl
use strict;
use warnings;
my $MIN_DELTA = 120;
my $nan;
my $last_good;