Skip to content

Instantly share code, notes, and snippets.

View tokuhirom's full-sized avatar
💖
Focusing

Tokuhiro Matsuno tokuhirom

💖
Focusing
View GitHub Profile
@tokuhirom
tokuhirom / Result
Created September 6, 2013 04:04
Time::Seconds and autodie?
[5.18.0] perl foo.pl
2013-09-05
[5.18.0] perl bar.pl
Bareword "ONE_DAY" not allowed while "strict subs" in use at bar.pl line 6.
Execution of bar.pl aborted due to compilation errors.
@tokuhirom
tokuhirom / pbvcp.pl
Created April 1, 2013 09:42
Reference implementation of pvbcp
use strict;
use warnings;
use 5.008001;
# Module code.
{
package Scalar::Bool;
use parent qw(Exporter);
use Scalar::Util ();
@tokuhirom
tokuhirom / pbvsp.md
Last active December 15, 2015 15:38
Perl5 Boolean Value Serializer Protocol(PBVSP)

Perl5 Boolean Value Serializer Protocol(PBVSP)

Status

Draft. Plase post a comment on gist.

Why?

Most programming languages have a native Boolean data type. Perl does not.

@tokuhirom
tokuhirom / SQLite_File.diff
Created March 26, 2013 03:20
SQLite_File does not works on BSD-ish systems.
diff --git a/lib/SQLite_File.pm b/lib/SQLite_File.pm
index 90456a3..991ea40 100755
--- a/lib/SQLite_File.pm
+++ b/lib/SQLite_File.pm
@@ -282,7 +282,7 @@ sub TIEHASH {
}
else {
# if no file specified, use a temp file...
- ($fh, $file) = tempfile();
+ ($fh, $file) = tempfile(EXLOCK => 0);
@tokuhirom
tokuhirom / Try.pm
Last active December 13, 2015 22:29 — forked from mattn/try-lite.pl
perl -I. mattn.pl
package Try;
use Carp;
$Carp::Internal{+__PACKAGE__}++;
*main::try = \&try;
sub try (&;%) { }
1;
@tokuhirom
tokuhirom / xslate-changes.txt
Created October 14, 2012 23:32
Xslate Changes < 1.5022
1.5021 で render の recursion call における segv が解消されている。
1.5020 で 1.5016 で導入されたキャッシュまわりのバグが解消されている。
1.5015以前にはキャッシュのリロードに失敗するバグがある
結論としてすべての Xslate ユーザーは 1.5021 以後にアップデートするべき。
# Foo.tra
my $Foo = class {
sub new() {
self.bless({})
}
sub bar() {
p("YAY");
}
}
$EXPORTABLE = $Foo;
@tokuhirom
tokuhirom / around.pl
Created October 5, 2011 09:22
around bug in Xslate
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use 5.010000;
use Text::Xslate;
use Data::Section::Simple qw(get_data_section);
my $xslate = Text::Xslate->new(
#!/usr/bin/env sudo perl
use utf8;
use strict;
use warnings;
use lib lib => glob 'modules/*/lib';
use Net::DNS::Nameserver;
use Path::Class;
use Perl6::Say;
sub random_string {
my $length = shift;
my @chars = ( 'A' .. 'Z', 'a' .. 'z', '0' .. '9' );
my $ret;
for ( 1 .. $length ) {
$ret .= $chars[ int rand @chars ];
}
return $ret;
}