Skip to content

Instantly share code, notes, and snippets.

View jacoby's full-sized avatar
🌮
I ❤️ Tacos

Dave Jacoby jacoby

🌮
I ❤️ Tacos
View GitHub Profile
@jacoby
jacoby / explanation.txt
Created March 23, 2015 19:37
Help Me Test Code Again
I'm writing tests, and I'm coding tests as non-test code before I put them into
my test file.
This code uses Perl objects (non-Moose; haven't made it to there yet) to handle
DBI connections, so I can do things like put my example code in GitHub gists
without being worried that server addresses, logins and passwords were accidentally
left in the code.
Right now, I'm trying to write tests for this module, and my biggest problem atm is
finding a way to test transactions against an existing MySQL database so I'm not
@jacoby
jacoby / imap_all.pl
Created March 27, 2015 20:09
This code goes one-by-one through your mailbox using IMAP, showing each message's date, to, from and subject
# I plan to redo this as YAML but have yet to
# identity , server , port , username , password , directory
gmail , imap.gmail.com , 993 , your_username , password , INBOX
@jacoby
jacoby / api_tests.pl
Created March 31, 2015 18:00
Code I wrote to test a new web API by comparing it's output with the old one
#!/usr/bin/env perl
use feature qw'say state' ;
use subs qw'uniq' ;
use Data::Dumper ;
use JSON ;
use LWP::UserAgent ;
use Test::Most ;
@jacoby
jacoby / gen.pl
Created April 14, 2015 15:36
Mustache vs Template Head To Head
my $data ;
my $c = 0 ;
for ( 1 .. 3_000 ) {
my $row ;
for ( 1 .. 10) {
push @$row , $c ;
$c = ( $c + 1 ) % 8 ;
}
push @$data , $row ;
@jacoby
jacoby / Multi.pm
Last active August 29, 2015 14:19
Testing Multimethods in Perl
package Multi ;
use Class::Multimethods ;
use Exporter qw(import) ;
our @EXPORT = qw{
test
} ;
multimethod test => ()
@jacoby
jacoby / template_vs_handlebars.pl
Created April 16, 2015 18:00
Takes an array of arrays, filled with 100 characters, turned into an HTML table
#!/usr/bin/env perl
use feature qw{ say state } ;
use strict ;
use warnings ;
use Data::Dumper ;
my @alphabet = 'a' .. 'z' ;
@jacoby
jacoby / fill_random.pl
Created April 17, 2015 20:49
Fill your terminal with random characters
#!/usr/bin/env perl
use feature qw{ say } ;
use Term::ReadKey ;
my ( $wchar, $hchar ) = GetTerminalSize() ;
for ( 2 .. $hchar ) {
say join '' , map { ( 'a' .. 'z' )[ int rand 26 ] } 1 .. $wchar ;
}
PS1="${debian_chroot:+($debian_chroot)}\u@\h:\$(~/bin/get_temp.pl):\w\n\$ "
@jacoby
jacoby / mfitbit.pl
Created May 12, 2015 21:08
Working Through Perl and MongoDB
#!/usr/bin/env perl
use feature qw'say' ;
use strict ;
use warnings ;
use DateTime ;
use Data::Dumper ;
use lib '/home/jacoby/lib' ;
@jacoby
jacoby / a2b.pl
Created May 19, 2015 20:45
ASCII to binary and vice versa
#!/usr/bin/env perl
use feature qw'say' ;
use strict ;
use warnings ;
use Data::Translate ;
my $data = new Data::Translate;
# allows a2b.pl foobarblee or echo foobarblee | a2b.pl