Skip to content

Instantly share code, notes, and snippets.

@waffle2k
waffle2k / perldeps
Created February 4, 2014 15:25
Search a given perl file for Debian dependencies within the package management.
#!/bin/sh
perl -lane 'print "$1.pm" if /^\s*use\s+(\S+)\s?.*?\;/' $1 | sed 's/::/\//g' | xargs -n1 dpkg -S
@waffle2k
waffle2k / git-squash
Created January 22, 2014 20:09
Place this in your $PATH, then you'll be able to quickly rebase N number of commits with "git squash N"
#!/bin/bash
#
# This is just a wrapper for : git rebase -i HEAD~4
BACK=$1
function die {
echo "$1"
exit 1
}
@waffle2k
waffle2k / get-to-council-twitter.pl
Created January 3, 2014 15:26
Get the twitter handles for all Toronto City Council.
#!/usr/bin/perl
use strict;
my @urls = qw( http://toronto.about.com/od/civicscityservices/tp/city_councillors_contact.htm
http://toronto.about.com/od/civicscityservices/tp/city_councillors_contact.01.htm
http://toronto.about.com/od/civicscityservices/tp/city_councillors_contact.02.htm
http://toronto.about.com/od/civicscityservices/tp/city_councillors_contact.03.htm
http://toronto.about.com/od/civicscityservices/tp/city_councillors_contact.04.htm );
my @twitter;
@waffle2k
waffle2k / snapshot.pl
Last active December 31, 2015 13:39
Rsync a remote dir locally, compare it against a previous backup, and replace all identical files with hardlinks to reduce the space used.
#!/usr/bin/perl
use strict;
package MAIN;
use Digest::MD5;
use File::Find;
use Data::Dumper;
my $VERBOSE = $ENV{'VERBOSE'} || 0;
@waffle2k
waffle2k / rbl_lookup.pl
Last active December 31, 2015 06:09
Lookup your CIDR ranges against a number of RBL zones, via http://petermblair.com/2009/08/check-if-your-outbound-relays-are-blacklisted/
#!/usr/bin/perl
use strict;
use Net::DNS::Async;
use NetAddr::IP;
# rbllookup_async.pl - Thu Aug 20 13:13:35 EDT 2009
#
# Author: pblair(at)tucows(dot)com
# Updated: Thu Aug 20 13:14:14 EDT 2009
#
@waffle2k
waffle2k / wordpress-backup.pl
Created December 11, 2013 19:38
A simple little script that backs up the wordpress/mysql database. It requires a ~/.wpbackup file with at least the line "SOURCE_FROM_WP" and "WPLOC=/location/of/wordpress" in it.
#!/usr/bin/perl
use strict;
sub extract_from_config {
my $filename = shift || die;
my $variable = shift || die;
open my $fd, "<$filename" or die "$filename: $!";
while( <$fd> ){
@waffle2k
waffle2k / compare-packages.pl
Last active December 28, 2015 05:49
(zabbix-package-versions ; ssh zabbix02 zabbix-package-versions) | compare-packages.pl
#!/usr/bin/perl
use strict;
sub map_set {
my $fn = shift;
die unless -f $fn;
my $map = {};
open my $fd, "<$fn";
#!/usr/bin/perl
#
# Take two keys, and attempt to match them up
#
# author: [email protected]
my @list = sort( @ARGV );
my (@name, @modulus);
for ( @list ){
@waffle2k
waffle2k / trim-by-epoch.pl
Created November 1, 2013 20:36
A simple little Perl script that takes an epoch, and a regular expression that captures an epoch within a filename, then deletes said file.
#!/usr/bin/perl
use strict;
use Getopt::Long;
$|++;
my ( $cutoff, $re );
GetOptions (
"regex=s" => \$re,
@waffle2k
waffle2k / split-out-repo.sh
Last active December 21, 2015 12:49
Github used to limit the number of public repos. As such, I had all of my CPAN modules as subdirectories of a single repo. This script iterates through those directories and imports the directory into the new repo after renaming the repo to match the Debian perl module package naming.
#!/bin/bash
#
# from https://help.github.com/articles/splitting-a-subpath-out-into-a-new-repository
#
for CHILD in Conan Copy-From-Git Net-Domain-Regex Net-Domain-Match Net-PortTest
do
cd /tmp
rm -rf /tmp/Perl-CPAN
git clone [email protected]:petermblair/Perl-CPAN.git && cd Perl-CPAN