Skip to content

Instantly share code, notes, and snippets.

View nobeans's full-sized avatar

Yasuharu Nakano nobeans

  • Yokohama, Japan
View GitHub Profile
package main
import (
"errors"
"fmt"
"os"
)
func main() {
test1()
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"))
// http://blog.64p.org/entry/2016/09/30/014358
//
// orelang を Groovy で実装してみた
//
// "わりとよくある JSON ベースの lisp っぽいインタープリタの実装ですが、コードを見ていてもよくわからなかったので自分で実装しなおしてみました。"
//
class OreLang {
Map<String, Object> vars = [:]
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 {
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) {
@nobeans
nobeans / deffer_error_sample.go
Created June 12, 2019 06:53
defferでのエラーのハンドリング
package main
import "fmt"
func main() {
fmt.Println("-----")
if err := hoge(); err != nil {
fmt.Println(err)
}
fmt.Println("-----")
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 ->
//
// Helpers
//
void log(String message, boolean linefeed = true) {
if (linefeed) {
System.err.println message
} else {
System.err.print message
}
class ApacheCollectionsSpec extends Specification {
def "BoundedFifoBuffer"() {
given:
def buffer = new BoundedFifoBuffer(3)
when:
buffer.add(1)
buffer.add(2)
buffer.add(3)
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()