Skip to content

Instantly share code, notes, and snippets.

View jjn1056's full-sized avatar

John Napiorkowski jjn1056

View GitHub Profile
@jjn1056
jjn1056 / gist:8785135
Created February 3, 2014 14:49
lazy inflate Datetime
package FastDateTimeField;
use overload
'""' => sub {
my $self = shift;
return $self->{__obj} || $self->{__field};
};
sub new {
package MyApp::Controller::User;
use Catalyst::Controller;
has 'user' => (is=>'ro', model=>'User');
action show :Chained(/) Args(0) ResponseBody
{
return $self->profile_info;
}
package Catalyst::Plugin::SubRequest;
use strict;
use warnings;
use Plack::Request;
our $VERSION = '0.20';
=head1 NAME
jnap@jnapcedev:~/src/CE$ ./extlib/build-package-list
MyCPAN::App::DPAN::Indexer 1.28
Processing 938 distributions
One * = 1 distribution
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package MyyApp::Controller::User;
use base 'Catalyst::Controller';
has target_controller => (is=>'ro', handles=>'foo');
sub myaction :Local {
my ($self, $c) = @_;
$self->foo;
}
=head1 PSGI Middleware and the Future of Catalyst
The PSGI specification describes middleware as:
=over 4
"A middleware component takes another PSGI application and runs it. From the perspective of a server, a middleware component is a PSGI application. From the perspective of the application being run by the middleware component, the middleware is the server. Generally, this will be done in order to implement some sort of pre-processing on the PSGI environment hash or post-processing on the response."
=back

PSGI Middleware and the Future of Catalyst

The PSGI specification describes middleware as:

    "A middleware component takes another PSGI application and runs it. From the perspective of a server, a middleware component is a PSGI application. From the perspective of the application being run by the middleware component, the middleware is the server. Generally, this will be done in order to implement some sort of pre-processing on the PSGI environment hash or post-processing on the response."

@jjn1056
jjn1056 / gist:f191e635964a8a746bd7
Created July 17, 2014 12:37
this is a source clas; MyApp::Schema::Result::User
## UserPermission is a view on a stored procedure
sub search_user_permissions {
my ($self, $search, $attrs) = @_;
return $self->result_source->schema->resultset('UserPermission')
->search($search||{},{%{$attrs||{}},bind=>[$_[0]->id]});
}
sub search_agency_permissions {
Couldn't instantiate component "Arbac::Model::Schema", "Could not find a class for trait: Replicated at local/lib/perl5/MooseX/Traits/Pluggable.pm line 101.
MooseX::Traits::Pluggable::_transform_trait("Arbac::Model::Schema", "Replicated") called at local/lib/perl5/MooseX/Traits/Pluggable.pm line 107
MooseX::Traits::Pluggable::_resolve_traits("Arbac::Model::Schema", "Caching", "Replicated") called at local/lib/perl5/MooseX/Traits/Pluggable.pm line 157
MooseX::Traits::Pluggable::_build_instance_with_traits("Arbac::Model::Schema", "Arbac::Model::Schema", "Arbac") called at local/lib/perl5/MooseX/Traits/Pluggable.pm line 116
MooseX::Traits::Pluggable::new_with_traits("Arbac::Model::Schema", "Arbac", HASH(0x7ff60d210fd8)) called at local/lib/perl5/CatalystX/Component/Traits.pm line 143
CatalystX::Component::Traits::COMPONENT("Arbac::Model::Schema", "Arbac", HASH(0x7ff609f9d728)) called at local/lib/perl5/darwin-2level/Class/MOP/Method/Wrapped.pm line 45
Class::MOP::Method::Wrapped::__ANON__("Arbac::Model::Sc
@jjn1056
jjn1056 / gist:53f17b3eb57f7fb8e402
Created July 25, 2014 13:47
What psgix.io means to different servers
HTTP::Server::PSGI bless( \*Symbol::GEN2, 'IO::Socket::INET' );
Twiggy \*{'AnyEvent::Socket::'};
Starman bless( \*Symbol::GEN1, 'Net::Server::Proto::TCP' );
Feersum ????
Net::Async::HTTP::Server bless( \*Symbol::GEN1, 'IO::Socket::INET' );
Corona bless( \*Symbol::GEN2, 'Net::Server::Proto::TCP' );
Starlet bless( \*Symbol::GEN1, 'IO::Socket::INET' );
Thrall bless( \*Symbol::GEN4, 'IO::Socket::INET' );
Starlight bless( \*Symbol::GEN1, 'IO::Socket::INET' );
Monoceros \*{'Monoceros::Server::$fh'};