Skip to content

Instantly share code, notes, and snippets.

View melo's full-sized avatar

Pedro Melo melo

View GitHub Profile
@melo
melo / TLS.pm
Last active February 22, 2017 15:32
Package MIME::Lite::TLS - **DEPRECATED** - look at Net::SMTPS at https://metacpan.org/release/Net-SMTPS
package MIME::Lite::TLS;
use strict;
use warnings;
use Net::SMTP::TLS;
use parent 'MIME::Lite';
=head1 NAME
HTTP (Starman) vs FastCGI (fastpass)
HTTP
Pros:
HTTP, easy for humans to debug
Also works directly behind load-balancers (without frontends)
Many PSGI server implementations, preforking Starman, Starlet and non-blocking Twiggy
Cons:
@melo
melo / perl_smoker
Created February 5, 2011 11:47
Script to use with Jenkins to smoke a Perl module
#!/bin/sh
#
# Use this as Jenkins Build "Execute shell" script
#
# Pedro Melo <melo@simplicidade.org>
## Die on any errors
set -ex
export OUTPUT=$WORKSPACE/logs
@melo
melo / gist:767856
Created January 6, 2011 13:03
strange problem with confess()
#
# Edited Class::MOP to this, around line 120:
catch {
unless (/^Can't locate \Q$file\E in \@INC/) {
# uncomment next line to temporarily work-around the problem
# s/ at / AT /gsm;
print "\n\n-------\n$_\n\n---------\n\n";
confess "Couldn't load class ($name) because: $_";
@melo
melo / moose_attr_traits.pl
Created December 23, 2010 16:35
How to use Moose attribute traits
##################
# Error management
has 'errors' => (
traits => ['Hash'],
is => 'bare',
isa => 'HashRef',
default => sub { {} },
handles => {
add_error => 'set',
@melo
melo / 00-method-signatures-overhead.pl
Created October 24, 2010 09:22
A benchmark comparing Method::Signatures with hand-written sub's
#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark 'cmpthese';
use Method::Signatures ':DEBUG';
sub sub_empty { }
func func_empty {}
@melo
melo / .bash_prompt
Created October 12, 2010 23:56
My PS1 bash setup
#!/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 / big.pl
Created September 29, 2010 20:05
#!perl
use strict;
use warnings;
use lib 'lib';
use Redis;
use Benchmark qw( cmpthese );
my $r = Redis->new(encoding => undef);
@melo
melo / Digest.pm
Created September 18, 2010 15:46
package Tarpipe::Connector::Digest;
use strict;
use warnings;
use Plack::App::Tarpipe;
use Digest::SHA1 qw(sha1_hex);
use Digest::MD5 qw(md5_hex);
## Definition of the connector
## GET uri will return the proper XML
package MyClass;
use Moose;
use MyTypes qw( MyDate );
use namespace::clean -except => 'meta';
has bday => (isa => MyDate, is => 'ro', coerce => 1);
__PACKAGE__->meta->make_immutable;
1;