Skip to content

Instantly share code, notes, and snippets.

View eqhmcow's full-sized avatar

Daniel S. Sterling eqhmcow

View GitHub Profile
@eqhmcow
eqhmcow / ping-check.pl
Last active November 5, 2019 20:39
timestamp STDOUT
#!/usr/bin/env perl
use strict;
use warnings;
# apt-get install apache2-utils libyaml-syck-perl libtimedate-perl
use YAML::Syck;
use IO::File;
use Date::Parse;
use Time::Piece;
@eqhmcow
eqhmcow / doit.pl
Last active September 26, 2016 02:42
quick and dirty ssh then sudo then run commands in a loop w/ Net::CLI::Interact and Parallel::ForkManager
#!/usr/bin/perl
use strict;
use warnings;
use Net::CLI::Interact;
use Parallel::ForkManager;
# servers
my @doit = qw( server1 server2 server3 );
Big Data on Little Linux
@eqhmcow
eqhmcow / multi shape
Last active June 18, 2018 09:14
use multiple internet connections, both simultaneously and transparently, both from the router itself and via boxes behind the router through NAT
#!/bin/bash
# As the "bufferbloat" folks have recently re-discovered and/or more widely
# publicized, congestion avoidance algorithms (such as those found in TCP) do
# a great job of allowing network endpoints to negotiate transfer rates that
# maximize a link's bandwidth usage without unduly penalizing any particular
# stream. This allows bulk transfer streams to use the maximum available
# bandwidth without affecting the latency of non-bulk (e.g. interactive)
# streams.
@eqhmcow
eqhmcow / reload_iptables.sh
Created April 30, 2013 03:19
unload the iptables modules and then reload them and apply the firewall rules stored at /etc/iptables.conf - adapted from RHEL 5's iptables services script
IPTABLES=iptables
IPV=${IPTABLES%tables} # ip for ipv4 | ip6 for ipv6
PROC_IPTABLES_NAMES=/proc/net/${IPV}_tables_names
/sbin/modprobe --version 2>&1 | grep -q module-init-tools \
&& NEW_MODUTILS=1 \
|| NEW_MODUTILS=0
# Do not stop if iptables module is not loaded.
[ -e "$PROC_IPTABLES_NAMES" ] || exit 1
@eqhmcow
eqhmcow / unzip.pl
Last active December 31, 2022 18:49
Perl unzip example with IO::Uncompress::Unzip
#!/usr/bin/perl
# example perl code, but this should now actually work properly, even on
# Windows
# thanks to everyone who tested this, reported bugs and suggested or
# implemented fixes!
# this code is licensed under GPL 2 and/or Artistic license;
# aka free perl software
@eqhmcow
eqhmcow / backup.sh
Last active December 15, 2015 10:09
mysql backup script
#!/bin/bash
# backup mysql tables - does an initial dump and then backs up to final
# location using rdiff-backup
# NOTE: do NOT manually edit or update the rdiff-backup managed final backup
# location. ONLY use rdiff-backup to update files in that backup directory. if
# the files are changed directly, the historical backups that rdiff-backup
# maintains will be corrupted.
@eqhmcow
eqhmcow / apache-preconnect-workaround-README
Last active April 12, 2020 19:41
version 2 of a script to kill apache 1.3 / 2.x prefork httpd processes serving preconnect connections, in an attempt to prevent chrome from causing a DoS against the httpd
script to kill apache 1.3 / 2.x prefork httpd processes serving preconnect connections, in an attempt to prevent chrome from causing a DoS against the httpd
This is version 2 of https://gist.github.com/eqhmcow/4774549
The major change is the use of two processes instead of one:
One process makes server-status requests, the other kills idle prefork processes.
This allows the kill script to continue killing idle processes even when Chrome has effectively DoS'd the apache server. When this happens, the check script can't get an updated status response back immediately, but the kill script can hopefully free up a slot by killing some processes. Having an uninterrupted request in the socket queue allows us to get an updated response after killing the Chrome preconnections are killed.
@eqhmcow
eqhmcow / kill_idle_cms_httpd.pl
Last active December 12, 2015 12:49
script to kill apache 1.3 / 2.x prefork httpd processes serving preconnect connections, in an attempt to prevent chrome from causing a DoS against the httpd
#!/bin/env perl
# kill_idle_cms_httpd.pl - kill idle httpd connections
# $Id$
use strict;
use warnings;
use Time::HiRes 'time';
@eqhmcow
eqhmcow / irc-espeak-README
Last active October 13, 2015 19:17
irc espeak replacer for fox
$ cat test.txt
18:36 <@Dop> also fox_1: the scottish accent isn't too bad but you need to slow it down quite a bit to get the full effect
18:37 <@fox_1> still need to tweak a little
18:37 <@fox_1> right now you're a female scot for example I think
18:37 <@Dop> och aye? rofl
18:38 <@fox_1> ;)
18:55 <@ytz> lol
18:56 <@fox_1> that was the facebook fight
18:56 <@ytz> time to assemble coffee before the main card
18:56 <@fox_1> yeah I got rockstar