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
def xml = new groovy.xml.MarkupBuilder() | |
def introduction = { | |
'my-information'{ | |
name('mike_neck') | |
'twitter-id'('@mike_neck') | |
job('SE') | |
} | |
'why-groovy'{ | |
'I-Tweeted'('To rewrite a copy of sample code is too bore for me. So I will write it in Groovy') |
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 static groovyx.gpars.GParsPool.*; | |
def numero = [1,2,3,4] | |
def square = [1,4,9,16] | |
withPool{ | |
assert square == numero.collectParallel { | |
println it | |
it * it | |
} |
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 static groovyx.gpars.GParsPool.*; | |
withPool { | |
assert 30 == | |
[1,2,3,4,5,6,7,8,9,10].parallel | |
.filter { | |
println "filter -> $it" | |
it <= 5 | |
} | |
.map { |
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 static groovyx.gpars.actor.Actors.*; | |
def console = actor{ | |
loop{ | |
react {msg -> | |
println msg | |
} | |
} | |
} |
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 groovy.xml.MarkupBuilder | |
def writer = new StringWriter() | |
def xml = new MarkupBuilder(writer) | |
xml.html('lang' : 'ja'){ | |
head{ | |
meta('http-equiv' : 'Content-Type', 'content' : 'text/html; charset=UTF-8') | |
title('jQuery Mobile Sample') | |
link('rel' : 'stylesheet', 'href' : 'http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css') | |
['http://code.jquery.com/jquery-1.6.1.min.js', 'http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js'].each{ |
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 groovy.xml.MarkupBuilder | |
def writer = new StringWriter() | |
def xml = new MarkupBuilder(writer) | |
xml.html('lang' : 'ja'){ | |
head{ | |
meta('http-equiv' : 'Content-Type', 'content' : 'text/html; charset=UTF-8') | |
title('jQuery Mobile Sample') | |
link('rel' : 'stylesheet', 'href' : 'http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css') | |
['http://code.jquery.com/jquery-1.6.1.min.js', 'http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js'].each{ |
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
IntRange.metaClass.random = {(new Random()).nextInt(delegate.to - delegate.from + 1) + delegate.from} |
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
def max = {num1, num2 -> | |
(num1 - num2 > 0) ? num1 : num2 | |
} | |
def min = {num1, num2 -> | |
(num1 - num2 > 0) ? num2 : num1 | |
} | |
assert max(1,2) == 2 | |
assert min(2,1) == 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
import java.lang.reflect.InvocationTargetException; | |
import java.lang.reflect.Method; | |
import android.content.Context; | |
import android.test.AndroidTestCase; | |
public class AndroidExtendedTestCase extends AndroidTestCase { | |
public Context getTestContext(){ | |
Context context = null; |
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 java.net.*; | |
NetworkInterface.getNetworkInterfaces().each{nInterface -> | |
println 'display name : ' + nInterface.getDisplayName() | |
nInterface.getInetAddresses().each{addr -> | |
address = addr.getHostAddress() | |
println 'address : ' + address | |
} | |
} |
OlderNewer