Skip to content

Instantly share code, notes, and snippets.

View melo's full-sized avatar

Pedro Melo melo

View GitHub Profile
Testing Gist
@melo
melo / Main.pm
Created October 8, 2009 14:28
Solving a problem for a user in the Lisbon.pm list
package Main;
use base qw/DBIx::Class::Schema/;
__PACKAGE__->load_namespaces;
1;
package MyModule;
use Moose;
with 'MyModule::RequireAttr';
has attr => (
isa => 'Str',
is => 'rw',
);
package Xpto;
use Moose;
has built => (
isa => 'Int',
is => 'rw',
clearer => 'clear_built',
builder => '_build_built',
);
@melo
melo / gist:305397
Created February 16, 2010 08:47 — forked from cpinto/gist:305094
Keep most recent but don't delete original option
<body>
<select id="teste">
<option>item 1</option>
<option>item 2</option>
<option>item 3</option>
<option>item 4</option>
</select>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function()
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;
@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
@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 / .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 / 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 {}