Skip to content

Instantly share code, notes, and snippets.

View eqhmcow's full-sized avatar

Daniel S. Sterling eqhmcow

View GitHub Profile
@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 / 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 / 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.
Big Data on Little Linux
@eqhmcow
eqhmcow / doit.pl
Last active December 29, 2024 03:54
quick and dirty ssh then sudo then run commands in a loop w/ IPC::Run and Parallel::ForkManager
#!/usr/bin/perl
use strict;
use warnings;
$|++;
use IPC::Run qw/start pump finish timeout/;
use Parallel::ForkManager;
use Getopt::Long;
@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 / gist:886717fc3b584118c954e9be5544dc28
Created August 19, 2016 14:10
quick and dirty linux "sysprep"
# remove IP / set IP to one that won't be used for other systems
# clear ssh host key
rm -rf /etc/ssh/ssh_host_*
# remove /etc/hosts entries as applicable
# remove utmp data - wtmp and btmp and lastlog
rm /var/log/{w,b}tmp /var/log/lastlog ;
touch /var/log/{w,b}tmp /var/log/lastlog ;
@eqhmcow
eqhmcow / aggregate.pl
Last active June 17, 2017 01:35
aggregate contiguous positive numbers
use strict;
use warnings;
my @n;
while (<>) {
push @n, $_;
}
my $first_num = 0;
my $next_num = 0;
my $contig = 0;
@eqhmcow
eqhmcow / README
Last active July 9, 2022 12:54 — forked from anonymous/README
docker wrapper
slightly-less-insecure-docker
wrapper around docker that perhaps makes it slightly less insecure
example usage:
DOCKER=/path/to/docker-wrapper
sudo $DOCKER run -it -v /etc/passwd:/etc/passwd -v /tmp:/tmp ubuntu
NOTE:
How to run "ls" in docker
---
Run "ls" in docker, handling various possible environmental issues that the shell normally directly handles.
That is, the below docker command is similar to simply issuing "ls" at a shell prompt, or adding an "ls" command to a shell script.
Without docker: