Skip to content

Instantly share code, notes, and snippets.

@MidLifeXis
MidLifeXis / Example ticket.md
Last active January 31, 2017 19:50
Example of table MD

This example data causes the frobnitz process to break:

ID Field 1 Field 2 expected received
id_1 data 1 1 data 1 2 Foo Bar

And an implementation of an output formatter based on Text::Table.

use strict;
my $doc = CAM::PDF->new( $cfg->infile );
printf( "read %s\n", $cfg->infile );
for my $p ( 1 .. $doc->numPages ) {
my $outfilename = $cfg->outfilebase;
$outfilename =~ s/XXXX/$p/;
printf( " extracting page %d\n", $p );
@MidLifeXis
MidLifeXis / autobox_with_subs
Last active May 6, 2019 15:48
Perl toolbox
#!/usr/bin/perl
# Not certain if this will ever be useful, but thanks to choroba@perlmonks.
use warnings;
use strict;
my $join = sub {join pop, @{shift()} };
my $grep = sub { my $f = pop; [ grep {$f->($_)} @{shift()} ]};
my $say = sub { print( @_, "\n" ) };
#!/usr/bin/env perl
use v5.16;
use constant {
GH_USER => 'bob',
GH_PASS => 'secret',
TRAVIS_CONFIG => { user => 'bob', token => 'ABfrht2s82J93AyGBNfq' , domain =>'' },
};
@MidLifeXis
MidLifeXis / dot-emacs-activate-unittest.snippet.el
Last active December 11, 2015 15:29
Activating unittest.el in .emacs
(require 'unit-test)
(define-key global-map (kbd "C-c t") 'run-unit-tests)
(define-key global-map (kbd "C-c s") 'set-unit-test-command)
(define-key global-map (kbd "C-c o") 'open-unit-test-file)
;;; (define-key global-map [(control shift mouse-2)] 'btw/perl-open-class-file)
(defun btw/unit-test-completion-function (buf status)
"Function to run when a unit-test compilation has completed."
(cond ((string-match "finished" status)
(show-test-status 'passed))
@MidLifeXis
MidLifeXis / perlmonks.css
Last active October 13, 2015 16:38
Perlmonks CSS settings
/* CSS tweaks to the 'Dark theme' at http://perlmonks.org/ */
/*
Note: This does not render properly if you link directly
to it in FFX or Chrome, as the Content-type attribute is
sent as text/plain. There is a bug / feature in the
gist rendering engine that has a fix and pull pending.
*/
body { background-color: red; }
@MidLifeXis
MidLifeXis / gist:3826679
Created October 3, 2012 12:27
Scopeguard example
# From Try::Tiny
{
package # hide from PAUSE
Try::Tiny::ScopeGuard;
sub _new {
shift;
bless [ @_ ];
}