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 strict; | |
use warnings; | |
my $length = shift // 64; | |
my $mode = shift // 'default'; # alphabet,small,capital,number,complex | |
my @special_chars = ('_','-','?','=','^','[',']','{','}','&','$','#','@','!','*','~','`','%','(',')','+','|',':',';','"',"'",'<','>',',','.','/','\\'); | |
my @small_chars = ('a' .. 'z'); | |
my @capital_chars = ('A' .. 'Z'); |
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 bignum (a => 200); | |
# error function | |
sub erf { | |
my $x = shift; | |
$x = $x * sqrt(2); | |
my $sqrt2pi = sqrt(2 * 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027); | |
my $t = 1.0/(1.0 + 0.2316419*abs($x)); |
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 MapReduce::Framework::Simple; | |
my $mfs = MapReduce::Framework::Simple->new( | |
skip_undef_result => 1, | |
warn_discarded_data => 1 | |
); | |
my $data_map_reduce = [ |
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
eval($code=q{ | |
# Quine like self-rewriting program | |
# 1st : $ perl quine.pl > a1.pl | |
# repeat : $ perl a1.pl > a2.pl ; cat a2.pl ; cp a2.pl a1.pl | |
$str=" | |
XXXXXXXXXX | |
A | |
XXXXXXXXXX | |
"; |
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 MapReduce::Framework::Simple; | |
use Data::Dumper; | |
use DBI; | |
my $mfs = MapReduce::Framework::Simple->new(); | |
my $data_bk = |
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 list_unique{ | |
my $left = shift; | |
my $right = shift; | |
my @list = (@$left,@$right); | |
my %tmp1; | |
my @unique = grep { !$tmp1{$_}++ } (@list); | |
return @unique; |
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; | |
my $sum = 0; | |
for(1 .. 3_000_000_000){ | |
$sum += $_; | |
} | |
print $sum,"\n"; |
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
# You can startup MR worker by one liner below. | |
# $ perl -MYCGL::Lite -e 'YCGL::Lite->new->plack->plackup_eval("/eval");' | |
# Example: Word count | |
use strict; | |
use warnings; | |
use YCGL::Lite; | |
use Data::Dumper; | |
my $ycgl = YCGL::Lite->new(); |
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 IO::Socket::SSL; | |
while(1){ | |
my $c = IO::Socket::SSL->new( | |
PeerAddr => "localhost", | |
PeerPort => 5001, | |
Proto => "tcp", | |
SSL_verify_mode => 'SSL_VERIFY_NONE' |
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 Plack::MIME; # mimeタイプ自動判別用 | |
use Data::Dumper; | |
use File::Slurp; # 効率的な静的ファイル応答 | |
# 静的ファイル置き場 | |
my $public_dir = './public'; | |
# ディレクトリインデックスの指定 |
NewerOlder