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 5.10.1; | |
| use strict; | |
| use warnings; | |
| use Text::CSV; | |
| use Text::CSV_XS; | |
| use Encode; | |
| my $csv = Text::CSV->new ({ binary => 1 }); | |
| my $xs = Text::CSV_XS->new({ binary => 1 }); |
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
| package Result::User { | |
| use strict; | |
| use warnings; | |
| use utf8; | |
| sub new { bless {}, shift } | |
| sub to_model { | |
| my $self = shift; | |
| Model::User->new(user => $self); |
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
| $ ruby t.rb | |
| {:push=>[#<Proc:[email protected]:27>]} | |
| {:push=>[#<Proc:[email protected]:27>, #<Proc:[email protected]:29>]} | |
| {:push=>[#<Proc:[email protected]:32>]} | |
| {:push=>[#<Proc:[email protected]:32>, #<Proc:[email protected]:34>]} | |
| {:push=>[#<Proc:[email protected]:37>]} | |
| {:push=>[#<Proc:[email protected]:37>, #<Proc:[email protected]:39>]} |
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
| diff --git a/lib/Plack/Request/WithEncoding.pm b/lib/Plack/Request/WithEncoding.pm | |
| index 45d3d3f..aa8f36b 100644 | |
| --- a/lib/Plack/Request/WithEncoding.pm | |
| +++ b/lib/Plack/Request/WithEncoding.pm | |
| @@ -81,11 +81,34 @@ sub _decode_parameters { | |
| my @flatten = $stuff->flatten; | |
| my @decoded; | |
| while ( my ($k, $v) = splice @flatten, 0, 2 ) { | |
| - push @decoded, $encoding->decode($k), $encoding->decode($v); | |
| + push @decoded, $self->__decode($encoding, $k), $self->__decode($encoding, $v); |
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
| package HTTP::Body::JSON; | |
| use strict; | |
| use warnings; | |
| use parent qw(HTTP::Body); | |
| use JSON::XS; | |
| use HTTP::Body; | |
| use Encode qw(encode_utf8); | |
| # based on tokuhirom-san's 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
| use strict; | |
| use warnings; | |
| use List::Util; | |
| use Test::More; | |
| sub fill { | |
| my ($list) = @_; | |
| my $max = 10; | |
| [@$list, map { undef } 1..($max - scalar(@$list))] |
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 5.10.1; | |
| use strict; | |
| use warnings; | |
| use Getopt::Long; | |
| GetOptions( | |
| "count=i" => \my $count, | |
| ); |
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 strict; | |
| use warnings; | |
| sub hoge { | |
| my $test = {}; | |
| return { | |
| hoge => fuga() # γγγ«,γγͺγ | |
| %{$test}, | |
| } | |
| } |
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 Time::Moment; | |
| use DateTime; | |
| use DateTime::Tiny; | |
| use Time::Piece (); | |
| use Time::Piece::Plus (); | |
| use Benchmark qw(:all); | |
| use DateTime::TimeZone; | |
| my $time_zone = DateTime::TimeZone->new(name => "Asia/Tokyo"); |
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
| # -*- encoding: utf-8 -*- | |
| require 'cinch' | |
| require 'tumblr_client' | |
| bot = Cinch::Bot.new do | |
| configure do |c| | |
| c.server = "irc.server" | |
| c.port = 5000 | |
| c.password = 'secret' | |
| c.channels = ["#tumbirc"] |