Skip to content

Instantly share code, notes, and snippets.

View karupanerura's full-sized avatar
👷‍♂️
Please assign issue to me. but, I may be slow to respond.

karupanerura karupanerura

👷‍♂️
Please assign issue to me. but, I may be slow to respond.
View GitHub Profile
@karupanerura
karupanerura / entrypoint.go
Created December 13, 2018 09:34
basic event loop example
package main
import (
"fmt"
"time"
)
func entrypoint() {
fmt.Println("1")
setTimeout(func() {
@karupanerura
karupanerura / bench_arrayref.pl
Created October 16, 2018 06:05 — forked from kfly8/bench_arrayref.pl
Benchmark JSON::Encode
use strict;
use warnings;
use JSON::XS qw(encode_json);
use Benchmark qw(cmpthese);
my $obj = [ map {
+{
name => 'foo',
age => 123,
use strict;
use warnings;
package Node {
use Class::Accessor::Lite ro => [qw/value children/], new => 1;
}
# DSL
package main {
sub node ($;&) { goto \&_node }
@karupanerura
karupanerura / wasm_fs.js
Created September 7, 2018 13:35
My golang webasm filesystem extension plactice
// override filesystem
global.fs = (() => {
class Locks {
constructor() {
this.rw = null;
this.ro = [];
}
getLock() {
if (this.rw !== null) {
ウー! マンボー!
@karupanerura
karupanerura / perl-role-sample.pl
Last active May 23, 2018 03:37
Perlでインスタンスに対するRole適用を行うための匿名クラスとre-blessを用いた実装例
use 5.014000;
use Package::Stash;
use Scalar::Util qw/blessed refaddr/;
use Module::Functions;
package Role::Foo {
sub foo {
my $self = shift;
return "role foo by $self->{name}";
@karupanerura
karupanerura / blueprint.pl
Last active March 7, 2018 07:02
idea Scope::Timer
use Plack::ServerTiming;
use Scope::Timer; # it's not exist in the world yet :p
my $duration_time = timer {
...
};
Plack::ServerTiming->new($env)->record_timing('foo' => {dur => $duration_time});
@karupanerura
karupanerura / main.go
Last active September 11, 2017 06:43
go run a.go | sort | uniq -c | sort -nr
package main
import (
"fmt"
"strconv"
)
func main() {
values := map[string]string{}
for i := 0; i < 50; i++ {
@karupanerura
karupanerura / main.pl
Created June 26, 2017 13:57
Executable Gotanda Perl Mongers
use overload '.' => sub { print $_[0]->[0].'.'.$_[1].$/ };
sub Gotanda () { bless ["Gotanda"] }
sub pm () { 'pm' }
Gotanda.pm
use strict;
use warnings;
use Benchmark qw/cmpthese timethese/;
my @class = qw/Foo Foo::Bar Foo::Bar::Baz/;
sub substr_c {
my $class = shift;
substr $class, 1 + rindex $class, ':';