Skip to content

Instantly share code, notes, and snippets.

View adokoy001's full-sized avatar

Toshiaki_Yokoda adokoy001

View GitHub Profile
@adokoy001
adokoy001 / gen_rand.pl
Created May 19, 2021 01:27
Random string generator
#!/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');
@adokoy001
adokoy001 / rarity.pl
Created June 21, 2017 10:34
Error function and Rarity calculation with Gauss distribution.
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));
@adokoy001
adokoy001 / mr_prime.pl
Created June 7, 2017 12:07
Summation of Prime numbers by MapReduce::Framework::Simple
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 = [
@adokoy001
adokoy001 / quine.pl
Last active April 2, 2017 08:12
Quine like self-rewriting program in perl
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
";
@adokoy001
adokoy001 / db_example.pl
Created January 21, 2017 05:51
MapReduce::Framework::Simple
use strict;
use warnings;
use MapReduce::Framework::Simple;
use Data::Dumper;
use DBI;
my $mfs = MapReduce::Framework::Simple->new();
my $data_bk =
@adokoy001
adokoy001 / list_compare.pl
Last active September 20, 2016 14:28
List comparison in Perl
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;
@adokoy001
adokoy001 / bench_sum.pl
Created July 11, 2016 08:07
MapReduce::Framework::Simple Benchmark example.
use strict;
use warnings;
my $sum = 0;
for(1 .. 3_000_000_000){
$sum += $_;
}
print $sum,"\n";
@adokoy001
adokoy001 / MapReduce by YCGL::Lite
Created July 5, 2016 13:18
MapReduce by YCGL::Lite
# 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();
@adokoy001
adokoy001 / zinnia feature.cpp
Created May 18, 2013 22:14
zinniaの特徴量抽出方法
// zinniaの特徴量抽出は以下を参照
void Features::makeBasicFeature(int offset,
const Node *first,
const Node *last) {
// distance
addFeature(offset + 1 , 10 * distance(first, last));
// degree
addFeature(offset + 2 ,
@adokoy001
adokoy001 / prefork_ssl_echo_client.pl
Last active November 11, 2015 02:45
prefork ssl echo server and client
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'