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 Mojolicious::Lite; | |
use DBM::Deep; | |
use Mojo::JWT; | |
plugin 'Bcrypt'; | |
plugin 'Minion' => {File => 'minion.db'}; | |
app->minion->add_task(send_email => sub { | |
my ($job, $address, $subject, $body) = @_; |
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 Mojolicious::Lite; | |
use Mango; | |
use JSON::XS 'encode_json'; | |
use Scalar::Util 'looks_like_number'; | |
helper mango => sub { state $mango = Mango->new('mongodb://localhost:27017') }; | |
helper world => sub { shift->mango->db('test')->collection('World') }; | |
helper fortune => sub { shift->mango->db('test')->collection('Fortune') }; | |
helper render_json => sub { shift->render( data => encode_json(shift), format => 'json' ) }; |
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 Mojo::Base -strict; | |
use Mojo::UserAgent; | |
use Mojo::IOLoop; | |
use Devel::Cycle; | |
my $ua = Mojo::UserAgent->new; | |
my $delay = Mojo::IOLoop->delay; | |
$delay->steps( |
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
Cycle (1): | |
$Mojo::UserAgent::A->{'connections'} => \%B | |
$B->{'6706b717d80b56a349b904c61e129fbf'} => \%C | |
$C->{'cb'} => \&D | |
$D variable $self => \$E | |
$$E => \%Mojo::IOLoop::Delay::F | |
$Mojo::IOLoop::Delay::F->{'remaining'} => \@G | |
$G->[0] => \&H | |
$H variable $ua => \$I | |
$$I => \%Mojo::UserAgent::A |
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 Mojo::IOLoop; | |
get '/error' => sub { | |
my $c = shift; | |
$c->render_later; | |
my $delay = Mojo::IOLoop->delay( | |
sub { die 'Argh' }, |
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 Mojo::IOLoop; | |
get '/error' => sub { | |
my $c = shift; | |
$c->delay( | |
sub { die 'Argh' }, | |
sub { $c->render( text => 'Lived!') }, |
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 Mojo::Base -strict; | |
use Test::More; | |
use Test::Mojo; | |
my $url = shift or die "Usage: $0 <url>\n"; | |
my $t = Test::Mojo->new; | |
$t->get_ok($url) |
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 DBIx::Connector; | |
my $dbname = $ENV{MOJO_DBNAME} || 'database.db'; | |
# add helper methods for interacting with database | |
helper connector => sub { | |
state $db = DBIx::Connector->new("dbi:SQLite:$dbname","","") or die "Could not connect"; |
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 Mango; | |
use Mojo::IOLoop; | |
use DDP; | |
use feature 'current_sub'; | |
plugin 'Config' => { | |
file => 'leaderboard.conf', |
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 experimental qw'signatures postderef'; | |
use Cwd; | |
app->attr( 'music_root' => sub { return $ENV{MUSIC_ROOT} || Cwd::cwd() } ); | |
push app->static->paths->@*, app->music_root; |
OlderNewer