Skip to content

Instantly share code, notes, and snippets.

View sharifulin's full-sized avatar

Anatoly Sharifulin sharifulin

View GitHub Profile
@sharifulin
sharifulin / gist:309654
Created February 20, 2010 12:06
MooseX::Declare example
use MooseX::Declare;
our $VERSION = '0.02';
# XXX: fuck, please, refactoring me :)
class Geo::Message {
has 'data' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } );
method parse(Str $data) {
@sharifulin
sharifulin / gist:335531
Created March 17, 2010 18:11
Nested layouts for the Mojolicious
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => 'index';
get '/ok' => 'index_ok';
use Test::More;
plan tests => 6;
@sharifulin
sharifulin / gist:335581
Created March 17, 2010 18:44
Example template with virtual block in a Mojolicious
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => 'index_with_block';
shagadelic;
__DATA__
@sharifulin
sharifulin / gist:336431
Created March 18, 2010 14:58
Render, mail and render_local in the Mojolicious
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub {
my $self = shift;
$self->main::mail(
to => 'To',
from => 'From',
@sharifulin
sharifulin / gist:341151
Created March 23, 2010 13:19
Mojolicious routes in my real app
# check routes: script/app routes
my $r = $self->routes;
$r->route("/$_")->to("user-auth#$_") for qw(login signup forgot);
# check user
for($r->bridge->to('user-auth#check')) {
$_->route('/')->to('about#index');
$_->route('/movies')->to('movie#main');
@sharifulin
sharifulin / gist:347812
Created March 29, 2010 13:02
nginx.conf error
# error
proxy_intercept_errors on;
proxy_ignore_client_abort on;
recursive_error_pages on;
error_page 400 403 404 /404.html;
error_page 500 502 503 504 512 =200 /500.html;
@sharifulin
sharifulin / gist:391879
Created May 6, 2010 07:00
Mojolicious bug with parse url
#!/usr/bin/env perl
use lib qw(../mojo/lib);
use Mojolicious::Lite;
use utf8;
plugin(charset => {charset => 'utf-8'});
get '/author/:name' => sub {
my $self = shift;
warn $self->stash('name');
@sharifulin
sharifulin / gist:393323
Created May 7, 2010 11:52
Mojolicious routes
my $a = $r->route('/api/disk')->to('api-disk#');
$a->route('/')->to('#one');
$a->route('/add')->to('#add');
@sharifulin
sharifulin / gist:412016
Created May 24, 2010 15:37
Mojolicious routes: bridge
#!/usr/bin/perl
use common::sense;
use lib qw(../lib lib);
$ENV{MOJO_APP} ||= 'App';
use Mojolicious::Commands; Mojolicious::Commands->start;
package App;
use common::sense;
@sharifulin
sharifulin / gist:413185
Created May 25, 2010 14:30
Config file for my mojolicious app
{
server => {
www => 'http://www.site.ru',
media => 'http://media.site.ru',
},
log => {
level => 'error', # 'debug',
path => 'log/site.log',
},
cookie => {