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:000> :load https://git.io/v2N1I | |
===> true | |
groovy:000> :register GrabCommand | |
===> true | |
groovy:000> :grab 'com.google.guava:guava:19.0' | |
groovy:000> import com.google.common.collect.Bi | |
BiMap BinaryTreeTraverser | |
groovy:000> import com.google.common.collect.BiMap | |
===> com.google.common.collect.BiMap | |
groovy:000> |
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
try { | |
new Raindrops().with { | |
assert convert(1) == '1' | |
assert convert(3) == 'Pling' | |
assert convert(5) == 'Plang' | |
assert convert(6) == 'Pling' | |
assert convert(7) == 'Plong' | |
assert convert(9) == 'Pling' | |
assert convert(10) == 'Plang' | |
assert convert(14) == 'Plong' |
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
# "I have measured out my life with coffee spoons." —T.S. Eliot | |
# | |
export JAVA_OPTS="-Djava.awt.headless=true" |
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 Greed | |
def self.score(dice) | |
# initialize a score | |
score = 0 | |
# create a hash of the roll (face values) and the number of times rolled | |
rolls = dice.inject(Hash.new(0)) {|hash, roll| hash[roll] += 1; hash } |
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(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' ) | |
import groovy.io.FileType | |
import groovyx.net.http.RESTClient | |
import static groovyx.net.http.ContentType.* | |
def standingsFile = new File('./src/test/resources/2015/fall/advsundiv.pdf') | |
def client = new RESTClient( 'http://beta.offenedaten.de:9998/tika' ) | |
def response = client.put( requestContentType: BINARY, body: standingsFile.bytes ) | |
println response.data.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
groovy.grape.Grape.grab(group:'org.codehaus.groovy.modules.http-builder', module:'http-builder', version:'0.7.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
Integer[][] matrix2 | |
matrix2 = [[1, 2], [3, 4]] | |
assert matrix2 instanceof Integer[][] |
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
(~){azazel}06:01P] groovysh | |
Groovy Shell (2.4.4, JVM: 1.8.0_60) | |
Type ':help' or ':h' for help. | |
---------------------------------------------------------------------------------------------------------------------------------------- | |
groovy:000> Integer[][] matrix2 | |
===> null | |
groovy:000> matrix2 = [[1, 2], [3, 4]] | |
===> [[1, 2], [3, 4]] | |
groovy:000> assert matrix2 instanceof Integer[][] | |
assert matrix2 instanceof Integer[][] |
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
filename = './advsundiv.txt' | |
file = new File(filename) | |
expression = /(\d+?)\s(.*?)\s\d+.*/ | |
file.findAll { (it=~expression).matches() }.collect { (it=~expression).collect { match, id, name -> | |
[ 'id': id, 'name': name ] | |
} } |
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
('72103 14 Balls & a Rack 412 3438 28 123' =~ /(\d+)\s(.*?)\s\d+.*/) | |
.collect { match, id, name -> [ 'id': id, 'name': name ] } |