This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
=head1 DESCRIPTION | |
Adds branch name to the beginning of your commit message if branch name is | |
something like C<APP-1234> or C<APP-1111-GL123>, and message doesn't start with | |
branch name yet. | |
=head1 USAGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use experimental qw(signatures); | |
use Time::HiRes qw(gettimeofday tv_interval); | |
# Constants are faster than vars | |
use constant BAILOUT => 16; | |
use constant MAX_ITERATIONS => 1000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use lib 'lib'; | |
use Try::Tiny; | |
use Benchmark qw( cmpthese ); | |
use JSON::XS; | |
my $coder = JSON::XS->new->utf8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
perl -MBenchmark=cmpthese -E 'cmpthese(10000, { for => sub { my $i = 0; for (1..1000) { $i += $_; } }, map => sub { my $i=0; map { $i += $_; } 1..1000 }, foreach => sub { my $i=0; foreach (1..1000) { $i+=$_; } }, postfix_for => sub { my $i=0; $i+=$_ for 1..1000; }, postfix_foreach => sub { my $i = 0; $i += $_ foreach 1..1000; } });' | |
Rate map postfix_foreach for foreach postfix_for | |
map 12195/s -- -27% -27% -29% -33% | |
postfix_foreach 16667/s 37% -- -0% -3% -8% | |
for 16667/s 37% 0% -- -3% -8% | |
foreach 17241/s 41% 3% 3% -- -5% | |
postfix_for 18182/s 49% 9% 9% 5% -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package My::DB::ResultSet::Service; | |
use our::way; | |
use parent 'DBIx::Class::ResultSet'; | |
# Wrapper to exclude services with 'deleted' status from search | |
sub new { | |
my $class = shift; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Wrapper to exclude services with 'deleted' status from search | |
sub search_rs { | |
my $self = shift; | |
my $next_method = $self->next::can('search_rs'); | |
my $status_alias = $self->current_source_alias . '.status'; | |
return $self->$next_method(@_) | |
->$next_method({ $status_alias => { '!=' => 'deleted' } }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for f in `git status | grep modified | perl -lanE 'say $F[-1] if /[.](p[lm]|t)$/' | sort -u` | |
do perl -c $f | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/ $ ./copy-benchmark.pl | |
Rate plain plain_1_2 | |
plain 138889/s -- -70% | |
plain_1_2 458716/s 230% -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Attribute (details) does not pass the type constraint because: Validation failed for 'My::Details::Stored' with value My::Details=HASH(0x2e9c1b0) (not isa My::Details::Stored) at /opt/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/x86_64-linux/Moose/Meta/Attribute.pm line 1275 | |
Moose::Meta::Attribute::verify_against_type_constraint('Moose::Meta::Attribute=HASH(0x2ea4218)', 'My::Details=HASH(0x2e9c1b0)', 'instance', 'My::API::Request=HASH(0x2ea22e0)') called at /opt/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/x86_64-linux/Moose/Meta/Attribute.pm line 1262 | |
Moose::Meta::Attribute::_coerce_and_verify('Moose::Meta::Attribute=HASH(0x2ea4218)', 'My::Details=HASH(0x2e9c1b0)', 'My::API::Request=HASH(0x2ea22e0)') called at /opt/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/x86_64-linux/Moose/Meta/Attribute.pm line 531 | |
Moose::Meta::Attribute::initialize_instance_slot('Moose::Meta::Attribute=HASH(0x2ea4218)', 'Moose::Meta::Instance=HASH(0x2eaaf98)', 'My::API::Request=HASH(0x2ea22e0)', 'HASH(0x2eab478)') called a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Account; | |
use Moose; | |
use MooseX::LazyRequire; | |
has 'password' => ( | |
is => 'rw', | |
isa => 'Str', | |
); | |
__PACKAGE__->meta->make_immutable; |