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 common::sense; | |
use lib 'lib'; | |
my $log = Mojo::Log::My->new; | |
$log->warn('sss'); | |
package Mojo::Log::My; | |
use base 'Mojo::Log'; | |
use Fcntl ':flock'; |
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
# сходу написал так, но завелось только на 3000 (дефолтном порту) | |
app->start('daemon', '--listen http://*:5000'); | |
# затем так | |
app->start('daemon', listen => 'http://*:5000'); | |
# посмотрел Mojo::Server::Daemon | |
app->start('daemon', listen => ['http://*:5000']); | |
# и даже так попробовал |
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 ojo; | |
use Test::More tests => 2; | |
my $ok = q( | |
<table class="post_table"> | |
<xtr> | |
<td> | |
<table class="reply_table"> | |
<tr> | |
<td class="info"> |
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 App::Index; | |
use App::Base -controller, with => ['App::News', 'App::Book', 'App::Audio']; | |
sub main { | |
my $self = shift; | |
my $limit = $self->conf('limit')->{index}; | |
$self->render('index', | |
news => $self->news->_last(limit => $limit->{news}), | |
book => $self->book->_list, |
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 App::Base; | |
use Mojo::Base; | |
use common::sense; | |
# code from Mojo::Base | |
sub import { | |
my $class = 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
use Mojolicious::Lite; | |
post '/' => sub { | |
my $self = shift; | |
my @test = $self->req->param('test'); | |
return $self->render_text(join "\n", @test); | |
}; | |
use Test::Mojo; |
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
log_format view | |
'$remote_addr - $remote_user [$time_local] $status ' | |
'"$request" $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" [$request_time]'; | |
server { | |
server_name www.site.com; | |
access_log off; | |
charset utf-8; |
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 DBI::Util; | |
use base 'DBI'; | |
use Carp 'croak'; | |
our $VERSION = '0.5'; | |
sub _parse_cfg { | |
my $cfg = shift || croak 'Bad config'; | |
my $attr = {%{shift || {}}, 'PrintError' => 0, 'RaiseError' => 1}; | |
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 Util; | |
use strict; | |
use utf8; | |
our $VERSION = '0.5'; | |
sub dumper(@) { | |
use Data::Dumper; | |
local $Data::Dumper::Terse = 1; local $Data::Dumper::Indent = 0; local $Data::Dumper::Varname = 0; |
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
warn $self->_format_crc(join('', 'a'..'z'), 17, '...', 4); | |
sub _format_crc { | |
my $self = shift; | |
my $crc = shift; | |
my $size = shift || 15; | |
my $miss = shift || '...'; | |
my $end = shift || 4; | |