Skip to content

Instantly share code, notes, and snippets.

View sharifulin's full-sized avatar

Anatoly Sharifulin sharifulin

View GitHub Profile
@sharifulin
sharifulin / gist:194660
Created September 27, 2009 07:54
Simple Mojo server
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
use lib "$FindBin::Bin/../../lib";
# Application
@sharifulin
sharifulin / Formating digital
Created November 10, 2009 17:50
Simple Perl code of formating digital
#!/usr/bin/perl
use common::sense;
sub D($) {
for (scalar reverse shift) {
s/(\d{3})(?=\d)/$1 /g;
return scalar reverse;
}
}
@sharifulin
sharifulin / say or die
Created November 26, 2009 10:47
say or die
#!/usr/bin/perl
use common::sense;
say 'hello, world' or die 'hello, world';
@sharifulin
sharifulin / gist:250702
Created December 7, 2009 08:03
Пересекаются ли два массива?
use common::sense;
my @a = qw(q w e r t y);
my @b = qw(u i o p q);
say 1 if grep { defined } @{{ map { $_ => 1 } @a }}{ @b };
@sharifulin
sharifulin / gist:261811
Created December 22, 2009 15:56
The Mojolicious example of routes (simple CRUD model)
#!/usr/bin/perl
use common::sense;
use lib '../lib';
$ENV{MOJO_APP} ||= 'App';
use Mojolicious::Commands; Mojolicious::Commands->start;
package App;
use common::sense;
@sharifulin
sharifulin / gist:282378
Created January 20, 2010 22:53
Mojo: bug in routes
#!/usr/bin/perl
use strict;
use lib qw(lib ../mojo/lib);
$ENV{MOJO_APP} ||= 'App';
use Mojolicious::Commands; Mojolicious::Commands->start;
package App;
use strict;
@sharifulin
sharifulin / gist:292838
Created February 2, 2010 17:22
Mojo uploads
#!/usr/bin/env perl
use lib '../mojo/lib';
BEGIN { $ENV{MOJO_TMPDIR} = 'tmp/upload' };
use Mojolicious::Lite;
use Data::Dumper;
get '/' => 'form';
post '/' => sub {
@sharifulin
sharifulin / gist:295758
Created February 5, 2010 12:48
FFmpeg config for scale video size
#!/usr/bin/perl
use strict;
my @SOURCE = (2000, 1500);
my @FORMAT = (1920, 1080);
my $K = '16x9';
my @check = check_video($SOURCE[0], $SOURCE[1], $FORMAT[0], $FORMAT[1], $K);
my $x = $check[1] / 2;
@sharifulin
sharifulin / gist:300243
Created February 10, 2010 11:55
App::Controller for Mojolicious apps
package App::Controller;
use strict;
use base 'Mojolicious::Controller';
# alias
sub redirect {
my $self = shift;
@sharifulin
sharifulin / gist:300295
Created February 10, 2010 13:14
Find Mojo ENV in mojo distributive
# find all env
find ~/mojo/lib/ -type f -print0 | xargs -0 grep -on -E --colour 'MOJO_[A-Z_]+'
# find uniq env
find ~/mojo/lib/ -type f -print0 | xargs -0 grep -oh -E --colour 'MOJO_[A-Z_]+' | sort -u
__END__
Total: 23
MOJO_APP