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
def feed = new XmlSlurper().parse( | |
"http://gdata.youtube.com/feeds/api/videos?category=kitten") | |
def uri = feed.entry[(int)(Math.random()*feed.itemsPerPage.toInteger())] | |
.link.find{it.@rel == 'alternate'}.@href | |
java.awt.Desktop.getDesktop().browse(new URI(uri.toString())) |
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 | |
* gomoku-0.0.4.jarをダウンロードし、~/.groovy/lib か <GROOVY_HOME>/lib にコピーしておく | |
* | |
* 学習ソースとしてWikipediaのテキストをJsoupで取得 |
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='org.jsoup', module='jsoup', version='1.6.1') | |
import org.jsoup.* | |
def keyword = 'Groovy' | |
if(args && args[0]) keyword = args[0] | |
def home = System.getProperty('user.home') | |
def tmp = home + '/tmp' |
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 static java.util.Calendar.* | |
def cal = Calendar.instance | |
def year = cal[YEAR] | |
def month = cal[MONTH] | |
if(args && args[0] && args[0].isInteger() && args[1] && args[1].isInteger()) { | |
year = args[0].toInteger() | |
month = args[1].toInteger() | |
cal[YEAR] = year |
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
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 = [] | |
NewerOlder