Skip to content

Instantly share code, notes, and snippets.

View schwern's full-sized avatar

Michael G. Schwern schwern

View GitHub Profile
@schwern
schwern / gist:ccc2d48805815e6c6b77
Created October 13, 2014 22:38
BackPAN dists with the same name, different case for https://github.com/evalEmpire/gitpan/issues/82
Cache-Memcached-LibMemcached|Cache-Memcached-libmemcached
authors/id/D/DM/DMAKI/Cache-Memcached-LibMemcached-0.00001.tar.gz|1200035192
authors/id/D/DM/DMAKI/Cache-Memcached-LibMemcached-0.00002.tar.gz|1200184992
authors/id/D/DM/DMAKI/Cache-Memcached-LibMemcached-0.00003.tar.gz|1200229628
authors/id/D/DM/DMAKI/Cache-Memcached-LibMemcached-0.00004.tar.gz|1200236499
authors/id/D/DM/DMAKI/Cache-Memcached-LibMemcached-0.00005.tar.gz|1200506252
authors/id/D/DM/DMAKI/Cache-Memcached-LibMemcached-0.00006.tar.gz|1200754914
authors/id/D/DM/DMAKI/Cache-Memcached-libmemcached-0.01000.tar.gz|1201536128
authors/id/D/DM/DMAKI/Cache-Memcached-libmemcached-0.02000.tar.gz|1204590503
authors/id/D/DM/DMAKI/Cache-Memcached-libmemcached-0.02001.tar.gz|1206583159
@schwern
schwern / gist:b5774115432e8da81e0e
Created July 31, 2014 20:11
Moo speed up coercion + default with eval block instead of DIE handler.
{
package Foo;
use Moo;
has with_coerce1 => (
is => 'rw',
coerce => sub { 1 },
default => sub { 1 },
);
has with_coerce2 => (
is => 'rw',
@schwern
schwern / gist:6592165547b4ea0f65ef
Created June 14, 2014 19:04
Benchmark List::MoreUtils::uniq() vs uniq() in Perl.
#!/usr/bin/perl
use v5.10;
use strict;
use warnings;
use Path::Tiny;
use List::MoreUtils qw(uniq);
use Benchmark qw(cmpthese);
#!/usr/bin/perl
use v5.10;
use strict;
use warnings;
use Benchmark qw(cmpthese);
{
package MyMoo;
@schwern
schwern / gist:10081851
Created April 8, 2014 01:48
Demonstrate Moose breaking App::Cmd commands
#!/usr/bin/perl
{
package App::Cmd::Bug;
use App::Cmd::Setup -app;
BEGIN { $INC{"App/Cmd/Bug.pm"} = 1; }
}
{
package App::Cmd::Bug::Command::foo;
$ ps auwx | head -1
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
$ ps auwx | grep perl
schwern 4311 0.0 0.0 2442000 620 s000 S+ 3:30PM 0:00.00 grep perl
schwern 4309 0.1 1.0 2515688 80204 s001 S 3:30PM 0:00.14 perl -wle my @list = (1..1_000_000); open my $fh, ">>", "/dev/null"; sub foo {} foo(); sleep 9999
schwern 4301 0.0 1.0 2525552 88052 s001 S 3:30PM 0:00.14 perl -wle my @list = (1..1_000_000); open my $fh, ">>", "/dev/null"; sub foo {} foo(@list); sleep 9999
schwern 4304 0.0 1.0 2525928 80232 s001 S 3:30PM 0:00.47 perl -wle my @list = (1..1_000_000); open my $fh, ">>", "/dev/null"; sub foo {} print {$fh} @list; sleep 9999
schwern 4336 0.0 1.0 2517736 80236 s001 S 3:35PM 0:00.47 perl -wle my @list = (1..1_000_000); open my $fh, ">>", "/dev/null"; sub foo {} print {$fh} @list, "foo"; sleep 9999
#!/usr/bin/perl
use Devel::Peek;
sub foo {
print Dump( \@_ );
}
my @list = qw(1 2 3);
foo(@list);
$ ps auwx | head -1
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
$ ps auwx | grep perl
schwern 3574 0.0 0.0 2442000 628 s000 S+ 10:50AM 0:00.00 grep perl
schwern 3567 0.0 1.0 2507496 80168 s001 S 10:50AM 0:00.13 perl -wle my @list = (1..1_000_000); open my $fh, ">>", "/dev/null"; sleep 9999
schwern 3558 0.0 1.0 2517736 80244 s001 S 10:50AM 0:00.56 perl -wle my @list = (1..1_000_000); open my $fh, ">>", "/dev/null"; print {$fh} $_ for @list; sleep 9999
schwern 3557 0.0 1.0 2525928 80232 s001 S 10:50AM 0:00.45 perl -wle my @list = (1..1_000_000); open my $fh, ">>", "/dev/null"; print $fh @list; sleep 9999
#!/usr/bin/perl
use v5.10;
use strict;
use warnings;
use Benchmark qw(cmpthese);
my @list = (1..1_000_000);
local $, = '';
@schwern
schwern / gist:9943058
Created April 2, 2014 20:59
The fibnonacci sequence implemented as a method on an immutable integer class, with purely per object caching, for demonstration purposes.
#!/usr/bin/perl
use perl5i::2;
# A full on Integer class.
{
package _Integer;
use perl5i::2;
use Method::Signatures;