This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"title" : "Technical Engineer: U.S.S.R.", | |
"id" : 127, | |
"ident" : "mechanicEngineer0" | |
}, | |
{ | |
"title" : "maxPiercingSeries", | |
"id" : 32, | |
"ident" : "maxPiercingSeries" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use Try::Tiny; | |
plugin 'disqus', { 'api_secret' => 'getyourownsecretplease', pass_api_errors => 1 }; | |
# This, of course, is total and utter overkill for something like this, | |
# but I figured if I'm going to write demonstration code, might as well | |
# go the whole hog. | |
plugin 'mongodb', { 'database' => 'disqusbridge' }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach my $key keys %hash { | |
print "key is: $key\n"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print "key is: $_" for keys %hash; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print('key is: ', $key, "\n") for(keys(%hash)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myPlugin = new Extension({ 'foo': 'bar'}); | |
myPlugin.hook('render_filter', function(output) { | |
output.replace('foo','bar'); | |
return output; | |
}); | |
app.register(myPlugin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package My::Plugin; | |
use strict; | |
use warnings; | |
use base 'TheApp::Plugin::Base'; | |
sub register { | |
my $self = shift; | |
my $app = shift; | |
$self->hook(render_filter => sub { s/foo/bar/ and return $_ }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub somecontroller { | |
my $self = shift; | |
my $foo = My::App::PaintBucket->new(); | |
$foo->paint(what => 'wall') || die My::App::Exception::NoPaintException->new(caller(1)); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Data::Dumper; | |
sub deflate { | |
my $self = shift; | |
my $doc = {}; | |
foreach my $attribute ($self->meta->get_all_attributes) { | |
# here be dragons, type checks, trait checks, and more | |
$doc->{$attribute->name} = $attribute->get_value($self); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you look at my Monger repository, imagine the following snippet being stuck in | |
# Monger.pm | |
BEGIN { | |
Moose::Meta::Class->meta->make_mutable; | |
Moose::Meta::Class->meta->add_before_method_modifier('make_immutable', sub { | |
my $self = shift; | |
my $name = $self->name; | |
# apply the dbref role if, and only if, we're a monger::document |
OlderNewer