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
@Grapes([ | |
@Grab("org.codehaus.geb:geb-core:latest.release"), | |
@Grab("org.seleniumhq.selenium:selenium-firefox-driver:latest.release") | |
]) | |
import geb.Browser | |
Browser.drive { | |
go "http://www.facebook.com/profile.php?id=732337788" | |
go "http://d.hatena.ne.jp/keyword/" |
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 rootDir = new File(args[0]) | |
def ant = new AntBuilder() | |
rootDir.eachDir { dir -> | |
def srcDirName = dir.name | |
def path = dir.absoluteFile.parent | |
def dstFileName = srcDirName + '.zip' | |
println "Zipping: ${path}\\${srcDirName}" | |
ant.zip(destfile: "${path}\\${dstFileName}", | |
basedir: "${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
import java.awt.Image | |
import java.awt.image.BufferedImage | |
import javax.imageio.ImageIO | |
def rootDir = new File(args[0]) | |
rootDir.eachFileRecurse { file -> | |
if(file.name ==~ /[^s].*\.jpg/) { // skip file starting with "s" | |
def srcFileName = file.name | |
def path = file.absoluteFile.parent | |
def dstFileName = 's' + srcFileName |
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
java.awt.SystemTray.getSystemTray().add(new java.awt.TrayIcon(image:java.awt.Toolkit.getDefaultToolkit().getImage(this.class.getResource('groovy/ui/ConsoleIcon.png')), tooltip:'Hello World!', imageAutoSize:true)) |
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
@Grab(group='net.sourceforge.nekohtml', module='nekohtml', version='1.9.14') | |
import org.cyberneko.html.parsers.SAXParser | |
def parser = new XmlParser(new SAXParser()) | |
def html = parser.parse('http://www.spec.org/jEnterprise2010/results/jEnterprise2010.html') | |
//new XmlNodePrinter().print(html) | |
def result = [] | |
def baseUrl = 'http://www.spec.org/jEnterprise2010/results/' |
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 inputFiles = [] | |
args.each{ fn -> | |
inputFiles << new File(fn) | |
} | |
new File('merged.csv').withWriter{ out -> | |
def outputLines = [] | |
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 obj = new Date() | |
try{ | |
serialize(obj) | |
}catch(e){ | |
println "Object is not Serializable" | |
} | |
def serialize(obj){ | |
def baos = new ByteArrayOutputStream() | |
def oos = new ObjectOutputStream(baos) |
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 groovy.json.* | |
import static groovy.json.JsonOutput.toJson | |
def parser = new JsonSlurper() | |
def s = '''{"a":1, "b":true, "c":"string", "d":"日本語", "e":"\u65E5\u672C\u8A9E"}''' | |
def o = parser.parseText(s) | |
assert o.getClass() == HashMap | |
assert o.a.class == Integer | |
assert o.b.class == Boolean | |
assert o.c.class == String |
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バージョン) | |
* 元ネタ) 機械学習 はじめよう 第3回 ベイジアンフィルタを実装してみよう | |
* http://gihyo.jp/dev/serial/01/machine-learning/0003 | |
* | |
* 分かち書きにはGomokuを利用 | |
* https://github.com/sile/gomoku | |
*/ | |
import net.reduls.gomoku.Tagger | |
import net.reduls.gomoku.Morpheme |
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
// g100pon #51 KVSの操作(保存、取得) | |
// Apache Cassandraを利用 | |
// Cassandraのセットアップはこちらを参照⇒http://gihyo.jp/dev/serial/01/cassandra/0002 | |
// セットアップ後にJARをクラスパス(~/.groovy/libなど)に追加してください。 | |
// サンプルコードとしてはgihyo.jpの大谷さんの記事ほぼそんままです。 | |
import org.apache.cassandra.thrift.* | |
import org.apache.thrift.* | |
import org.apache.thrift.protocol.* |