Skip to content

Instantly share code, notes, and snippets.

View taichi's full-sized avatar
😸
shaving...

taichi taichi

😸
shaving...
View GitHub Profile
/**
* Asynchronously resolve the module path string id into cb(err, res [, pkg]), where pkg (if defined) is the data from package.json.
*/
declare function resolve(id: string, opts?: Options, callback?: (err?: Error, res?: any, pkg?: any) => string);
interface readFile { (filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; }
interface readFile { (filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void; }
interface readFile { (filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; }
interface readFile { (filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; }
@taichi
taichi / code_review_basics.md
Last active March 5, 2024 08:29
チームでコードを書き始めた後、「どうやらレビューってやつをした方が良いらしい」くらいの若手に向けた資料です。

コードレビューの基本


一番大事な事

ソースコードはプロジェクトの共同所有物である

  • 誰かだけが触れるコードを無くす
@taichi
taichi / gist:41603d7029e9cf18482b91cc933a1413
Created April 11, 2016 08:21 — forked from teppeis/gist:d7f40170902a9a4144a2
TypeScript用フルスタック型付きライブラリのご提案 (https://gist.github.com/teppeis/10659631 は間違えて消しちゃったので再投稿)
@taichi
taichi / JavaSAM.java
Created February 28, 2016 14:11
Kotlin SAM type conversion
package aaa;
public interface JavaSAM {
String doIt(int i, String s);
static void call(JavaSAM ms) {
System.out.println(ms.doIt(1, "zzzz"));
}
}
public static void main(String[] args) {
String[] tmpl = { //
"public void %s(CharSequence msg) {this.delegate.printMessage(Kind.%s, msg, null);}",
"public void %s(Supplier<CharSequence> msg) {this.delegate.printMessage(Kind.%s, msg.get(), null);}",
"public void %s(CharSequence msg,Element e) {this.delegate.printMessage(Kind.%s, msg, e);}",
"public void %s(Supplier<CharSequence> msg,Element e) {this.delegate.printMessage(Kind.%s, msg.get(), e);}",
"public void %s(CharSequence msg,Element e,AnnotationMirror a) {this.delegate.printMessage(Kind.%s, msg, e, a);}",
"public void %s(Supplier<CharSequence> msg,Element e,AnnotationMirror a) {this.delegate.printMessage(Kind.%s, msg.get(), e, a);}",
"public void %s(CharSequence msg,Element e,AnnotationMirror a,AnnotationValue v) {this.delegate.printMessage(Kind.%s, msg, e, a, v);}",
"public void %s(Supplier<CharSequence> msg,Element e,AnnotationMirror a,AnnotationValue v) {this.delegate.printMessage(Kind.%s, msg.get(), e, a, v)
/**
* @author taichi
*/
public class Zy {
// これから実装しようとしている処理
public static Optional<Integer> newFn(Optional<String> s) {
return s.flatMap(s2 -> {
Integer i = funkyOldFn(s2);
return i < 0 ? Optional.empty() : Optional.of(i);
@taichi
taichi / human.txt
Last active September 18, 2015 09:10
Json benchmark results. if you want to test yourself, try https://github.com/taichi/json-benchmarks
# JMH 1.10.5 (released 21 days ago)
# VM version: JDK 1.8.0_60, VM 25.60-b23
# VM invoker: C:\jdk1.8.0_60\jre\bin\java.exe
# VM options: -Dfile.encoding=windows-31j -Duser.country=JP -Duser.language=ja -Duser.variant
# Warmup: 10 iterations, 1 s each
# Measurement: 10 iterations, 1 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Average time, time/op
# Benchmark: json.benchmark.AutoBenchmark.ParserBenchmark.bufferdStream
@taichi
taichi / AtomicFieldUpdaters.java
Created June 22, 2015 02:31
use LongAccumulator instead.
public interface AtomicFieldUpdaters {
static <T> void max(T self, long value, AtomicLongFieldUpdater<T> updater) {
long max;
do {
max = updater.get(self);
if (value < max) {
break;
}
} while (updater.compareAndSet(self, max, value) == false);
/*
* Copyright 2015 SATO taichi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
public class ReturnTypeOverload {
public static void main(String[] args) {
Long lv = getValue();
System.out.println(lv);
String sv = getValue();
System.out.println(sv);
}