Skip to content

Instantly share code, notes, and snippets.

@zby
zby / gist:766589
Created January 5, 2011 16:59
After constants removal, before main DI
package MyClass;
sub new {
my ( $class, $dsn, $user, $password ) = @_;
my $self = bless {}, $class;
my $self->{dbh} = DBI->connect($dsn, $user, $password);
@zby
zby / gist:766588
Created January 5, 2011 16:57
Before removing constants
package MyClass;
sub new {
my ( $class ) = @_;
my $self = bless {}, $class;
$self->{dbh} = DBI->connect( 'DBI:mysql:database=db', 'dbuser', 'dbpassword' );
@zby
zby / NblogConstructor.pm
Created December 23, 2010 09:05
Constructing a Plack app with images search path and sessions
around psgi_callback => sub {
my $orig = shift;
my $self = shift;
my $cascade = Plack::App::Cascade->new;
my $favicon_c = Plack::App::Cascade->new;
for my $root ( $self->static_roots ){
$cascade->add( Plack::App::File->new(root => $root )->to_app );
$favicon_c->add( Plack::App::File->new( file => "$root/images/favicon.ico" )->to_app );
};
my $app = Plack::App::URLMap->new;
use strict;
use Devel::Peek;
binmode(STDOUT,":utf8");
for my $letter ( "\x{0411}", 'A' ){
print "Letter $letter\n";
Dump $letter;
if( $letter =~ /p{Latin}/ ){
print "matched p{Latin}: $1\n";
use MyApp;
my $app = MyApp->new();
$app->psgi_callback;
sub psgi_callback {
my $self = shift;
sub {
my $req = Plack::Request->new( shift );
$self->handle( $req );
};
}
use strict;
use warnings;
use Plack::Request;
sub {
my $env = shift;
# eval { die 'aaaaaaaaaaaaaaaaaaaa'; };
return [
'500',
[ 'Content-Type' => 'text/plain' ],
has_field 'date_time' => (
type => 'Compound',
apply => [
{
transform => sub { DateTime->new( shift ) },
message => 'This is not a correct date',
}
{
check => sub { shift->day_of_week == 1 },
message => 'Only Mondays allowed',
zby@zby:~/progs/Enzyme$ cpanp i Some::Module
Computing prerequisites.
You have unmet external prerequisites:
memcached
xslt version 1.1.18
...
Please install the prerequisites first then run the installation again.
zby@zby:~/progs/Enzyme$ cpanp i Cache::Memcached::Managed
Installing Cache::Memcached::Managed (0.20)
Running [/home/zby/local/bin/perl /usr/local/bin/cpanp-run-perl /home/zby/.cpanplus/5.10.1/build/Cache-Memcached-Managed-0.20/Makefile.PL]...
No executable memcached found: No such file or directory
Running [/usr/bin/make test]...
PERL_DL_NONLAZY=1 /home/zby/local/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
Can't exec "memcached": No such file or directory at /home/zby/.cpanplus/5.10.1/build/Cache-Memcached-Managed-0.20/blib/lib/Cache/Memcached/Managed.pm line 843.
#
# Stopped memcached server
# Looks like you planned 176 tests but ran 184.