Skip to content

Instantly share code, notes, and snippets.

View melo's full-sized avatar

Pedro Melo melo

View GitHub Profile
@melo
melo / delegation.pl
Created October 21, 2011 16:41
Create delegations dynamically on roles
package DB;
use Moose;
sub create {
use Data::Dump qw(pp); print STDERR ">>>>>> ", pp(@_), "\n";
}
package Role;
@melo
melo / .bash_prompt
Created October 22, 2011 21:44
uber git PS1
#!/bin/bash
#
# PS1 magic
#
# Mostly copied from YUVAL KOGMAN version, added my own __git_ps1 stuff
# Original: http://gist.github.com/621452
#
# See video demo of this at http://vimeo.com/15789794
#
# To enable save as .bash_prompt in $HOME and add to .bashrc:
@melo
melo / snippet.pl
Created October 28, 2011 14:49
My tweaks to Test::More::subtest
sub tests {
my ($name, $subtests) = @_;
return if $ENV{SUBTEST_FOCUS} && $name !~ /$ENV{SUBTEST_FOCUS}/;
diag("Running '$name'");
return Test::More->builder->subtest(@_);
}
diff --git a/t/20-how-crud-of-you.t b/t/lib/HowCrudOfYou.pm
similarity index 99%
rename from t/20-how-crud-of-you.t
rename to t/lib/HowCrudOfYou.pm
index dd81086..e8b994c 100644
--- a/t/20-how-crud-of-you.t
+++ b/t/lib/HowCrudOfYou.pm
@melo
melo / Where does perl come from?
Created February 27, 2012 15:03
perl on CentOS
# rpm -qf /usr/bin/perl
perl-5.10.1-119.el6_1.1.i686
@melo
melo / gist:1937200
Created February 29, 2012 02:54
Compiling perl 5.14.2 with perlbrew on CentOS 6 64bit with mod_perl support
# the fpic is needed for mod_perl
# so is usesshrplib
# use 64bitall just makes sense as uselargefiles
# the ldflags mimic the settings of the system perl
perlbrew install -j 8 5.14.2 \
-Dcccdlflags=-fPIC \
-Duseshrplib \
-Duse64bitall \
@melo
melo / .perltidyrc
Created March 4, 2012 09:34
The quest for the perfect .perltidyrc
# My (almost) perfect perl tidy config file
-l=100 # Max line width is 100 cols - We are not on vt100 line terminals anymore
-i=2 # Indent level is 2 cols
-ci=2 # Continuation indent is 2 cols
-se # Errors to STDERR
-vt=2 # Maximal vertical tightness
-cti=0 # No extra indentation for closing brackets
-pt=2 # High parenthesis tightness
-bt=2 # High brace tightness
@melo
melo / gist:2365612
Created April 12, 2012 08:26
reminds me of something...
Naturally the common people don't want war... but after all it is the
leaders of a country who determine the policy, and it is always a
simple matter to drag the people along, whether it is a democracy, or
a fascist dictatorship, or a parliament, or a communist dictatorship.
Voice or no voice, the people can always be brought to the bidding of
the leaders. That is easy. All you have to do is tell them they are
being attacked, and denounce the pacifists for lack of patriotism and
exposing the country to danger. It works the same in every country.
-- Hermann Goering, Nazi and war criminal, 1883-1946
@melo
melo / Class.pm
Created April 26, 2012 09:27
My Perl class builder
package E6::Setup::Class;
use :5.14;
use warnings;
use utf8;
use Moose ();
use MooseX::HasDefaults::RO ();
use MooseX::StrictConstructor ();
use MooseX::AttributeShortcuts ();
use Try::Tiny ();
@melo
melo / bench_crc.pl
Created May 3, 2012 09:11
Digest::CRC vs String::CRC32
#!/usr/bin/env perl
use 5.014;
use warnings;
use Benchmark 'cmpthese';
use Digest::CRC ();
use String::CRC32 ();
my $payload = 'a' x 1024;