This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"fmt" | |
"os" | |
) | |
func main() { | |
test1() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
l1 := make([]string, 0, 0) | |
fmt.Println(append(l1, "1")) | |
fmt.Println(append(l1, "2")) | |
fmt.Println(append(l1, "3")) | |
fmt.Println(append(l1, "4"), append(l1, "5"), append(l1, "6")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://blog.64p.org/entry/2016/09/30/014358 | |
// | |
// orelang を Groovy で実装してみた | |
// | |
// "わりとよくある JSON ベースの lisp っぽいインタープリタの実装ですが、コードを見ていてもよくわからなかったので自分で実装しなおしてみました。" | |
// | |
class OreLang { | |
Map<String, Object> vars = [:] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.lang3.RandomUtils | |
import org.junit.Rule | |
import org.junit.rules.TemporaryFolder | |
import org.junit.rules.TestName | |
import org.springframework.util.StopWatch | |
import spock.lang.Shared | |
import spock.lang.Specification | |
class FileIOSpec extends Specification { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PathResolver { | |
String relativePath(String path1, String path2) { | |
[path1, path2].each{ checkPath(it) } | |
def (from, to) = cutCommonBaseDir(path1, path2) | |
(baseDir(from).replaceAll('[^/]+/', '../') ?: './') + to | |
} | |
private checkPath(path) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
fmt.Println("-----") | |
if err := hoge(); err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println("-----") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def f = new File("/tmp/test.dat") | |
f.text = "1234567890" * 2 | |
def tryRead(ins) { | |
def buff = new byte[9] | |
println ins.read(buff) | |
println new String(buff) | |
} | |
f.withInputStream { ins -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Helpers | |
// | |
void log(String message, boolean linefeed = true) { | |
if (linefeed) { | |
System.err.println message | |
} else { | |
System.err.print message | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApacheCollectionsSpec extends Specification { | |
def "BoundedFifoBuffer"() { | |
given: | |
def buffer = new BoundedFifoBuffer(3) | |
when: | |
buffer.add(1) | |
buffer.add(2) | |
buffer.add(3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.spockframework.runtime.SpockTimeoutError | |
import spock.lang.FailsWith | |
import spock.lang.Specification | |
import spock.lang.Timeout | |
import java.util.concurrent.CopyOnWriteArrayList | |
class PipedStreamsSpec extends Specification { | |
PipedOutputStream pout = new PipedOutputStream() |
NewerOlder