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 addOne( a ) { a + 1 } | |
def addTwo ( b ) { b + 2 } | |
def tellMeWhatToRun = { what, val -> | |
"$what"(val) | |
} | |
println addOne(1) | |
println addTwo(5) |
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 addOne = { a -> | |
return a + 1 | |
} | |
def addTwo = { b -> | |
return b + 2 | |
} | |
def decideWhatToRun = [0: addOne, 1: addTwo] |
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
1.upto(100, { i -> println "${i % 3 ? '' : 'Fizz'}${i % 5 ? '' : 'Buzz'}" ?: i }) |
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
String testString = "SOSSOSSDSSKS" | |
def countSOS = { index = 0, count = 0 -> | |
println "${testString}, ${index}, ${count}" | |
index > testString.size() - 1 ? | |
count : curry(index + 1, count += (testString[index] != "SOS"[index % 3] ? 1 : 0)).call() | |
}.trampoline() |
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
"SOSSOSSDSSKS" | |
.toList() | |
.withIndex() | |
.collect { val, index ->(val != "SOS"[index % 3] ? 1 : 0) } | |
.sum() |
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
credential.serviceAccountScopes = [GmailScopes.MAIL_GOOGLE_COM, | |
GmailScopes.GMAIL_LABELS, | |
GmailScopes.GMAIL_READONLY, | |
GmailScopes.GMAIL_MODIFY] |
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 contents = service.users().messages().get(userId, message.id).execute() |
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
GoogleAuthorizationCodeFlow flow = | |
new GoogleAuthorizationCodeFlow.Builder( | |
httpTransport, JSON_FACTORY, clientSecrets, SCOPES) | |
.setDataStoreFactory(dataStoreFactory) | |
.setAccessType("offline") | |
.build() |
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
Map insertTest = [(Book.BOOK.ID): 6, | |
(Book.BOOK.AUTHOR_ID): 2, | |
(Book.BOOK.TITLE): "Learn JOOQ in 24 Hours"] | |
create.insertInto(Book.BOOK).set(insertTest).execute() |
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
// An inner join that is painless | |
def result = create.select() | |
.from(Author.AUTHOR.join(Book.BOOK) | |
.on(Book.BOOK.AUTHOR_ID.equal(Author.AUTHOR.ID))) | |
.fetch() |
NewerOlder