Skip to content

Instantly share code, notes, and snippets.

View kamipo's full-sized avatar

Ryuta Kamizono kamipo

View GitHub Profile
We couldn’t find that file to show.
use strict;
use MogileFS::Client;
use MIME::Types;
my $mogc = MogileFS::Client->new(
domain => ($ENV{DOMAIN} || 'yapc2009'),
hosts => ['127.0.0.1:7001'],
) or die "Could not initialize MogileFS";
use Plack::Request;
package LWP::UserAgent::ProxyConnect;
use strict;
use warnings;
our $VERSION = '0.01';
use LWP::UserAgent ();
{
use LWP::Protocol::http ();
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
BEGIN {
my @table = (0 .. 9, 'A' .. 'Z', 'a' .. 'z', '_', '-');
use constant NUM64 => \@table;
use constant DIGIT => 6;
function cpan-uninstall {
perl -MConfig -MExtUtils::Install -le '
($FULLEXT = shift) =~ s{::}{/}g;
if ($_ = $ENV{PERL_MM_OPT}) {
s/INSTALL_BASE=//;
$_ .= "/lib/perl5/$Config{archname}/auto/$FULLEXT/.packlist";
}
else {
$_ = "$Config{sitearchexp}/auto/$FULLEXT/.packlist";
}
#!/usr/bin/perl
package string;
use overload '""' => sub { ${$_[0]} };
sub __ : method : lvalue { substr(${$_[0]}, $_[1], $_[2]) }
package main;
use Data::Dump qw/dump/;
sub p { print dump(@_), "\n" }
sub _ { local $_ = $_[0]; bless \$_, 'string' }
<?php
$connect_info = file_get_contents('connect_info.json');
$connect_info = json_decode($connect_info, true);
foreach (explode(";", $connect_info["dsn"]) as $line) {
list($key, $value) = explode("=", $line);
$connect_info[$key] = $value;
}
use strict;
use Data::Dumper;
sub foo {
my ( $a_ref, $key, $value ) = @_;
eval join('->', '$a_ref', map "{$_}", split /\./, $key) . ' = $value';
return $a_ref;
}
my $ref = {
@kamipo
kamipo / hanoi.pl
Created April 15, 2010 18:09
hanoi
#!/usr/bin/perl
use strict;
use warnings;
sub hanoi {
my ($from, $to, $spare, $num) = @_;
my $hanoi = $num > 1 ? \&hanoi : sub {};
$hanoi->($from, $spare, $to, $num - 1);
@kamipo
kamipo / prime.pl
Created April 30, 2010 09:32
素数を求める(新卒のときの課題)
#!/usr/bin/perl -l
use strict;
use Time::HiRes;
my $start_time = Time::HiRes::time;
main(int($ARGV[0]) || 10_000);
my $end_time = Time::HiRes::time;
my $computation_time = $end_time - $start_time;