Skip to content

Instantly share code, notes, and snippets.

@icot
icot / timer.pl
Created June 27, 2012 09:46
Perl timed child process
#!/usr/bin/perl -w
use strict;
use POSIX;
my $MAX_EXEC_TIME = 10;
my $pid;
eval {
local $SIG{'ALRM'} = sub { die "timed out\n" };
@icot
icot / Xresources
Created November 18, 2012 16:36
urxvt color configuration
urxvt.foreground: White
urxvt.saveLines: 20000
urxvt.scrollBar: off
urxvt.font: xft:inconsolata:size=10:autohint=true:antialias=true
urxvt*foreground: #f2f2f2
!urxvt*background: #101010
urxvt*background: #002b37
@icot
icot / syscontrol fabfile.py
Created January 11, 2013 11:03
Fabric fabfile for syscontrol tasks
from fabric.api import run, hosts,env
import logging
logging.basicConfig( level=logging.ERROR )
env['use_ssh_config'] = True
SVN_USER = 'XXXXXXXX'
BASE_PATH = """ $DISTRIBUTE_TOP/dist_top_syscontrol/projects/dod/ """
@icot
icot / gist:4672146
Created January 30, 2013 10:08
Editable webs
data:text/html, <body contenteditable style="font-size:2rem;line-height:1.4;max-width:60rem;margin:0 auto;padding:4rem;">
@icot
icot / gist:5129797
Created March 10, 2013 18:41
MP4 to AVI
avconv -i $file.mp4 -vcodec mpeg4 -acodec ac3 -ab 128k -ac 2 $file.avi
@icot
icot / gist:5245353
Last active December 15, 2015 10:19
Iptables
#Youtube ADS filtering
$IPTABLES -A INPUT -s 206.111.0.0/16 -j REJECT
$IPTABLES -A INPUT -s 173.194.55.0/24 -j REJECT
# Opening port 80
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
@icot
icot / xmobar_1
Last active December 17, 2015 16:19
xmobar_1
Config { font = "-Misc-Fixed-Bold-R-Normal--13-100-75-75-C-70-ISO8859-1"
, bgColor = "#101030"
, fgColor = "grey"
, position = Static { xpos = 0 , ypos = 0, width = 1024, height = 16 }
, commands = [ Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
, Run Memory ["-t","Mem: <usedratio>%"] 10
, Run Swap [] 10
, Run StdinReader
]
@icot
icot / xmobar
Created May 23, 2013 17:52
xmobar
Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*"
, bgColor = "black"
, fgColor = "grey"
, position = Top
, border = NoBorder
, borderColor = "black"
, lowerOnStart = True
, commands = [ Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
, Run Memory ["-t","Mem: <usedratio>%"] 10
, Run Swap [] 10
@icot
icot / RDO removal
Last active December 17, 2015 22:09
Removes an RDO installation
# Warning! Dangerous step! Destroys VMs
for x in $(virsh list --all | grep instance- | awk '{print $2}') ; do
virsh destroy $x ;
virsh undefine $x ;
done ;
# Warning! Dangerous step! Removes lots of packages, including many
# which may be unrelated to RDO.
yum remove -y nrpe "*nagios*" puppet "*ntp*" "*openstack*" \
"*nova*" "*keystone*" "*glance*" "*cinder*" "*swift*" \
@icot
icot / gist:5859436
Created June 25, 2013 15:31
Find and kill queries which have been running for more than an hour in MySQL (Perl)
#!/usr/bin/env perl
use DBI;
use warnings;
# DB Connection
my $dsn = "DBI:mysql:information_schema:dbod-testinstance:5500:mysql_read_default_file=$ENV{HOME}/.my.cnf";
$dbh = DBI->connect($dsn,undef, undef, {RaiseError => 1})
or die "Connection Error: $DBI::errstr\n";