Skip to content

Instantly share code, notes, and snippets.

View rsrchboy's full-sized avatar

Chris Weyl rsrchboy

View GitHub Profile
#!/usr/bin/env perl
#
# Chris Weyl <cweyl@alumni.drew.edu>
use strict;
use warnings;
use lib '/usr/share/bugzilla';
use Plack::App::CGIBin;
@rsrchboy
rsrchboy / gist:284409
Created January 23, 2010 03:34
RPM macros to generate a -tests subpackage automagically
#####################################################################
# Perl tests subpackage macros...
%perl_version %(eval "`%{__perl} -V:version`"; echo $version)
%perl_testdir %{_libexecdir}/perl5-tests
%cpan_dist_name %(eval echo %{name} | %{__sed} -e 's/^perl-//')
# easily mark something as required by -tests and BR to the main package
%tests_req() %{expand:\

SYNOPSIS

package Foo;
use Moose;

# mark overloads as methods and wipe other non-methods
use MooseX::MarkAsMethods autoclean => 1;

# define overloads, etc as normal
@rsrchboy
rsrchboy / gist:916155
Created April 12, 2011 19:04
MooseX::AutoDestruct
package MooseX::AutoDestruct;
# ABSTRACT: Clear your attributes after a certain time
use warnings;
use strict;
use namespace::autoclean;
# debugging
@rsrchboy
rsrchboy / gist:916174
Created April 12, 2011 19:11
MooseX::MarkAsMethods
package MooseX::MarkAsMethods;
# ABSTRACT: Mark overload code symbols as methods
use warnings;
use strict;
use namespace::autoclean;
use B::Hooks::EndOfScope;
@rsrchboy
rsrchboy / gist:916189
Created April 12, 2011 19:15
MooseX::AttributeShortcuts
package MooseX::AttributeShortcuts;
# ABSTRACT: Shorthand for common attribute options
use strict;
use warnings;
use namespace::autoclean;
use Moose ();
@rsrchboy
rsrchboy / gist:916208
Created April 12, 2011 19:29
git-trim-fork
#!/usr/bin/env perl
# A small scriptie to clean up all those branches that get carried over
# after a github fork that (99% of the time) end up cluttering everything up
# and obscuring your own branches :)
#
# This script is under the GNU GPL, either version 2 or (at your option) any
# later version.
#
# Chris Weyl <cweyl@alumni.drew.edu> 2010.
@rsrchboy
rsrchboy / gist:916212
Created April 12, 2011 19:32
git-checkin
#!/usr/bin/env perl
# This script is under the GNU GPL, either version 2 or (at your option) any
# later version.
#
# Chris Weyl <cweyl@alumni.drew.edu> 2010.
use common::sense;
use autodie 'system';
use opts;
@rsrchboy
rsrchboy / attribute.pl
Created May 8, 2012 22:12
Emulating multiple attributes
has config => (
traits => ['Hash'],
is => 'bare',
isa => 'HashRef[Str]',
lazy => 1,
# returns a hashref of key/value config pairs
builder => 'load_config',
handles => {
@rsrchboy
rsrchboy / lazy.pl
Created May 19, 2012 06:09
Cheap caching with AutoDestruct
# ta-da!
has expensive_value => (is => 'ro', lazy_build => 1);
sub _build_foo { ... something expensive ... }