Skip to content

Instantly share code, notes, and snippets.

View kfly8's full-sized avatar
🐪
Working from home

kobaken kfly8

🐪
Working from home
View GitHub Profile
use v5.38;
package User {
sub is_admin($user) {
$user->{role} eq 'admin'
}
sub is_editor($user) {
$user->{role} eq 'editor'
}
use v5.36;
use Test2::V0;
use Types::Common -types;
sub Fn :prototype($$) {
my ($Args, $Return) = @_;
unless (ref $Args eq 'ARRAY') {
Carp::croak "first argument must be an array reference (got $Args)";
}
@kfly8
kfly8 / gist:3989101b80918e674d567900b3ba5c6d
Created February 12, 2023 14:30
Perl Navigator server/src/hover.ts をいじって、前後の数行を表示してみる
diff --git a/server/src/hover.ts b/server/src/hover.ts
index e469b56..dfb7e60 100644
--- a/server/src/hover.ts
+++ b/server/src/hover.ts
@@ -22,6 +22,20 @@ export function getHover(params: TextDocumentPositionParams, perlDoc: PerlDocume
let hoverStr = buildHoverDoc(symbol, elem);
if(!hoverStr) return; // Sometimes, there's nothing worth showing.
+ const BEFORE_CONTEXT_COUNT = 3;
+ const AFTER_CONTEXT_COUNT = 3;
@kfly8
kfly8 / json_type_bench.pl
Created September 14, 2020 13:55
JSON::Types vs Cpanel::JSON::XS::Type
use v5.32.0;
use warnings;
use Benchmark qw(cmpthese);
use JSON::XS ();
use Cpanel::JSON::XS ();
use Cpanel::JSON::XS::Type;
use JSON::Types;
use constant Item => {
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 June 17, 2019 15:08
benchmark
package Hello;
use Types::Standard -types;
use Function::Parameters;
fun message(Str $msg) {
return "HELLO $msg";
}
1;
use warnings;
CHECK {
warn "CALL check"
}
@kfly8
kfly8 / bench_arrayref.pl
Last active October 16, 2018 06:05
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;
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 10:32
Lodash.pm export design

general case

use Lodash;
# => export `_`

_->add(1,2) # => 3
_(list)->chain->head->value