Skip to content

Instantly share code, notes, and snippets.

@bokutin
bokutin / benchmark_sql_ll.pl
Created June 29, 2017 06:14
気になったので雑なの CPU時間 実時間
#!/usr/local/bin/perl
use Modern::Perl;
use Data::Section::Simple qw(get_data_section);
use File::Temp;
my $langs = get_data_section;
for my $lang (sort keys %$langs) {
my $code = $langs->{$lang};
#!/usr/local/bin/perl
use Modern::Perl;
use HTML::TreeBuilder::LibXML;
use JSON;
use LWP::UserAgent;
use URI;
use URI::QueryParam;
use YAML::Syck;
@bokutin
bokutin / benchmark_dbic_freeze_thaw.pl
Created May 14, 2016 21:00
DBIx::Class and sereal
#!/usr/bin/env perl
use rlib;
use MyApp::Container qw(container);
use Modern::Perl;
use Sereal qw(encode_sereal);
my $id = 1234;
my $rs1 = container('schema')->resultset('Item')->search(
https://fengmk2.github.io/blog/2011/fibonacci/nodejs-python-php-ruby-lua.html
% which python2.7
/opt/local/bin/python2.7
% python2.7 -V
Python 2.7.11
% time python2.7 fib.py
102334155
python2.7 fib.py 61.28s user 0.34s system 98% cpu 1:02.31 total
#!/usr/bin/env perl
use Modern::Perl;
use Data::Dumper;
use Data::Section::Simple qw(get_data_section);
use File::Temp;
use Text::Outdent qw(outdent);
my $sections = get_data_section;
@bokutin
bokutin / try_span_dates.pl
Last active August 29, 2015 14:06
Time::Momentさんかりっかり
#!/usr/bin/env perl
use Modern::Perl;
use Benchmark qw(:all) ;
use Data::Dumper;
use DateTimeX::Web;
use DateTime::Span;
use Date::Manip::Date;
use Date::Manip::Recur;
use Date::Calc qw(:all);
@bokutin
bokutin / gist:5f47b901c4d3975442cf
Last active August 29, 2015 14:03
Perl DateTime.pm vs Python relativedelta
@@ try_datetime.pl
#!/usr/bin/env perl
use Modern::Perl;
use DateTimeX::Web;
# http://www.houseabsolute.com/presentations/a-date-with-perl/#33
{
my $dt = DateTimeX::Web->new->strptime('%Y-%m-%d', '2009-02-01'); # 2009-02-01
@bokutin
bokutin / gist:6b639ac6d355f6206e43
Created May 23, 2014 00:08
tmux SSH_AUTH_SOCK
探したけどうまいものが見付からないので、メモ。。。
@@ ~/.zprofile
if [ -z "$TMUX" -a -n "$SSH_AUTH_SOCK" ]; then
file=`echo $SSH_TTY | sed -e 's/\//_/g'`
abs="$HOME/.ssh/$file"
echo "export SSH_AUTH_SOCK=\"$SSH_AUTH_SOCK\"; export SSH_CONNECTION=\"$SSH_CONNECTION\"" > $abs
#echo "wrote $abs"
fi
@bokutin
bokutin / gist:be7eac13477eadc57ecc
Last active August 29, 2015 14:00
FreeBSD リードエラーでgmirror片肺から戻せない
gmirrorで片肺なったのに新調したHDDを足してsyncしても次のエラーで落ちる。
May 4 22:46:35 lian kernel: GEOM_MIRROR: Request failed (error=5). ada2p3[READ(offset=1869273890816, length=131072)]
% bc -le "1869273890816 / 512"
3650925568.00000000000000000000
% bc -le "131072 / 512"
256.00000000000000000000
% dd if=/dev/ada2p3 of=/dev/null iseek=3650925568 count=256
(コンソールにエラー CAM status: ATA Status Error )
@bokutin
bokutin / vcard_to_h_donya.pl
Created May 1, 2014 20:14
連絡先.app から ストラップフォン2 へ電話帳を転送します
#!/usr/bin/env perl
use utf8;
use Modern::Perl;
use Data::Dumper;
use Docopt;
use Encode;
use IO::All;
use Lingua::JA::Kana;