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
def getBytes(str, encode) { | |
str.getBytes(encode).collect{ | |
"0x${Integer.toHexString(it & 0xff)}" | |
} | |
} | |
assert getBytes('\uff5e', 'Windows-31J') == ['0x81', '0x60'] |
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
// required hatenahaiku4j | |
// http://d.hatena.ne.jp/fumokmm/20090905/1252143947 | |
import hatenahaiku4j.* | |
long start = System.currentTimeMillis() | |
new HatenaHaikuAPILight().with { | |
getUser('fumokmm').api.followingKeywordList.each { k -> | |
println k.title | |
} | |
} |
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 groovy.xml.NamespaceBuilder | |
import groovy.xml.MarkupBuilder | |
// create 'ivy.xml' | |
def ivyxml = new StringWriter() | |
def mkb = new MarkupBuilder(ivyxml) | |
mkb.doubleQuotes = true | |
mkb.'ivy-module' (version: '2.0') { | |
info (organisation: 'apache', module: 'hello-ivy') | |
dependencies { |
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 groovy.xml.NamespaceBuilder | |
import groovy.xml.MarkupBuilder | |
// create 'ivy.xml' and 'ivysettings.xml' | |
createIvyXml() | |
createIvySettingXml() | |
// invoke ant | |
def ant = new AntBuilder() | |
def ivy = NamespaceBuilder.newInstance(ant, 'antlib:org.apache.ivy.ant') |
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
<!-- | |
* Copyright 2003-2008 the original author or authors. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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('hatenahaiku4j:hatenahaiku4j:latest.integration') | |
import hatenahaiku4j.* | |
new HatenaHaikuAPIHTML().publicTimeline.each { | |
println it.userId | |
} |
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
<?xml version="1.0" ?> | |
<project name="ant-with-groovy" default="test"> | |
<taskdef name="groovy" | |
classname="org.codehaus.groovy.ant.Groovy" | |
classpath="groovy-all-1.7.2.jar" /> <!-- groovy-all-*.jar を指定 --> | |
<target name="test"> | |
<groovy><![CDATA[ | |
// この中にgroovyスクリプトを自由に記述できる。 | |
// このバインディング内で暗黙的に利用可能な変数は以下。 |
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
<?xml version="1.0" ?> | |
<project name="ant-with-groovy" default="test"> | |
<taskdef name="groovy" | |
classname="org.codehaus.groovy.ant.Groovy" | |
classpath="groovy-all-1.7.2.jar" /> <!-- groovy-all-*.jar を指定 --> | |
<target name="test"> | |
<groovy><![CDATA[ | |
(1..100).each { no -> | |
ant.mkdir dir: "test/dir${no.toString().padLeft(3, '0')}" |
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
<?xml version="1.0" ?> | |
<project name="ant-with-groovy" default="test"> | |
<taskdef name="groovy" | |
classname="org.codehaus.groovy.ant.Groovy" | |
classpath="groovy-all-1.7.2.jar" /> <!-- groovy-all-*.jar を指定 --> | |
<target name="test"> | |
<groovy><![CDATA[ | |
// 例:古いディレクトリから新しいディレクトリにコピー | |
def dirMap = [ |
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
<?xml version="1.0" ?> | |
<project name="ant-with-groovy" default="test"> | |
<taskdef name="groovy" | |
classname="org.codehaus.groovy.ant.Groovy" | |
classpath="groovy-all-1.7.2.jar" /> <!-- groovy-all-*.jar を指定 --> | |
<target name="test"> | |
<groovy><![CDATA[ | |
import static java.util.Calendar.* | |
def isWeekend = { new Date()[DAY_OF_WEEK] in [SATURDAY, SUNDAY] } |