Skip to content

Instantly share code, notes, and snippets.

View mdstoy's full-sized avatar

Toyofumi Takeda mdstoy

View GitHub Profile
@mdstoy
mdstoy / R.java
Last active June 7, 2019 09:54
「もう参照渡しとは言わせない 2018 冬」用 サンプルコード
import java.util.*;
public class R {
public static void main(String[] args) {
List<String> x = new ArrayList<>();
System.out.printf("x: %s\n", x); // "x: []"
add(x);
System.out.printf("x: %s\n", x); // "x: ["xxx"]"
}
@mdstoy
mdstoy / xml-format.vim
Created October 25, 2018 13:30
(Lazy) Formatting flat XML without line breaks
:%s/> *<\([^/]\)/>^M<\1/g | filetype indent on | setf xml | set et | set sw=4 | normal gg=G
@mdstoy
mdstoy / rename.sh
Created April 2, 2018 05:17
Renaming files that contain spaces in the file names
#!/bin/bash
for f in *.mp3; do mv "${f}" $(echo ${f} | awk '{print $1 ".mp3"}'); done
@mdstoy
mdstoy / VarAnonymousClass.java
Created March 21, 2018 06:57
当たり前だけど、クラスファイルは二つできてしまいますね。1 java ファイル に対して 1 class ファイルが義務付けられる現場の方はご愁傷さまでした。
public class VarAnonymousClass{
public static void main (String[] args) {
var obj = new Object(){
int value() {
return 1;
}
};
System.out.println(obj.value());
}
@mdstoy
mdstoy / get-kifu
Created January 12, 2018 15:23
(Lazy) One liner that create csa file from shogi wars kifu url
curl <kifu-url> | grep receiveMove | sed -E 's/( +receiveMove\("|[A-Z_]+"\);|,L[0-9]+)//g' | sed 's/^/PI\t+\t/' | sed 's/\t/\n/g' > [output-file]
import java.util.Optional;
public class Java9OptionalTrial {
public static void main(String[] args) {
new Java9OptionalTrial().ifPresentTrial();
}
public void ifPresentTrial() {
present().ifPresentOrElse(