Skip to content

Instantly share code, notes, and snippets.

@ysasaki
ysasaki / MyApp::Controller
Created March 4, 2010 16:12
Mojolicious redirect_to_abs
package MyApp::Controller;
use strict;
use warnings;
use base 'Mojolicious::Controller';
sub redirect_to_abs {
my $self = shift;
my $url = $self->url_for(@_);
return $self->redirect_to($url->to_abs->to_string);
@ysasaki
ysasaki / gist:324903
Created March 8, 2010 05:40
Mojolicious - change response code and content_type
package MyApp::Example;
use strict;
use warnings;
use base 'Mojolicious::Controller';
sub default {
my $self = shift;
# to text/plain
@ysasaki
ysasaki / gist:326702
Created March 9, 2010 15:33
Mojolicious - send static file not in public path
package MyApp::Controller;
use strict;
use warnings;
use base 'Mojolicious::Controller';
use Path::Class;
sub sendfile {
my $self = shift;
my %args = @_;
package Plack::Middleware::Parallel::Scoreboard;
use strict;
use warnings;
use parent qw(Plack::Middleware);
use Plack::Util::Accessor qw(board base_dir path);
use Parallel::Scoreboard;
our $VERSION = '0.01';
sub prepare_app {
my $self = shift;
#!/usr/bin/env perl
use strict;
use warnings;
use XML::RPC;
use Data::Dumper;
my $blogid = 'xxxxxxx';
my $username = 'xxxxxxx';
my $password = 'xxxxxxx';
#!/usr/bin/env perl
package MT::Feed;
use strict;
use warnings;
sub new {
my $class = shift;
bless { entries => [], delimiter => "--------\n" }, $class;
}
#!/usr/bin/perl
use strict;
use warnings;
use YAML;
use Devel::Peek;
my $data = YAML::LoadFile('data.yaml');
print Dump($data->{hoge});
#!/usr/bin/perl
# Usage: read-password.pl --user hoge -p
use strict;
use warnings;
use Term::ReadPassword;
use Data::Dumper;
use Getopt::Long;
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 3;
my $xxx = "a";
my $str = "aaabbbaaabbb";
my $hit = 6;
diag "str => $str, char => $xxx, hit => $hit";
#!/usr/bin/env perl
# benchmark for
# http://gist.github.com/641766
use strict;
use warnings;
use Benchmark qw(cmpthese);
my $xxx = "a";