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
remotes { | |
localhost { | |
host = 'localhost' | |
user = System.properties['user.name'] | |
identity = file("${System.properties['user.home']}/.ssh/id_rsa") | |
} | |
} | |
task showPlatformVersion(type: SshTask) { | |
session(remotes.localhost) { |
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 org.apache.tools.ant.filters.EscapeUnicode | |
apply plugin: 'java' | |
processResources { | |
include '**/*.properties' | |
filter{ String line -> | |
//byte[] bytes = line.getBytes() |
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
// build.gradle: Gradle2.2.1で稼働確認ずみ | |
// (1) Tomcatプラグイン利用のための設定 | |
buildscript { | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
classpath 'com.bmuschko:gradle-tomcat-plugin:2.0' | |
} | |
} |
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(group='com.datastax.cassandra', module='cassandra-driver-core', version='2.1.5') | |
) | |
import com.datastax.driver.core.* | |
def cluster = Cluster.builder().addContactPoint('127.0.0.1').build() | |
def session = cluster.connect() | |
session.execute("INSERT INTO first_keyspace.first_table (name, value) VALUES ('foo', 'bar');"); | |
session.execute("INSERT INTO first_keyspace.first_table (name, value) VALUES ('gee', 'baz');"); |
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(group='com.datastax.cassandra', module='cassandra-driver-core', version='2.1.5') | |
) | |
import com.datastax.driver.core.* | |
def cluster = Cluster.builder().addContactPoint('127.0.0.1').build() | |
def metadata = cluster.getMetadata() | |
println "Connected to cluster: ${metadata.getClusterName()}" |
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 -e "def b='10 49 4a 03'; println b.split(' ').collect{ Integer.decode('0x'+it) }.join(' '); println b.split(' ').collect{ Integer.toBinaryString(Integer.decode('0x'+it)).padLeft(8,'0') }.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
// g100pon #98 DerbyでGroovySQL | |
import groovy.sql.Sql | |
import groovy.grape.Grape | |
Grape.grab(group:'org.apache.derby', module:'derby', version:'[10.5.3,)', | |
classLoader:this.class.classLoader.rootLoader) | |
def sql = Sql.newInstance('jdbc:derby:memory:testdb;create=true', | |
'user', 'password', 'org.apache.derby.jdbc.EmbeddedDriver') |
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 #26 文字列を分割してListに変換 | |
assert 'This is a pen'.tokenize() == ['This', 'is', 'a', 'pen'] | |
assert '東京/大阪/名古屋/仙台'.tokenize('/') == ['東京', '大阪', '名古屋', '仙台'] |
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 #44 DBとテーブル名を引数指定して標準入力から読み取ったCSV/TSVデータをinsert | |
import groovy.sql.Sql | |
import groovy.grape.Grape | |
if(args.size()<2){ | |
println "Usage: groovy Text2DB.groovy <DB> <TABLE> < <CSV|TSV>" | |
System.exit(1) | |
} |
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 #40 XMLの読み書きを色んな方法で(DOMBuilder->XmlUtil) | |
import groovy.xml.XmlUtil | |
import groovy.xml.dom.DOMCategory | |
import groovy.xml.DOMBuilder | |
// DOMBuilderを使うとパースが簡単にできる | |
// パース結果のオブジェクトはDOM | |
def doc = DOMBuilder.parse( | |
new InputStreamReader(new FileInputStream('sample.xml'),'UTF-8') ) |
OlderNewer