Skip to content

Instantly share code, notes, and snippets.

View hisaichi5518's full-sized avatar
🍑
吉高由里子

hisaichi5518 hisaichi5518

🍑
吉高由里子
View GitHub Profile
@hisaichi5518
hisaichi5518 / hoge.t
Created March 30, 2011 02:46
わけがわからないよ。
use strict;
use warnings;
use Test::More;
use IO::ScalarArray;
use ExtUtils::MakeMaker qw(prompt);
{
my $stdin = IO::ScalarArray->new(["hoge\n"]);
local *STDIN = *$stdin;
my $hoge = prompt("set: ", 1);
ok $hoge;
@hisaichi5518
hisaichi5518 / each-splice.pl
Created June 9, 2011 05:42
eachとspliceの速さ比較用コード
use strict;
use warnings;
use Benchmark qw(:all);
print "splice(), each(), keys(), values() Benchmark!!\n";
my %mapping = my @mapping = map {$_ => $_} (1..100);
cmpthese -1, {
splice => sub {
while (my ($key, $value) = splice @mapping, 0, 2) {}
@hisaichi5518
hisaichi5518 / test.pl
Created September 19, 2011 13:23
プロトタイプ宣言
sub hoge (&) {
my ($callback) = @_;
$callback->();
}
# subがない
hoge {
print "hisada\n";
};
@hisaichi5518
hisaichi5518 / fuga.pl
Created November 5, 2011 07:22
Malts::Web::Router::Simple::Declare
package MyApp::Web;
use strict;
use warnings;
use parent qw(Malts Malts::Web);
sub startup {
my ($self) = @_;
MyApp::Web::Dispatcher->dispatch($self) or $self->not_found;
}
@hisaichi5518
hisaichi5518 / Cached.pm
Created November 17, 2011 02:15
Plack::Request::Cached
package Plack::Request::Cached;
use 5.008_001;
use strict;
use warnings;
use Variable::Magic qw/cast wizard VMG_OP_INFO_NAME/;
use Scalar::Util qw/refaddr weaken/;
use Class::Method::Modifiers::Fast qw(install_modifier);
use Data::Util qw(install_subroutine get_code_ref);
use Plack::Request;
@hisaichi5518
hisaichi5518 / hoge.pl
Created November 17, 2011 07:45
Devel::Symdumpの例
use Devel::Symdump;
use Amon2::Web;
print Devel::Symdump->new('Amon2::Web')->as_string;
@hisaichi5518
hisaichi5518 / gist:1395166
Created November 26, 2011 06:21
Data::Wheren使ってみた。
use strict;
use warnings;
use Data::Wheren::7Bit;
sub say {
print @_, "\n";
}
my $wheren = Data::Wheren::7Bit->new;
my $lat = 35.3137;
@hisaichi5518
hisaichi5518 / fuga.t
Created November 28, 2011 04:05
DBIx::Unko
use strict;
use warnings;
use utf8;
use Test::More;
use DBI;
use DBIx::Unko;
my $dbh = DBI->connect(...);
my $unko = DBIx::Unko->new(dbh => $dbh, namespace => 'Geri');
my $geri = $unko->create_factory(
testtetstest
use strict;
use warnings;
package Fuga;
sub fuga { "1" }
package main;
use Data::Dumper;
my $hoge = \&Fuga::fuga;