Skip to content

Instantly share code, notes, and snippets.

@ilyaevseev
ilyaevseev / fix_nginx_port_on_startup.sh
Last active Dec 26, 2015
Script for restarting Django on-the-fly -- creates new instance on another port, switches nginx to it, kills old instance.
View fix_nginx_port_on_startup.sh
#!/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 Nov 5, 2013
Building and running Primecoin daemon under Ubuntu 12.10 Quantal
View build_primecoind.sh
#!/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 Jun 30, 2017
Support Anti-DDOS modules for nginx under FreeBSD.
View nginx-devel-antiddos.patch
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
View rpmuncovered.pl
#!/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.
#_______________________________________________________________
View google-drive-fs-autopassword.patch
--- 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 Jan 3, 2016
Split mysqldump to separate databases or tables
View mysqldump2databases.pl
#!/usr/bin/perl
use strict;
use warnings;
my $filenum = 0;
my $fd;
while(<>) {
if (/^-- Current Database: /) {
@ilyaevseev
ilyaevseev / fixeth0.sh
Last active Jan 4, 2016
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.
View fixeth0.sh
#!/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 Aug 29, 2015
For given deb-package, creates list of changed files and line-by-line diff.
View deb2diffs.sh
#!/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; }
View sphinxapi.php-SetFilterFloatRange.diff
--- 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 Aug 29, 2015
Find connectivity failures in collectd reports.
View pingcsv2stat.pl
#!/usr/bin/perl
use strict;
use warnings;
my $MIN_DELTA = 120;
my $nan;
my $last_good;