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 / fail.p6
Created October 5, 2015 15:36
io-server-async and run on mac
use v6;
sub MAIN($port=5000) {
react {
whenever IO::Socket::Async.listen('127.0.0.1', $port) -> $conn {
run 'ls'; # process exits at here.
await $conn.print("yo");
$conn.close();
}
}
@tokuhirom
tokuhirom / client.pl
Last active October 1, 2015 07:21
perl6 react server stuck
use strict;
use warnings;
use utf8;
use 5.010000;
use IO::Socket::INET;
my $port = 3000;
my $n = 1000;
@tokuhirom
tokuhirom / hoge.pl
Created September 28, 2015 03:42
いっぱいファイル開いてるプロセスを検出してしきい値超えたら lsof の結果をファイルに吐くやつ
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use 5.010000;
use autodie;
use Term::ANSIColor;
use Getopt::Long;
use Time::HiRes qw/sleep/;
use Pod::Usage;
@tokuhirom
tokuhirom / perl6-precompile-all
Created September 21, 2015 03:20
pre-compile all perl6 modules
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use 5.010000;
use autodie;
use File::Find;
use Getopt::Long;
use File::Temp;
@tokuhirom
tokuhirom / avans2.md
Last active August 29, 2015 14:27
avans2 の新設計

Controller

コントローラクラスは、得になにも継承する必要はない。が、各プロジェクトで親になるクラスを作っておいたほうが便利。

基本的な見た目は 1 と変わらない。

public class EntryController {
  @GET("/entry/detail")
  public WebResponse index(@Param("id") long id) {
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.stream.Collectors;
public class Hoge {
public static void main(String[] args) throws IOException {
Files.readAllLines(Paths.get(args[0])).stream()
.flatMap(line -> Arrays.stream(line.split("\\W+")))
@tokuhirom
tokuhirom / rakudo-build
Created February 2, 2015 07:47
rakudo-build
#!/bin/sh
set -x
set -e
WORK=$HOME/.rakudo-build/
PREFIX=$HOME/perl6
mkdir -p $PREFIX
mkdir -p $WORK
rm -rf $WORK/rakudo
@tokuhirom
tokuhirom / fillinform.js
Created January 27, 2015 13:38
fillinform.js
(function () {
// public domain. buggy.
"use strict"
var elems = document.getElementsByClassName("fillinform");
var query = parseQuery();
for (var i = 0, l = elems.length; i < l; i++) {
var it = elems[i];
Object.keys(query).forEach(function (key) {
var input = it.querySelector("input[name=" + key + "]");
if (input.type == "checkbox") {
@tokuhirom
tokuhirom / DateTimeFormatterSample.java
Last active November 29, 2018 05:54
Java 8 Date And Time API - Sample code.
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
public class DateTimeFormatterSample {
public static void main(String[] args) {
String[][] patterns = new String[][]{
new String[]{"G", "appendText(ChronoField.ERA,"},
@tokuhirom
tokuhirom / moose.t
Created July 3, 2014 09:47
no Moose
use strict;
use warnings;
use Test::More;
ok(!eval { require Moose; 1; }, 'no Moose');
ok(!eval { require DateTime; 1; }, 'no DateTime');
ok(!eval { require Devel::StackTrace::WithLexicals; 1; }, 'no Devel::StackTrace::WithLexicals');
done_testing;