Skip to content

Instantly share code, notes, and snippets.

View clicktx's full-sized avatar

clicktx / Munenori Sugimura clicktx

View GitHub Profile
@clicktx
clicktx / woothee_test.pl
Last active December 22, 2015 05:08
Woothee - multi-language user-agent strings parsers (perl implementation) https://metacpan.org/release/TAGOMORIS/Woothee-0.3.3 のテスト。tabletは判別されない、か。 UserAgent一覧は以下から抜粋 http://www.openspc2.org/userAgent/
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Data::Dumper;
use Woothee;
say Dumper (Woothee->parse("Mozilla/5.0 (Linux; U; Android 4.0.3; ja-jp; Sony Tablet S Build/TISU0R0110) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30"));
say Dumper (Woothee->parse("Mozilla/5.0 (Linux; U; Android 4.1.1; ja-jp; Galaxy Nexus Build/JRO03H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"));
@clicktx
clicktx / array.pl
Created March 31, 2013 04:00
アルゴリズムを学ぼうP48の問題: 戦略1をperlで書く。コピー回数のカウント用。
#!/usr/bin/env perl
use strict;
use warnings;
# 戦略1: 10だけ大きくした配列を作る戦略
my $array_ref =[('undef') x 10];
my $count = count();
run($ARGV[0]);
@clicktx
clicktx / powmod-benchmark.pl
Last active December 13, 2015 20:38
アルゴリズムで学ぼうのリスト1-1と1-2をperlで書いてCore 2 Duo 2GhzでBenchmark取ってみた
use strict;
use warnings;
use Benchmark qw(:all);
sub powmod1_1 {
my ($a, $k, $m) = @_;
my $t = 1;
for (my $i = 0; $i < $k; $i++){
$t = ($t * $a) % $m;
}
@clicktx
clicktx / powmod.pl
Last active December 13, 2015 20:38
アルゴリズムを学ぼう リスト1-2(perl) 実行される時にwarnだして思い出した感。9行目の条件をクリアした後の18行目のreturnが10行目に帰るっての忘れてたよ...
warn "結果:", powmod(2,10,5);
sub powmod
{
my ($a, $k, $m) = @_;
warn "powmod a:$a, k:$k, m:$m";
if (int $k == 0){ return 1; }
my $t = powmod($a, $k /2, $m);