Skip to content

Instantly share code, notes, and snippets.

View bAndie91's full-sized avatar

Andreas Hrubak bAndie91

View GitHub Profile
# format tab-delimited lines to table with borders
# compute width of each column
column_width=()
text=''
while read -r line
do
text=$text${text:+$'\n'}$line
@bAndie91
bAndie91 / cidr2regex
Last active April 25, 2018 10:53
converts CIDR to regexp
#!/usr/bin/env perl
use Number::Range::Regex;
Number::Range::Regex->init({'comment'=>0, 'no_leading_zeroes'=>1, 'no_sign'=>1});
$rr0_255 = range(0, 255);
$rr0_32 = range(0, 32);
$union_range = range(-1, -1);
@bAndie91
bAndie91 / git author stats
Created January 22, 2018 15:41
display stats (first, last commit, num of commits, lines +/-) about each git author on the master branch
git log master --shortstat --format='commit %ct %aN' |\
perl -MDate::Format -ne '
if(/(\d+) insertion.* (\d+) deletion/){
$s{$N}->{"add"}+=$1;
$s{$N}->{"del"}+=$2;
$s{$N}->{"com"}++;
}elsif(/^commit (\d+) (.+)/){
$t=$1;
$N=$2; $N=~s/ /_/g;
if($first{$N}>$t or !$first{$N}){ $first{$N}=$t };
#!/usr/bin/perl
#
# Rouge DHCP traffic detection.
#
$0 = "RougeDetect";
# Wait for dhcp offer:
$WAIT = 10;
# Only legal dhcp server and gateway:
$Router = "192.168.1.254";