Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env perl
use strict;
use warnings;
use FindBin::libs;
use YAML;
use Sniffer::RTMP;
my $dev = $ARGV[0] or die 'require device name';
my $router = HTTP::Router->define(sub {
$_->with({ controller => 'users' }, sub {
$_->match('/login')->register;
$_->match('/logout')->register;
$_->match('/signup')->register;
});
});
package MyApp;
__PACKAGE__->request_class('MyApp::Request');
package MyApp::Request;
use strict;
use parent 'Catalyst::Request';
sub method {
#!/usr/bin/perl
use Data::OpenStruct::Deep;
my %hash = (
foo => 1,
bar => {
baz => 2,
},
);
diff --git a/lib/Mouse/Meta/Role.pm b/lib/Mouse/Meta/Role.pm
index 95bdca8..fd2fc11 100644
--- a/lib/Mouse/Meta/Role.pm
+++ b/lib/Mouse/Meta/Role.pm
@@ -107,7 +107,20 @@ sub apply {
for my $name ($self->get_attribute_list) {
next if $class->has_attribute($name);
my $spec = $self->get_attribute($name);
- Mouse::Meta::Attribute->create($class, $name, %$spec);
+
@masaki
masaki / gist:78645
Created March 13, 2009 16:38
ShipIt with Git
diff --git a/lib/ShipIt/VC/Git.pm b/lib/ShipIt/VC/Git.pm
index 9bf21d7..b5b6c2c 100644
--- a/lib/ShipIt/VC/Git.pm
+++ b/lib/ShipIt/VC/Git.pm
@@ -61,6 +61,18 @@ sub commit {
print $tmp_fh $msg;
my $tmp_fn = "$tmp_fh";
system($command, "commit", "-a", "-F", $tmp_fn);
+
+ if (my $where = $self->{push_to}) {
package MouseX::Log::Log4perl;
use Mouse::Role;
use Log::Log4perl;
our $VERSION = '0.01';
has 'logger' => (
is => 'rw',
isa => 'Log::Log4perl',
# release-0.01 (CPAN)
Benchmark: timing 10000 iterations of match, match_block, to_block, with...
match: 14.2198 wallclock secs (13.88 usr + 0.05 sys = 13.93 CPU) @ 717.88/s (n=10000)
match_block: 14.6266 wallclock secs (14.44 usr + 0.04 sys = 14.48 CPU) @ 690.61/s (n=10000)
to_block: 15.8561 wallclock secs (15.69 usr + 0.05 sys = 15.74 CPU) @ 635.32/s (n=10000)
with: 15.2271 wallclock secs (14.78 usr + 0.07 sys = 14.85 CPU) @ 673.40/s (n=10000)
# 32664d58be4ebfea9c445aa91bac1709e62ce5fa (Class::Accessor::Fast)
Benchmark: timing 10000 iterations of match, match_block, to_block, with...
match: 8.87748 wallclock secs ( 8.79 usr + 0.02 sys = 8.81 CPU) @ 1135.07/s (n=10000)
# Merb-like
use HTTP::Router::Declare;
my $router = router {
# path and params
match '/' => to { controller => 'Root', action => 'index' };
# path, conditions, and params
match '/home', { method => 'GET' } => to { controller => 'Home', action => 'show' };
#!/usr/bin/perl
use strict;
use warnings;
use Hash::Inflator;
use Hash::AsObject;
use Data::OpenStruct::Deep;
use Test::MockObject;
use Benchmark qw(:hireswallclock cmpthese);