Skip to content

Instantly share code, notes, and snippets.

@waffle2k
waffle2k / pf.conf
Created March 8, 2013 17:29
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/*"
@waffle2k
waffle2k / rename-zabbix-template.pl
Created March 1, 2013 19:25
When exporting templates from zabbix, it defaults the download name to something generic. It's useful to then rename all of the xml files to reflect their template name.
#!/usr/bin/perl -s
use XML::Simple;
my @files = grep { /\.xml$/ and -f $_ } @ARGV;
for my $filename ( @files ){
my $xml = XML::Simple->new;
my $data = $xml->XMLin( $filename );
@waffle2k
waffle2k / perl-linter
Created February 20, 2013 15:57
This is a little perl linter that I wrote. It will make any Perl script 100% better.
#!/bin/bash
FILENAME=""
if [ -e $1 ]; then
FILENAME=$1
fi
if [ ! -z $FILENAME ]; then
FILENAME=/dev/stdout
fi
@waffle2k
waffle2k / fbl_rules.pl
Created January 21, 2013 20:51
Attempt to identify complaints based on custom rules
#!/usr/bin/perl
use strict;
use Email::ARF::Report;
my $message = do { local $/; <>; };
my $report = Email::ARF::Report->new( $message );
use Data::Dumper;
@waffle2k
waffle2k / install_latest.sh
Created November 19, 2012 21:53
Install the latest package given the script get_latest.pl exists
#!/bin/bash
#
#
function die
{
echo "$1"
exit 1
}
@waffle2k
waffle2k / get_latest.pl
Created November 19, 2012 21:46
Get the URL of the latest package available, using a PCRE against a URL as input.
#!/usr/bin/perl
use strict;
#my $regex = 'http://slowpoke.internal.tucows.com/~pblair/perl/Tucows-OPS-Cloud-(\d+(?:\.\d+)).tar.gz';
my $WGET = `which wget` || die 'Must install either wget for this to work';
chomp $WGET;
die 'wget must be installed and in the PATH' if $WGET =~ /^\s*$/;
@waffle2k
waffle2k / zabbix_checks.pl
Created November 15, 2012 19:26
Get all active checks for your host
#!/usr/bin/perl
use strict;
package ZBX::SERVER;
use JSON;
use IO::Socket;
use Net::Domain 'hostfqdn';
use constant ZBX_SERVER_PORT => 10051;
@waffle2k
waffle2k / google_maps_locality.pl
Created November 6, 2012 19:10
Take some unknown locations (city and state) and call out to google to get some of the pertinent info
#!/usr/bin/perl
use strict;
use Data::Dumper;
use JSON;
sub best_candidate {
my ($json_obj) = @_;
for( @{$json_obj->{results}} ){
next if $_->{types}->[0] eq 'route';
@waffle2k
waffle2k / run-as.pl
Created October 17, 2012 17:57
Simple package for ensuring that a script is run as a given user
#!/usr/bin/perl
package Must::Run::As;
sub import {
my ($package,$user) = @_;
unless( $user ){
$user = 'mail';
}
die "Must run as $user\n" unless ( getpwuid( $< ) eq $user );
@waffle2k
waffle2k / ver.pl
Created October 2, 2012 21:19
Parsing the version of a package
#!/usr/bin/perl
use strict;
package Version;
use overload
'""' => "str",
'cmp' => "compare",
'<=>' => "compare",
;