Skip to content

Instantly share code, notes, and snippets.

View briandfoy's full-sized avatar

brian d foy briandfoy

View GitHub Profile
@briandfoy
briandfoy / gist:1342877
Created November 6, 2011 13:29
Perl regex escapes by version of their introduction
# compiled by Tom Christiansen
v1.0 \0, \0N,\0NN Match octal character up to octal 077.
v1.0 \N, \NN, \NNN Match Nth capture group (decimal) if not in charclass and that many seen, else (octal) character up to octal 377.
v4.0 \a Match the alert character (ALERT, BEL).
v5.0 \A True at the beginning of a string only, not in charclass.
v1.0 \b Match the backspace char (BACKSPACE, BS) in charclass only.
v1.0 \b True at Unicode word boundary, outside of charclass only.
v1.0 \B True when not at Unicode word boundary, not in charclass.
v4.0 \cX Match ASCII control character Control-X (\cZ, \c[, \c?, etc).
v5.6 \C Match one byte (C char) even in UTF‑8 (dangerous!), not in charclass.
@briandfoy
briandfoy / transmission-mojo.pl
Created April 16, 2012 10:20
Mojo::UserAgent interacting with Mac app Tranmission's RPC
use v5.10;
use utf8;
use strict;
use warnings;
# https://trac.transmissionbt.com/browser/branches/1.7x/doc/rpc-spec.txt
use Mojo::UserAgent;
use JSON qw(to_json);
@briandfoy
briandfoy / gist:3058464
Created July 6, 2012 06:45
Switch file names
#!perl
die "Two files only!\n" if @ARGV != 2;
rename $ARGV[0] => my $temp = "$ARGV[0].bak";
rename $ARGV[1] => $ARGV[0];
rename $temp => $ARGV[1];
#!/usr/bin/perl
use warnings;
use strict;
use Cwd;
use Digest::MD5;
my $md5 = Digest::MD5->new();
my %digests = ();
#!/usr/bin/perl
use File::Find;
use Digest::MD5;
find( \&wanted, grep { -e } @ARGV );
our %digests;
sub wanted {
return if( -d $File::Find::name or -l $File::Find::name );
@briandfoy
briandfoy / gist:3068953
Created July 8, 2012 01:48
Download from TiVo
#!/usr/bin/perl -s
use strict;
use warnings;
use Data::Dumper;
use DBM::Deep;
use Net::TiVo;
our $S;
@briandfoy
briandfoy / perl_module_checklist.pl
Created July 24, 2012 01:20
Perl Module Checklist
#!/usr/bin/perl
use strict;
use warnings;
use vars qw( $Longest_name );
use Data::Dumper;
use File::Spec::Functions qw(catfile);
use Spreadsheet::WriteExcel;
use Test::Manifest qw(get_t_files);
@briandfoy
briandfoy / perl_on_windows.txt
Created July 25, 2012 22:05
Outline for a book on Perl on Windows
Introduction
Why Perl over Powershell?
This isn't Learning Perl on Win32
Perl distributions for Windows
ActivePerl
Strawberry Perl
Cava
cygwin (only briefly)
@briandfoy
briandfoy / looney_toons.pl
Created August 29, 2012 18:23
Extract Looney Toons links
#!/usr/local/perls/perl-5.14.2/bin/perl
use v5.14;
use Mojo::UserAgent;
my $ua = Mojo::UserAgent->new;
my $url = 'http://www.toonarific.com/show_episodes.php?show_id=2177';
my @seasons = $ua->get( $url )
->res
@briandfoy
briandfoy / perl-cert.json
Last active December 11, 2015 01:48
A JSON representation of the CERT Perl Secure Coding Standards (https://www.securecoding.cert.org/confluence/display/perl/CERT+Perl+Secure+Coding+Standard)
[
{
"priority" : "P4",
"name" : "Canonicalize path names before validating them",
"rule" : "",
"section" : "1",
"recommedation" : "1",
"level" : "L3",
"url" : "https://www.securecoding.cert.org/confluence/display/perl/IDS00-PL.+Canonicalize+path+names+before+validating+them",
"class" : "IDS00-PL",