Skip to content

Instantly share code, notes, and snippets.

@overplumbum
overplumbum / video-from-frames.sh
Last active September 27, 2015 04:08
Video clip from frames generation
## Windows: http://en.cze.cz/Images-to-video
## MacOSX & Linux below
clipdir=/tmp/clip/
rm -fr $clipdir && mkdir $clipdir
# crop&resize 3x4 frames to 16x9 1280x720
for i in *.JPG ; do convert -verbose $i -strip -resample 72x72 -crop x1386+0+100 -resize 1280x $clipdir/$i ; done
#:> cmds.lst && for i in *.JPG ; do echo convert -verbose $i -strip -resample 72x72 -crop x1386+0+100 -resize 1280x $clipdir/$i >> cmds.lst ; done
@overplumbum
overplumbum / gist:1237114
Last active December 6, 2022 12:46
PostgreSQL tables sizes with related TOAST tables
SELECT E'{| border=1 cellspacing=0 cellpadding=5\n|+\n|тип || relation || size || чей toast || mantainer || планы\n|-\n' || array_to_string(ARRAY(
SELECT '|' || C.relkind ||
'||' || nspname || '.' || C.relname ||
'||' || pg_size_pretty(pg_relation_size(C.oid)) ||
'||' || COALESCE(T.relname, '-') ||
'||' || '/author/' ||
'||' || '/wtf?/' || E'\n|-'
/*SELECT C.relkind, nspname || '.' || C.relname AS "relation",
@overplumbum
overplumbum / gist:1349878
Created November 9, 2011 00:36
Pg Table Sync
-- DROP FUNCTION table_sync(regclass, regclass);
CREATE OR REPLACE FUNCTION table_sync(in_source regclass, in_destination regclass)
RETURNS void AS
$BODY$DECLARE
_pk name[];
_data name[];
_all name[];
_pk_ident text;
@overplumbum
overplumbum / gist:2284823
Created April 2, 2012 16:32
phppgadmin hosts
diff --git a/database.php b/database.php
index 95cdf2b..de5ef19 100755
--- a/database.php
+++ b/database.php
@@ -400,6 +400,27 @@
echo "</div>";
}
+
+ function clientResolve($addr) {
@overplumbum
overplumbum / netgear_status.py
Created April 10, 2012 11:12
NetGear WiFi Router Monitoring
#!/usr/bin/env python
import urllib2, argparse
parser = argparse.ArgumentParser()
parser.add_argument('-H', required=True)
parser.add_argument('-U', default='admin')
parser.add_argument('-P', default='password')
args = parser.parse_args()
fields = "an_rxbs an_txbs bgn_rxbs bgn_txbs lan_rxbs lan_txbs".split(' ')
@overplumbum
overplumbum / gist:2764300
Created May 21, 2012 19:58
URL average speed by hour from nginx access log
zcat /var/log/nginx/prod.*.access.log-2012051[567].gz | grep autocomplete | perl -nle 'm|(\d+)/.../....:(\d+):.* "([0-9.]+)" "ostrovok.ru" "ajax"| and print "$1$2 $3"' | awk '{a[$1]++;b[$1]=b[$1]+$2}END{for (i in a) printf("%s\t%10.2f\n", i, b[i]/a[i])} ' | sort
@overplumbum
overplumbum / gist:2965503
Created June 21, 2012 12:34
Per Process Group memory usage
ps auxw | awk '{ g[$11 " " $12] += $6 } END { for (i in g) { print g[i] "\t" i }}' | sort -bgr
@overplumbum
overplumbum / gist:3037065
Created July 3, 2012 02:05
max fd count per process and per user
for f in /proc/*/fd/ ; do ls -U1 $f | wc -l ; done | sort -gr | head -n1
lsof | awk '{ a[$3]++ } END { for(i in a) print a[i] "\t" i }' | sort -bgr
@overplumbum
overplumbum / gist:3043615
Created July 3, 2012 21:55
redis memory per db analysys
apt-get install unzip python-pip
pip install https://github.com/sripathikrishnan/redis-rdb-tools/zipball/master
KEYS=$(redis-cli info | perl -nle '/^db.:keys=([0-9]+)/ and print $1' | awk '{ a+=$1 } END { print a }')
rdb -c memory /var/lib/redis/dump.rdb | perl -nle '/^(\d+),.*,(\d+),(\d+)$/ and print $1, " ", $2' | pv -ltpe -s $KEYS | gzip -1 > memory.csv.gz
zcat memory.csv.gz | awk '{ c[$1]++; a[$1] += $2} END { for(i in a) print "db:" i "\t" int(a[i]/1024/1024) "Mb\t" c[i] " keys\t" int(a[i]/c[i]) " b/key" }'
@overplumbum
overplumbum / ls_recursive_to_plain_listing.py
Created July 18, 2012 14:30
Convert `ls -UR1` output (fastest way to get recursive listing) to plain file listing
#!/usr/bin/env python
import sys
import argparse
def self_check():
from subprocess import check_output, check_call
from StringIO import StringIO
ls_r = StringIO(check_output(['ls', '-1RU']))