This file contains hidden or 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('org.eclipse.jetty:jetty-server:7.0.1.v20091125') | |
@Grab('org.eclipse.jetty:jetty-servlet:7.0.1.v20091125') | |
import org.eclipse.jetty.server.* | |
import org.eclipse.jetty.server.handler.* | |
import org.eclipse.jetty.servlet.* | |
import groovy.servlet.* | |
server = new Server(8080) | |
servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS) | |
servletHandler.with { |
This file contains hidden or 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
@GrabResolver(name='HiveDB', root='http://www.hivedb.org/maven/') | |
@Grab('org.hivedb:github-api:1.0') | |
import org.hivedb.github.* | |
hub = new GitHub('glaforge', 'gaelyk') | |
println "Recent commits in ${hub.userName}/${hub.repository}:" | |
hub.commits.each { c -> println """ | |
${c.authorDate} by ${c.author.name} | |
${c.message} | |
${c.url}""" |
This file contains hidden or 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('jivesoftware:smack:3.0.4') | |
@Grab('jivesoftware:smackx:3.0.4') | |
import org.jivesoftware.smack.* | |
(username, password) = ['<<from_username>>', '<<from_password>>'] | |
to = '<<to_username>>@gmail.com' | |
con = new XMPPConnection( | |
new ConnectionConfiguration('talk.google.com', 5222, 'gmail.com')) | |
con.connect() |
This file contains hidden or 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
#!/usr/bin/env groovy | |
@Grab('nekohtml:nekohtml:latest.integration') | |
import org.cyberneko.html.parsers.SAXParser | |
import groovy.xml.DOMBuilder | |
import groovy.xml.XmlUtil | |
import groovy.xml.dom.DOMCategory | |
/* | |
* gaelyk - utility wrapper command for Gaelyk. | |
* 2010/02/03 [email protected] |
This file contains hidden or 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.util.logging.* | |
/** | |
* Simple wrapper for java.util.logging.Logger. | |
* This logger can log correct class/method names even if used in Groovy. | |
* | |
* @author [email protected] | |
*/ | |
class GroovyLogger { | |
static final EXCLUDE_LIST = [ |
This file contains hidden or 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 #1 HelloWorld(Java完全互換版) | |
class Hello { | |
public static void main(String[] args) { | |
System.out.println("Hello, World!"); | |
} | |
} |
This file contains hidden or 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 #30 ファイルのコピー | |
// Usage: groovy filecopy <srcfile> <destfile> | |
ant = new AntBuilder() | |
ant.copy(file:args[0], tofile:args[1]) |
This file contains hidden or 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 #14 twitterにつぶやく | |
@Grab('org.twitter4j:twitter4j-core:[2.1,)') | |
import twitter4j.* | |
twitter = new TwitterFactory().instance | |
twitter.updateStatus 'Groovy rocks!' |
This file contains hidden or 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 #96 jlineで行編集/補完/ヒストリ付きコマンドライン | |
import jline.* | |
reader = new ConsoleReader() | |
user = reader.readLine('User Name: ').trim() | |
passwd = reader.readLine('Password: ', '*' as char) | |
println "User $user logged in." | |
reader.history.clear() | |
commands = ['bye', 'test', 'debug', 'verbose', 'help'] |
This file contains hidden or 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 #45 日時の演算処理。例えば「現在時刻の3日と4時間後を求める」「特定の時刻間の時間数を求める」 | |
use (groovy.time.TimeCategory) { | |
// 現在時刻の3日と4時間後を求める | |
def now = new Date() | |
def d = now + 3.day + 4.hours | |
println d | |
// 特定の時刻間の時間数を求める | |
def diff = d - now |
OlderNewer