Skip to content

Instantly share code, notes, and snippets.

@bowman
bowman / uni2ascii.pl
Created October 25, 2013 05:35
simple/stupid unicode to ascii mapping
my %uni2ascii = (
"\x{00AB}" => '"', "\x{2018}" => "'", "\x{2236}" => ':',
"\x{00AD}" => '-', "\x{2019}" => "'", "\x{223C}" => '~',
"\x{00B4}" => "'", "\x{201A}" => ',', "\x{2264}" => '<',
"\x{00BB}" => '"', "\x{201B}" => "'", "\x{2265}" => '>',
"\x{00F7}" => '/', "\x{201C}" => '"', "\x{2266}" => '<',
"\x{02B9}" => "'", "\x{201D}" => '"', "\x{2267}" => '>',
"\x{02BA}" => '"', "\x{201E}" => '"', "\x{2303}" => '^',
"\x{02BC}" => "'", "\x{201F}" => '"', "\x{2329}" => '<',
"\x{02C4}" => '^', "\x{2022}" => "*", "\x{232A}" => '>',
@bowman
bowman / literate-bash
Created October 25, 2013 05:32
asciidoc + literate bash
#!/bin/bash
# Executable documentation, lines starting with "> " will be echoed
# (Probably a bad idea, but kind of fun)
# ./INSTALL # | bash -x -
grep \^\\s*\> $0 | cut -c5-
exit # don't run anything unprocessed
(Semi-) Literate Bash Script
----------------------------
@bowman
bowman / mg.pl
Created October 25, 2013 05:23
Perl Variable::Magic experiment
#!/usr/bin/perl -l
package A;
use strict qw(subs);
use warnings;
no warnings 'uninitialized';
use Variable::Magic qw(wizard cast VMG_OP_INFO_NAME);
my $wiz;
BEGIN {
@bowman
bowman / dates.pl
Created October 25, 2013 05:07
Perl Benchmark script for Date validation methods. (Was cluttering $HOME)
#!/usr/bin/perl
#
# Benchmark script for Date validation methods.
#
use strict;
use warnings;
use Benchmark qw(:all :hireswallclock);
use DateTime;
use Time::Piece;
use Time::Local qw(timelocal);
@bowman
bowman / gist:5053397
Created February 28, 2013 01:21
Clarify handling LHS off =>
diff --git pod/perlop.pod pod/perlop.pod
index 40402be..4a2817c 100644
--- pod/perlop.pod
+++ pod/perlop.pod
@@ -1138,10 +1138,11 @@ both its arguments into the list. These arguments are also evaluated
from left to right.
The C<< => >> operator is a synonym for the comma except that it causes a
-word on its left to be interpreted as a string if it begins with a letter
@bowman
bowman / DBIx-Connector.pm.diff
Created February 27, 2012 04:12
DBIx::Connector - allow $pass wrapped in a closure
diff --git lib/DBIx/Connector.pm lib/DBIx/Connector.pm
index 75f4e7d..e330c75 100644
--- lib/DBIx/Connector.pm
+++ lib/DBIx/Connector.pm
@@ -22,22 +22,25 @@ sub DESTROY { $_[0]->disconnect if $_[0]->{_dond} }
sub _connect {
my $self = shift;
+ my @args = @{ $self->{_args} };
+ $args[2] = $args[2]->() if ref $args[2] eq 'CODE'; # reveal wrapped password
@bowman
bowman / DBIx-Connector.pm.diff
Created February 27, 2012 03:59
DBIx::Connector - wrap _args in a closure instead of an array
diff --git lib/DBIx/Connector.pm lib/DBIx/Connector.pm
index 75f4e7d..ab4807f 100644
--- lib/DBIx/Connector.pm
+++ lib/DBIx/Connector.pm
@@ -10,8 +10,9 @@ our $VERSION = '0.52';
sub new {
my $class = shift;
+ my @args = @_;
bless {