Skip to content

Instantly share code, notes, and snippets.

View nobeans's full-sized avatar

Yasuharu Nakano nobeans

  • Yokohama, Japan
View GitHub Profile
var Backend = require('i18next-node-fs-backend');
//var Backend = require('i18next-sync-fs-backend');
var i18next = require('i18next');
var assert = require('power-assert');
var config = {
debug: true,
lng: 'en',
resources: {
var os = require('os');
var osType = os.type();
console.log(osType);
console.log(/^Windows/.test(osType));
console.log(/^Darwin$/.test(osType));
console.log(/^Windows/.test('Windows'));
console.log(/^Windows/.test('Windows_HOGE'));
var l = [1, 2, 3];
var l2 = Object.assign([], l, [4, 5]);
var l3 = l.concat();
l3[1] = "X";
console.log(l);
console.log(l2);
console.log(l3);
@groovy.transform.Immutable(copyWith = true)
class User {
String name
Integer age
}
def user = new User(name: "おれ", age: 18)
assert user.is(user.copyWith())
assert user.is(user.copyWith(name: "おまえ")) == false
// http://blog.64p.org/entry/2016/09/30/014358
//
// orelang を Groovy で実装してみた
//
// "わりとよくある JSON ベースの lisp っぽいインタープリタの実装ですが、コードを見ていてもよくわからなかったので自分で実装しなおしてみました。"
//
class OreLang {
Map<String, Object> vars = [:]
Grails
★Slf4jをつけないと%lineなどがnullになる
Slf4jをつけるとマシになるけど、100%OKではないっぽい...
残っただめなのはAST変換部分?→しかたない系?
nullableなDateがクリアできない
Boolean,Double, IntegerはOK(nullクリアできる)
データバインディングで空文字が無視される
convertEmptyStringsToNull: false が関係している?
class MyResource implements Closeable {
@Override
void close() {
println "Closed!"
}
}
new MyResource().withCloseable {
println "HOGE"
throw new RuntimeException("FAILED!")
@nobeans
nobeans / zundokoKiyoshiVsIio.groovy
Last active March 17, 2016 14:30
ずんどこキヨシ vs ずんの飯尾(ラスボス感) 〜声に出して読みたい飯尾〜
// (出典)
// ズンドコキヨシ http://qiita.com/shunsugai@github/items/971a15461de29563bf90
// ずんの飯尾(ラスボス感) http://alfalfalfa.com/articles/139689.html?utm_source=alfalfa&utm_medium=kanren_image2
def random = new Random()
// 飯尾が強すぎるので「ずん」を恣意的に水増ししてみる
def words = [["ずん"] * 5, "どこ", "の", "飯尾"].flatten()
def buf = ""
@Grab('com.github.dakusui:jcunit:0.4.10')
@Grab('org.spockframework:spock-core:0.7-groovy-2.0')
import com.github.dakusui.jcunit.core.FactorField;
import com.github.dakusui.jcunit.generators.TupleGeneratorFactory;
import com.github.dakusui.jcunit.core.tuples.Tuple;
import com.github.dakusui.jcunit.generators.ipo2.IPO2;
import com.github.dakusui.jcunit.generators.ipo2.optimizers.GreedyIPO2Optimizer;
import com.github.dakusui.jcunit.constraint.constraintmanagers.ConstraintManagerBase;
import com.github.dakusui.jcunit.constraint.ConstraintManager;
import com.github.dakusui.jcunit.exceptions.UndefinedSymbol;
@nobeans
nobeans / cloneMap.groovy
Created January 29, 2016 06:22
Map単体のcloneだと項目の参照経由でmutableですよ
def map = [a: [1], b: [2], c: [3]]
println map.dump()
// clone()の場合、コストも気になるが実際影響が出るんだった!!!!!
def newMap = map.clone()
println newMap.dump()
// 追加した項目は独立であるが...
newMap.x = "XXXX"
assert newMap.x == "XXXX"