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
| 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 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
| @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 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
| @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 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
| // build.gradle: Gradle2.2.1で稼働確認ずみ | |
| // (1) Tomcatプラグイン利用のための設定 | |
| buildscript { | |
| repositories { | |
| jcenter() | |
| } | |
| dependencies { | |
| classpath 'com.bmuschko:gradle-tomcat-plugin:2.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
| /* 行末に特定の日本語文字があると文字化けしてしまう・・残念 */ | |
| import org.apache.tools.ant.filters.EscapeUnicode | |
| apply plugin: 'java' | |
| processResources { | |
| include '**/*.properties' | |
| filter{ String line -> | |
| //byte[] bytes = line.getBytes() |
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
| 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 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 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 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
| /* | |
| * ベイジアンフィルタのサンプル(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 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(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 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 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 |
NewerOlder