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 / jdk-triple-quote.diff
Created August 29, 2016 21:13
JDK triple quote patch
diff -r 6e14043ceae4 src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java Thu Aug 11 15:47:10 2016 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java Tue Aug 30 06:13:27 2016 +0900
@@ -629,6 +629,39 @@
break loop;
case '\"':
reader.scanChar();
+
+ if (reader.ch == '\"' && reader.bp < reader.buflen) {
+ reader.scanChar();
@tokuhirom
tokuhirom / password-prompt.pl
Created August 25, 2016 11:10
noecho prompting with IO::Prompt::Simple
use strict;
use Term::ReadKey;
use IO::Prompt::Simple;
use Scope::Guard qw/guard/;
my $guard = guard { Term::ReadKey::ReadMode(0) }; # restore
Term::ReadKey::ReadMode(4); # no echo
my $answer = prompt 'some question...';
package com.example;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.HashMap;
import java.util.Map;
@tokuhirom
tokuhirom / Dockerfile
Created June 27, 2016 16:06
Compile ansible as PIP wheel
# docker build -t ansible-wheel .
# docker run --rm -v $PWD/output:/output -t ansible-egg
FROM centos:6.6
RUN yum update -y
RUN yum install -y libffi-devel python-devel openssl-devel gcc wget
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python get-pip.py
@tokuhirom
tokuhirom / incremental-dom.js
Created June 14, 2016 04:59
Content disappear after rendering Incremental DOM twice
<!doctype html>
<html>
<head>
<script type="text/javascript" src="node_modules/incremental-dom/dist/incremental-dom.js"></script>
</head>
<body>
<x-foo></x-foo>
<x-foo></x-foo>
@tokuhirom
tokuhirom / process_exporter.rb
Last active May 10, 2016 01:17
process_exporter for prometheus' textfile exporter
class ProcessExporter
def initialize(filter=nil)
unless filter.nil?
@filter = /#{filter}/
end
end
def run
Dir.glob("/proc/*/stat") do |file|
next unless File.file?(file)
@tokuhirom
tokuhirom / Main.java
Last active January 21, 2022 09:37
tiny nonblocking http client for java
import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.channels.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.logging.Logger;
@tokuhirom
tokuhirom / httpd.pl6
Created October 17, 2015 13:55
This script stuck with `ab -c 10 -n 1000 http://127.0.0.1:15555/`
use v6;
my $port = 15555;
my $host = '127.0.0.1';
say "$host:$port";
react {
whenever IO::Socket::Async.listen($host, $port) -> $conn {
my $chan = $conn.chars-supply.Channel;
@tokuhirom
tokuhirom / e-fail.pl
Created October 12, 2015 22:33
IO::Path.e cache is too strong
use v6;
use Test;
unlink 'foobar.txt';
my $fh = open 'foobar.txt', :rw;
$fh.print('foo');
ok $fh.path.e;
@tokuhirom
tokuhirom / B.pm
Last active October 10, 2015 01:53
FAIL
# lib/C/B.pm
use v6;
unit class C::B;
method a() {
my $pkg = 'C::M';
require ::($pkg);
::($pkg).new();
say "DONE";
}