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
package tddbc; | |
import static org.junit.Assert.*; | |
import static org.hamcrest.CoreMatchers.*; | |
import java.util.ArrayList; | |
import java.util.List; | |
import org.junit.Test; |
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
class Hello {void hello(){println "1"}} | |
def a = new Hello() | |
def b = new Hello() | |
b.metaClass.hello = { println "2" } | |
a.hello() | |
b.hello() | |
a.metaClass.hello = {b.metaClass.hello} | |
a.hello() |
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
class Hello {void hello(){println "1"}} | |
def a = new Hello() | |
a.hello() | |
a.metaClass.hello = { println "2" } | |
a.hello() | |
a.metaClass.hello = { a.&hello() } | |
a.hello() |
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
class C {int m(){1}} | |
C.metaClass.m = {9} | |
def a = new C() | |
assert 9 == a.m() | |
a.metaClass.m = {2} | |
assert 2 == a.m() | |
C.metaClass.m = {8} |
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
new File("src").eachFileRecurse(groovy.io.FileType.FILES) { | |
def s = it.text.replaceAll(/\r\n?/,'\n') | |
it.withWriter("UTF-8") {it << s} | |
} |
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("org.twitter4j:twitter4j-core:2.2.3") | |
import twitter4j.* | |
def twitter = new TwitterFactory().instance | |
twitter.getUserListStatuses( | |
twitter.getAllUserLists('kyon_mm').find{it.name == 'groovy'}.id, new Paging() | |
).each { println "<@${it.user.screenName}> $it.text" } |
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('org.twitter4j:twitter4j-core:2.2.3') | |
@Grab('org.twitter4j:twitter4j-stream:2.2.3') | |
import twitter4j.* | |
def twitter = new TwitterFactory().instance | |
def stream = new TwitterStreamFactory().getInstance(twitter.OAuthAccessToken) | |
def print = {println "@${it.user.screenName}: ${it.text}"} | |
stream.addListener([onStatus:print] as UserStreamAdapter) | |
stream.user() |
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('org.twitter4j:twitter4j-core:2.2.3') | |
import twitter4j.* | |
import twitter4j.conf.* | |
def conf = new ConfigurationBuilder() | |
.setOAuthConsumerKey('consumer key') | |
.setOAuthConsumerSecret('consumer secret') | |
.setOAuthAccessToken('access token') | |
.setOAuthAccessTokenSecret('access token secret') |
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
// こちらは以前試していた失敗作 | |
class DoWhile { | |
def proc | |
def _do(Closure proc) { | |
this.proc = proc | |
return this | |
} | |
def _while(Closure cond) { | |
10.times { | |
println cond() |
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 javafx.animation.Timeline; | |
import javafx.scene.effect.BoxBlur | |
import javafx.scene.paint.Color; | |
import javafx.scene.shape.StrokeType; | |
import groovyx.javafx.GroovyFX; | |
import groovyx.javafx.SceneGraphBuilder; | |
import groovyx.javafx.TimelineBuilder; | |
GroovyFX.start {stage-> |
OlderNewer