Skip to content

Instantly share code, notes, and snippets.

@waffle2k
waffle2k / cpan-pipeline
Created August 14, 2013 05:28
Once I've manually tested a new build, I run this script to execute certain regression tests against it, then push it to my PAUSE account for indexing.
#!/bin/bash
#
# This script is used to automate and move along the CPAN pipeline of
# module creation, and upload to CPAN.
set -e
function die {
echo "$1"
exit 1
@waffle2k
waffle2k / git-squash
Created August 7, 2013 15:52
For some reason, I can never remember the rebase command, yet I use it all of the time. This is handy if you're done with your commits, and you're ready to merge back into master. First, rebase all of your commits with "f" to fixup all of them before merging. This follows the convention of "1 change, 1 commit".
#!/bin/bash
#
# This is just a wrapper for : git rebase -i HEAD~4
BACK=$1
function die {
echo "$1"
exit 1
}
@waffle2k
waffle2k / google-man
Last active December 20, 2015 18:18
Sometimes I just type "man something-or-other" and would like google to take over if the man page does exist.
#!/usr/bin/perl
use strict;
$|++; # piping hot!
my $BROWSER = 'chromium-browser';
my $man = '/usr/bin/man';
sub googleit {
my $search = join( " ", @ARGV );
@waffle2k
waffle2k / lg.pl
Created July 5, 2013 18:57
Log-Grok: Search within logfiles for either a regex pattern or for an IP that matches a given CIDR range
#!/usr/bin/perl
use strict;
use Getopt::Long;
use Net::CIDR ':all';
$|++;
my $re = '.*';
my $verbose = 0;
my $cidr_str = undef;
@waffle2k
waffle2k / markov.py
Last active December 18, 2015 18:49
Simple Markov Chain programme and helper utilities
#!/usr/bin/env python
import sys
import random
class Markov:
def __init__(self):
self.h = {}
def add( self, x, y ):
@waffle2k
waffle2k / ifconfig.feature
Last active December 15, 2015 13:09
Take a cue from ruby and cucumber, but with Perl and for system admins to write behaviour driven test cases for configuration management. Run: "./testadmin.pl ifconfig.step ifconfig.feature"
As a silly system administrator
When I run ifconfig eth0
Then the MTU must be 1500
@waffle2k
waffle2k / gist:5259193
Created March 27, 2013 23:42
Example mutt hooks for good mailing list etiquette
send-hook '~t [email protected]' my_hdr From: Peter Blair <pblair@***.com>
send-hook '~t [email protected]' my_hdr Reply-To: [email protected]
send-hook '~t [email protected]' my_hdr Fcc: ""
send-hook '~c [email protected]' my_hdr From: Peter Blair <pblair@***.com>
send-hook '~c [email protected]' my_hdr Reply-To: [email protected]
send-hook '~c [email protected]' my_hdr Fcc: ""
@waffle2k
waffle2k / port_check.pl
Last active December 15, 2015 07:18
Example of using Net::PortTest
#!/usr/bin/perl -w
use strict;
use Net::PortTest;
on 143 => sub {
my $sock = shift;
my $results = {};
my $rc = -1;
closure: closure.cpp
g++ -W -Wall -Wextra -pedantic -std=c++0x closure.cpp -o closure
clean:
rm closure
@waffle2k
waffle2k / pf.conf
Created March 8, 2013 17:30
My OpenBSD 5.2 /etc/ppp/ppp.conf file used for connecting to my copper.net dialup account. This is executed via the "ppp -auto copper" command as user root.
# $OpenBSD: pf.conf,v 1.50 2011/04/28 00:19:42 mikeb Exp $
#
# See pf.conf(5) for syntax and examples.
# Remember to set net.inet.ip.forwarding=1 and/or net.inet6.ip6.forwarding=1
# in /etc/sysctl.conf if packets are to be forwarded between interfaces.
set skip on lo
# filter rules and anchor for ftp-proxy(8)
#anchor "ftp-proxy/*"