This file contains hidden or 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; | |
get '/tasks' => sub { | |
my $self = shift; | |
$self->stash( | |
tasks => [ | |
map { [ split /\s+/ ] } | |
split /\n/, qx(ps axh -o comm,stat,\%cpu,nice,pid,rss,user) | |
] |
This file contains hidden or 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 common::sense; | |
use lib qw(../.. /tk/lib /tk/mojo2/lib); | |
use ojo; | |
use Util; | |
use Unicode::Normalize 'NFD'; | |
use Data::Dumper; | |
my $conf = { |
This file contains hidden or 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 MyApp::Validation; | |
use Validation::Class; | |
use base 'Validation::Class'; | |
# a validation rule | |
field 'login' => { | |
label => 'user login', | |
error => 'login invalid', | |
validation => sub { |
This file contains hidden or 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 MyApp::Validation; | |
use Validation::Class; | |
use base 'Validation::Class'; | |
# a validation rule | |
field 'login' => { | |
label => 'user login', | |
error => 'login invalid', | |
validation => sub { |
This file contains hidden or 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 Application::Model::Sugar; | |
# common sugar routines | |
sub serial { | |
my %chngs = @_; | |
my %attrs = ('data_type', 'integer', 'is_auto_increment', 1, null() ); | |
$attrs{$_} = $chngs{$_} for keys %chngs; | |
return %chngs; | |
} |
This file contains hidden or 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 PiffHop; | |
use strict; | |
use warnings; | |
use base 'Mojolicious'; | |
# This method will run once at server start | |
sub startup { | |
my $self = shift; |
This file contains hidden or 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 DateTime; | |
use Mojolicious::Lite; | |
get '/' => 'index'; | |
get '/service/datetime' => sub { | |
my $self = shift; | |
my $dt = DateTime->now; |
This file contains hidden or 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 strict; | |
use warnings; | |
use Test::More tests => 6; | |
use Test::Mojo; | |
my $url = 'http://localhost/~rhaen/index.html'; | |
my $t = Test::Mojo->new; |
This file contains hidden or 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 Coro; | |
use Mojo::IOLoop; | |
Mojo::IOLoop->recurring(0 => sub {cede}); | |
hook around_dispatch => sub { | |
my $next = shift; | |
async { $next->() }; |
This file contains hidden or 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 EV; | |
use AnyEvent; | |
use AnyEvent::Util; | |
get '/' => sub { | |
my $self = shift; | |
# Run Perl oneliner in separate process and capture STDOUT | |
fork_call { |