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
sub _format_byte { | |
my $self = shift; | |
my $byte = shift; | |
my $str; | |
for (reverse [ 1 => 'B' ], [ 1024 => 'KB' ], [ 1024 ** 2 => 'MB' ], [ 1024 ** 3 => 'GB' ], [ 1024 ** 4 => 'TB' ]) { | |
my $temp = $byte / $_->[0]; | |
$str = sprintf "%0.2f $_->[1]", $temp; | |
$str =~ s/\.?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
use common::sense; | |
my $n = 1.229; | |
my $n = 4; | |
say 1 + $1 if $n =~ /(\d+)\./; # simple and good! | |
say $n =~ /(\d+)\./ && $1 + 1; # not pretty :) |
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 'lib'; | |
use Mojolicious::Lite; | |
use Test::Mojo; | |
use Test::More tests => 8; | |
use Data::Dumper; |
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 lib 'lib'; | |
use ojo; | |
use Test::More tests => 4; | |
my $xml = do { local $/; <DATA> }; | |
my $x = x($xml); |
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 Mojolicious::Lite; | |
get '/' => 'about/what' ; | |
get '/who' => 'about/who' ; | |
get '/what' => 'about/what' ; | |
get '/where' => 'about/where'; | |
get '/code' => 'about/code' ; |
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
my $imgs = eval { $net->request( | |
method => 'artist.getImages', | |
artist => $artist, | |
)->{images} }; | |
unless ($@) { | |
if (my @imgs = | |
map { | |
my $h = { | |
map { $_->{name} => $_->{'#text'} } |
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 utf8; | |
get '/' => 'index'; | |
get '/:groovy' => sub { | |
my $self = shift; | |
$self->render(text => $self->param('groovy'), layout => 'funky'); |
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 | |
BEGIN { $ENV{MOJO_MAX_MESSAGE_SIZE} = 50 * 1024 * 1024; } | |
use Mojolicious::Lite; | |
my $conf = { path => 'data/uploads/', ext => qr/\.(?i:mp3|wav|wma|ogg)$/ }; | |
post '/uploadify/check' => sub { | |
my $self = shift; | |
my $param = $self->req->params->to_hash; |
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 lib 'lib'; | |
package Mojolicious::Plugin::IncludeHelpers; | |
use strict; | |
use warnings; | |
use base 'Mojolicious::Plugin'; | |
use Data::Dumper; |
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
# controller | |
sub list { | |
my $self = shift; | |
my $DB = $self->app->db; | |
my $where = $self->stash('act') ? 'status=' . $DB->quote( $self->stash('act') ) : 1; | |
$self->stash( | |
page => $_, |