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
# domain.com nginx config | |
server { | |
listen 443; | |
server_name domain.com; | |
return 301 https://www.$server_name$request_uri; | |
} | |
server { | |
listen 80; |
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
# the helper | |
$app->helper( | |
testarray => sub { | |
my $self = shift; | |
my @array = ("Quarter","Dime","Nickel"); | |
return \@array; | |
} | |
); |
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
my $foo = $r->bridge('/foo')->to(cb => sub { | |
my $self = shift; | |
$self->app->log->debug('foo cb'); | |
return 1; | |
}); | |
$foo->route('/')->to(cb => sub { | |
my $self = shift; | |
$self->app->log->debug('foo/ cb'); |
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 Mojolicious::Plugin::Pipeline::CSSCompressor; | |
use Mojo::Base 'Mojolicious::Plugin'; | |
use CSS::Compressor 'css_compress'; | |
sub register { | |
my ($self, $app) = @_; | |
# Register "css_compressor" filter | |
$app->filter(css_compressor => sub { css_compress shift }); |
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
%= t 'table', class => 'myclass', => begin | |
%= t 'tr', => begin | |
%= t 'td', => begin | |
cell content | |
% end | |
% end | |
% end |
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
my $arrayref; | |
for ( 1..5 ) { | |
push(@$arrayref, $_); | |
} | |
$collection->insert({arrayref => $arrayref}); | |
> db.test.find().pretty(); | |
{ | |
"_id" : ObjectId("511502d0acd47abc56010000"), |
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
<h2>Mango Cheatsheet</h2> | |
% my $mango = Mango->new('mongodb://localhost:27017')->db('foo')->collection('foo'); | |
% my @records; | |
% for my $cntr (1..10) { | |
% | |
% my @objects; |
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
$self->hook( | |
before_dispatch => sub { | |
my $c = shift; | |
if (!$c->param('layout')) { | |
if ($c->req->is_xhr) { | |
$c->stash(layout => 'ajax'); | |
} | |
} | |
..... |
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
CORE | |
Perl (v5.16.0, darwin) | |
Mojolicious (3.12, Rainbow) | |
OPTIONAL | |
EV (not installed) | |
IO::Socket::IP (not installed) | |
IO::Socket::SSL (not installed) | |
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; | |
# Documentation browser under "/perldoc" | |
plugin 'PODRenderer'; | |
get '/' => sub { | |
my $self = shift; | |
$self->render('index'); | |
}; |
NewerOlder