Skip to content

Instantly share code, notes, and snippets.

View eqhmcow's full-sized avatar

Daniel S. Sterling eqhmcow

View GitHub Profile
@eqhmcow
eqhmcow / iptables.rules
Last active February 12, 2020 10:35
let me eat cake
# /etc/iptables.rules
# Generated by iptables-save v1.6.1 on Sat Oct 19 09:21:09 2019
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:MINIUPNPD - [0:0]
@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;
dsterling@thinkfly:~/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope/src/kaleidoscope/plugin$ git diff
diff --git a/src/kaleidoscope/plugin/LED-Wavepool.cpp b/src/kaleidoscope/plugin/LED-Wavepool.cpp
index 1c24fe49..b649e3a5 100644
--- a/src/kaleidoscope/plugin/LED-Wavepool.cpp
+++ b/src/kaleidoscope/plugin/LED-Wavepool.cpp
@@ -179,10 +179,10 @@ void WavepoolEffect::TransientLEDMode::update(void) {
int8_t *p;
for (p = offsets, value = 0; p < offsets + 8; p++)
value += oldpg[offset + (*p)];
- value = (value >> 2) - newpg[offset];
@eqhmcow
eqhmcow / apache-logtop-README
Last active July 29, 2019 14:54
Real-time top-like requests-per-second average for httpd request logs - similar to apachetop
DESCRIPTION
logstat.pl and logtop.pl
These scripts show current and average request-per-second counts based on
apache access logs in real-time.
You can see the total requests-per-second as well as a breakdown by:
* vhost
* URL
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:
@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 / 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 / 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 / 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 );
@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 ;