Skip to content

Instantly share code, notes, and snippets.

View mlbright's full-sized avatar

Martin-Louis Bright mlbright

  • Toronto
  • 00:54 (UTC -04:00)
View GitHub Profile
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use BuildForge::Services;
use Try::Tiny;
use Config::Simple;
my $cfg = Config::Simple->new( $0 . '.cfg' );
#!/usr/bin/env perl
use 5.016;
use JenkinsRC;
my $jenkins = JenkinsRC->new( url => $ENV{'JENKINS_URL'} );
my @jobs = @ARGV;
for my $job (@jobs) {
my $def = $jenkins->get($job);
say $def;
@mlbright
mlbright / sysenv.pl
Created May 12, 2013 18:46
display environment variables and PATH in a simple, sane way
#!/usr/bin/env perl
use Modern::Perl;
say "$_ : " . $ENV{$_} for ( sort keys %ENV );
say "";
say "System PATH for $^O";
say "";
my $pathdel;
@mlbright
mlbright / feeds.pl
Created May 10, 2013 05:09
find all feeds from an OPML file. Add them to rss2email.
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use XML::OPML::LibXML;
use HTTP::Tiny;
use Path::Class;
my $url = "https://raw.github.com/mlbright/myopml/master/subs.xml";
@mlbright
mlbright / mortgage_example.pl
Last active December 16, 2015 20:39
compare 2 mortgage options
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
my $n = 21 * 12; # remaining amortization in number of months
my $ingblended = 3.84;
my $ingbroken = 3.08;
my $tdrate = 2.79;
#!/usr/bin/python
# Does this work?
# http://blog.jgc.org/2013/04/the-minimum-coin-problem-with-prize.html
coins = [200,50,50,100,100,20,20,20,10,5,5,2,2,1,1]
coins.sort()
coins.reverse()
paper = 170
@mlbright
mlbright / shouldiupgradejenkins.pl
Created April 18, 2013 13:12
Should you upgrade Jenkins to the latest version? Here's the ratio of sunny ratings to the number of cloudy and stormy ratings.
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use HTTP::Tiny;
my $ratings = 'http://jenkins-ci.org/rate/result.php';
my $response = HTTP::Tiny->new->get($ratings);
@mlbright
mlbright / chattyrm.pl
Created March 23, 2013 02:26
Chattier version of rm -rf. Deletes every path provided on STDIN.
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use File::Path qw (remove_tree);
while ( my $path = <> ) {
chomp $path;
my $errors;
@mlbright
mlbright / buploader.pl
Last active December 11, 2015 16:58
upload all pictures from a given directory to Flickr, and then to Picasa Web Albums, using your secret email upload address.
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Flickr::Upload;
use File::Spec;
use File::Find;
use Config::Simple;
use Path::Class;
@mlbright
mlbright / socks.py
Created December 27, 2012 16:04
Calculate the expected percentage of pairs of socks recovered after randomly washing a sample
# Calculate the expected percentage of pairs of socks recovered
# after randomly washing a sample
from random import shuffle, sample
from collections import defaultdict
from time import clock
PAIRS = 20.0
EXPERIMENTS = 1000000