Skip to content

Instantly share code, notes, and snippets.

View schwern's full-sized avatar

Michael G. Schwern schwern

View GitHub Profile
#!/usr/bin/perl
use v5.10;
use strict;
use warnings;
use Benchmark qw(cmpthese);
{
package MyMoo;
@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);
@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: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
#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark qw(cmpthese);
my $String = "ATGC" x 1000;
my @Genes = qw(A T G C);
my %Count;
#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark qw(cmpthese);
my $String = "ATGC" x 1000;
my @Genes = qw(A T G C);
my %Count;
use strict; use warnings; use 5.010;
use DBI;
use Benchmark qw{:all} ;
my $EXECUTES_PER_PREPARE = 10;
my $BENCH_TIMES = int(200_000 / $EXECUTES_PER_PREPARE);
my $dbh = DBI->connect('DBI:mysql:database=test', '', '',
{RaiseError => 1, AutoCommit => 0}
);
$ perl -wle 'use Devel::Peek; $foo = 1.23; print $foo; print int $foo; Dump $foo'
1.23
1
SV = PVNV(0x7f99f3804730) at 0x7f99f4808350
REFCNT = 1
FLAGS = (NOK,POK,pIOK,pNOK,pPOK)
IV = 1
NV = 1.23
PV = 0x7f99f3609040 "1.23"\0
CUR = 4
$ git remote show origin
* remote origin
Fetch URL: git://github.com/CPAN-API/cpan-api.git
Push URL: git://github.com/CPAN-API/cpan-api.git
HEAD branch: master
Remote branches:
apeiron/signature-false-positive-pod tracked
apeiron/support-signed-dists tracked
grantm/#159 tracked
haarg/download-ssl tracked
@schwern
schwern / git-unpushed-ref
Last active August 29, 2015 14:15
Find the nth unpushed reference in the current branch.
#!/usr/bin/env perl
use strict;
use warnings;
sub current_branch {
my $branch=`git symbolic-ref --short HEAD`;
chomp $branch;
die "Cannot figure out the current branch.\n" unless $branch;