Skip to content

Instantly share code, notes, and snippets.

🐪
I love Perl

Kenta Kobayashi kfly8

🐪
I love Perl
Block or report user

Report or block kfly8

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View bless coderef
use Benchmark qw(cmpthese);
sub hello { return 'HELLO' }
sub world { return 'WORLD' }
sub hello2 { return 'HELLO' }
*{"hello"} = bless \&hello, __PACKAGE__;
hello();
my $hello = \&hello;
@kfly8
kfly8 / F::P
Last active Jun 17, 2019
benchmark
View F::P
package Hello;
use Types::Standard -types;
use Function::Parameters;
fun message(Str $msg) {
return "HELLO $msg";
}
1;
View check.pl
use warnings;
CHECK {
warn "CALL check"
}
@kfly8
kfly8 / bench_arrayref.pl
Last active Oct 16, 2018
Benchmark JSON::Encode
View bench_arrayref.pl
use strict;
use warnings;
use JSON::XS qw(encode_json);
use Benchmark qw(cmpthese);
my $obj = [ map {
+{
name => 'foo',
age => 123,
View example-dv.t
use strict;
use warnings;
use utf8;
use Data::Validator;
use Types::Standard qw(Int);
use DDP;
sub strict_seq {
my $rule = Data::Validator->new(
@kfly8
kfly8 / SYNOPSIS.md
Last active May 14, 2018
Lodash.pm export design
View SYNOPSIS.md

general case

use Lodash;
# => export `_`

_->add(1,2) # => 3
_(list)->chain->head->value
@kfly8
kfly8 / example.md
Created Mar 3, 2018
Variable::Declaration example
View example.md
use strict;
use warnings;
use feature qw/say/;

use Variable::Declaration;
use Types::Standard '-all';

let $foo = 'hello';
say $foo; # => hello
@kfly8
kfly8 / benchmark-simple.pl
Created Dec 8, 2017
Benchmark Perl Type constraints
View benchmark-simple.pl
#!perl -w
use 5.10.0;
use strict;
use Benchmark qw(:all);
use Data::Validator;
use Function::Parameters qw/fun/;
use Kavorka fun => { -as => 'kavorka_fun' };
print "perl: $]\n";
@kfly8
kfly8 / app.psgi
Created Mar 24, 2015
session の finalizeがもたもた
View app.psgi
use strict;
use warnings;
use utf8;
use Amon2::Lite;
use Cache::Memcached::Fast;
use Plack::Session::Store::Cache;
get '/' => sub {
my $c = shift;
@kfly8
kfly8 / bbs.pl
Created Feb 28, 2015
Perl入学式 #6 の掲示板の練習問題で、DBに記事を格納する形にしてみる
View bbs.pl
#!/usr/bin/env perl
use Mojolicious::Lite;
use DBIx::Sunny;
app->attr(dbh => sub { DBIx::Sunny->connect('dbi:mysql:dbname=bbs', 'root','') });
get '/' => sub {
my $c = shift;
my $entries = app->dbh->select_all('SELECT * FROM entry');
You can’t perform that action at this time.