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 exampleXmlString = '''<?xml version="1.0" encoding="UTF-8"?> | |
<persons> | |
<person> | |
<name>John</name> | |
<lastname>Doe</lastname> | |
<age>38</age> | |
</person> | |
</persons>''' | |
def exampleXml = new XmlParser().parseText(exampleXmlString) |
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 javax.swing.* | |
def showTimeredMessage(String message, int afterSeconds = 600) { | |
sleep (afterSeconds*1000) | |
JOptionPane.showMessageDialog(null, message) | |
} | |
showTimeredMessage("Pomodoro over, get back to work! :)", 300) |
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
#!/usr/bin/env groovy | |
assert args.size() == 1 : "Specify the path of the folder that needs placeholders." | |
def projectFolder = new File(args[0]) | |
projectFolder.eachDirRecurse { dir -> | |
if(dir.list().size() == 0) { | |
def placeholder = new File(dir, '.PLACEHOLDER') | |
println "Creating: $placeholder.absolutePath" | |
placeholder.createNewFile() |
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
#!/usr/bin/env groovy | |
/* setgrails: Script used to easily change grails version on the commandline in OS X | |
* | |
* My setup: | |
* /User/leo/Apps/grails Folder where all versions of grails are installed | |
* /User/leo/Apps/grails/grails A symlink pointing to the version of grails I'm currently using | |
* /User/leo/Apps/grails-1.3.1 One of the installed versions | |
* | |
* in ~/.profile |
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 Predicate { | |
boolean value | |
boolean asBoolean() { value } | |
} | |
// Works: | |
assert new Predicate(value: true) | |
assert !new Predicate(value: false) | |
assert (new Predicate(value: true) as Boolean == true) | |
assert (new Predicate(value: false) as Boolean == false) |
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
// Example of using groupBy and collect together | |
def values = | |
[[lastname: "Anderson", age: 30], | |
[lastname: 'Bergstrom', age: 24], | |
[lastname: 'Anderson', age: 45], | |
[lastname: 'Bergstrom', age: 40], | |
[lastname: 'Brown', age: 25]] | |
// Find average age by lastname: |
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
Grails Runtime Exception | |
Error Details | |
Error 500: Executing action [show] of controller [org.weceem.controllers.WcmContentController] in plugin [weceem] caused exception: groovy.lang.MissingMethodException: No signature of method: org.weceem.services.WcmContentRepositoryService.resolveSpaceAndURI() is applicable for argument types: ([Ljava.lang.String;) values: [[/views/search-results, /]] Possible solutions: resolveSpaceAndURI(java.lang.String) | |
Servlet: grails | |
URI: /try-weceem/grails/wcmContent/show.dispatch | |
Exception Message: No signature of method: org.weceem.services.WcmContentRepositoryService.resolveSpaceAndURI() is applicable for argument types: ([Ljava.lang.String;) values: [[/views/search-results, /]] Possible solutions: resolveSpaceAndURI(java.lang.String) | |
Caused by: No signature of method: org.weceem.services.WcmContentRepositoryService.resolveSpaceAndURI() is applicable for argument types: ([Ljava.lang.String;) values: [[/views/search-results, /]] Possible solutions: resolveSpaceAndURI(java.lan |
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
// Impl of a lazyCollect method that will not execute | |
// until you actually ask for the value | |
class LazyCollectList extends AbstractList { | |
private Closure collectClosure | |
private List backingList | |
private Map cached = [:] | |
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
#!/usr/bin/env groovy | |
// Validating arguments | |
assert args.size() == 1 : "mp4it takes 1 argument: the path to the file to be conerted into mp4" | |
assert new File(args[0]).exists() : "The file you specified could not be found." | |
def videoFilePath = args[0] | |
def outputFilePath = videoFilePath.replaceAll(/\.avi$/, '.mp4') | |
assert !new File(outputFilePath).exists() |
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
javascript:window.open('about:blank') |
OlderNewer