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 worker = { latch, num -> | |
println "ready: $num" | |
latch.countDown() | |
latch.await() | |
Thread.sleep(num * 10) | |
println num | |
} | |
def latch = new java.util.concurrent.CountDownLatch(args.size()) | |
args.each { |
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
apply plugin: 'java' | |
apply plugin: 'groovy' | |
apply plugin: 'code-quality' | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
groovy 'org.codehaus.groovy:groovy:1.7.10' |
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
scala> trait ComposableFunction1[-T1, +R] { | |
| val f: T1 => R | |
| def >>[A](g:R => A):T1 => A = f andThen g | |
| def <<[A](g:A => T1):A => R = f compose g | |
| } | |
defined trait ComposableFunction1 | |
scala> implicit def toComposableFunction1[T1,R](func:T1 => R) = new ComposableFunction1[T1,R]{ val f = func } | |
toComposableFunction1: [T1,R](func: (T1) => R)java.lang.Object with ComposableFunction1[T1,R] |
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
// あるプロジェクトの下流ビルドと上流ビルドを取得する方法 | |
// 以下は groovy plugin の Execute system Groovy script の中で使用して | |
// TEST プロジェクトの下流ビルドと上流ビルドを取得する例 | |
def jobname = "TEST" | |
def job = hudson.model.Hudson.instance.getItem(jobname) | |
def dep = hudson.model.Hudson.instance.dependencyGraph | |
assert job, "ERROR: Can't find the job $jobname." | |
assert dep, "ERROR: Can't get the dependency graph." |
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 java.security.MessageDigest | |
println "-"*40 | |
println "MessageDigest:" | |
File.metaClass.getMd5 = { | |
MessageDigest.getInstance("md5"). | |
digest(delegate.readBytes()). | |
collect{ String.format("%02x", it) }. | |
join() | |
} |
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
// ==UserScript== | |
// @name Hatena Haiku notify auto opener | |
// @namespace http://www.hatena.ne.jp/Nikola/ | |
// @description はてなハイク1.1の新着通知を自動で開きます。Google Chromeにも対応。 | |
// @include http://h1beta.hatena.ne.jp/* | |
// @include http://h1beta.hatena.com/* | |
// ==/UserScript== | |
(function () { |
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
// ==UserScript== | |
// @name Hatena Haiku notify auto opener | |
// @namespace http://d.hatena.ne.jp/kurumigi/ | |
// @description はてなハイク1.1の新着通知を自動で開きます。 | |
// @include http://h.hatena.ne.jp/* | |
// @include http://h.hatena.com/* | |
// @include http://h1beta.hatena.ne.jp/* | |
// @include http://h1beta.hatena.com/* | |
// @version 1.2 | |
// ==/UserScript== |
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
'UTF-8'.with { enc -> | |
URLDecoder.decode(new URL('http://h.hatena.ne.jp/').getText(enc), enc) | |
}.findAll(~/["']\/keyword\/(.+?)["']/) { match, _1 -> | |
_1 | |
}.sort().unique().each { | |
println it | |
} |