Skip to content

Instantly share code, notes, and snippets.

View skaji's full-sized avatar

Shoichi Kaji skaji

  • Kanagawa, Japan
  • 06:16 (UTC +09:00)
View GitHub Profile
@skaji
skaji / gist:5526580
Last active December 17, 2015 01:09
JSON::PP issue under perl-5.8.6
% wget http://search.cpan.org/CPAN/authors/id/M/MA/MAKAMAKA/JSON-PP-2.27202.tar.gz
% tar xzf JSON-PP-2.27202.tar.gz
% cd JSON-PP-2.27202
% echo 5.8.6 > .perl-version
% perl -Ilib -MJSON::PP -e 'JSON::PP->new->decode(qq|{ "a":0, "b":"\x{c0}" }|)' && echo OK
, or } expected while parsing object/hash, at character offset 7 (before ", "b":"\x{c0}" }") at -e line 1.
% echo 5.8.7 > .perl-version
@skaji
skaji / client.pl
Last active December 17, 2015 06:59
#!/usr/bin/env perl
use strict;
use warnings;
use 5.016;
use AnyEvent::HTTP;
$|++;
$AnyEvent::HTTP::MAX_PER_HOST = 8;
for my $i (1..100) {
http_get 'http://shoichi.me:5000', timeout => 10 => sub {
#!/usr/bin/env perl
use strict;
use warnings;
sub say { print @_, "\n" }
my @FIELD = qw( ip - user time req code size ref ua );
my %FIELD = map { $_ => 1 } @FIELD;
my @want = grep { exists $FIELD{$_} || help() } split /,/, shift or help();
while (<STDIN>) {
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Fcntl qw(:DEFAULT :seek :flock);
use autodie qw(:io);
my $file = shift or die "missing file name";
sysopen my $fh, $file, O_RDWR;
@skaji
skaji / ubuntu vim
Last active December 18, 2015 04:08
✗ vim --version 06/07 01:02
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Oct 26 2012 16:45:32)
Included patches: 1-547
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by buildd@
Huge version with GTK2-GNOME GUI. Features included (+) or not (-):
bin/
├── ex -> vim
├── rview -> vim
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Net::SSLeay;
use feature qw(say);
my $host = shift || 'www.google.co.jp';
my $port = shift || 443;
my $req = shift || '/';
@skaji
skaji / plenv-install.diff
Last active December 18, 2015 07:09
(cd ~/.plenv/plugins/perl-build; curl -sk https://gist.github.com/shoichikaji/5744179/raw | patch -p0)
diff --git bin/plenv-install bin/plenv-install
index 3055311..630f9c1 100755
--- bin/plenv-install
+++ bin/plenv-install
@@ -44,6 +44,8 @@ sub main {
'version!' => \my $version,
'h|help' => \my $help,
'l|list' => \my $list,
+ 'as=s' => \my $as,
+ 'test' => \my $test,
#!/bin/sh
DIR=`/usr/bin/perl -MCwd -MFile::Basename -e 'print dirname Cwd::abs_path shift' $0`
export PATH=$DIR/local/bin:$PATH
export PERL5LIB=$DIR/local/lib/perl5
exec perl app.pl
@skaji
skaji / Fork.pm
Last active December 18, 2015 22:59
package Fork;
use strict;
use warnings;
use IO::Pipe;
use Time::HiRes ();
sub run {
(undef, my %opt) = @_;
my $name = $opt{name} || 'Fork';
my $worker = $opt{worker} || 5;
@skaji
skaji / die.h
Last active December 19, 2015 03:59
#ifndef __DIE_H__
#define __DIE_H__
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#define die(msg) { \
if (errno) { \