Skip to content

Instantly share code, notes, and snippets.

View adokoy001's full-sized avatar

Toshiaki_Yokoda adokoy001

View GitHub Profile
@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 / partial_corr_demo.pl
Created December 25, 2014 11:06
Perl : PDLを使って偏相関係数行列を生成
use strict;
use warnings;
use PDL;
use PDL::Stats::Basic;
# モジュール化するまでも無いのでgistに載せます。
# ランダム要素を無くすと出力がInfになったりするのでそこはご愛嬌ということで。
# また、対角要素は-1になってしまいます。
# 偏相関係数行列を求める関数
sub partial_corr{
@adokoy001
adokoy001 / plack_psgi_example.pl
Created October 13, 2015 17:55
PSGI Plack example with Japanese comments.
use strict;
use warnings;
use Plack::MIME; # mimeタイプ自動判別用
use Data::Dumper;
use File::Slurp; # 効率的な静的ファイル応答
# 静的ファイル置き場
my $public_dir = './public';
# ディレクトリインデックスの指定
@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'
@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 / 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 / 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 / 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 / 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 / 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 = [