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 data=[ | |
one:"john", | |
two:"mary" | |
] | |
String entry="two" | |
println data."${entry}" //"mary" |
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 data=[ | |
one:[ | |
two:"2222", | |
three:"333" | |
] | |
] | |
String nestedExpression="one.two" | |
String output=nestedExpression.tokenize('.').inject(data) {v, k -> v."$k"} | |
println output // "2222" |
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
enum CommunicationStateEnum { | |
DESIGN, APROBADA, EJECUTADA, EN_PROGRESO, FINALIZADA, CANCELADA | |
} | |
enum CampaignStateEnum { | |
DESIGN, APROBADA, EJECUTADA, EN_PROGRESO, FINALIZADA, CANCELADA | |
} | |
CommunicationStateEnum campaignState2ComunicationState(CampaignStateEnum campaignState){ | |
if(!campaignState) return 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
SELECT | |
concat('UPDATE ', | |
my_table_name, | |
' SET ', | |
my_column_name, | |
' = REPLACE(', | |
my_column_name, | |
', \'my_old_str\', \'my_new_str\')', | |
' WHERE ', | |
my_column_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
import java.util.Collections | |
//Input | |
def elements=['a','b','c','d','e'] | |
def selectedIndices=[1,2,3] | |
boolean isMovingUp=false | |
println "Initial: ${elements}" | |
println "Selection: ${selectedIndices.collect{elements[it]}}" | |
println "Direction: ${isMovingUp?'<':'>'}" |
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
//The kind of API I was looking for | |
String myInput="This string is FORBIDDEN" | |
myInput.containsAny(["FORBIDDEN","NOT_ALLOWED"]) //=>true | |
//Adding the method to String | |
String.metaClass.containsAny={notAllowedTerms-> | |
notAllowedTerms?.inject(false,{found,term->found || delegate.contains(term)}) | |
} | |
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 input=[1,[2,3],4] | |
def output=[] | |
//Warning!! Potential error | |
input.each{ | |
output+=it | |
} | |
println output //=>[1,2,3,4]!!! | |
println output.size()//=>4 |
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 testmixfx | |
import javafx.embed.swing.JFXPanel | |
import groovyx.javafx.GroovyFX | |
import javafx.application.Platform; | |
import javafx.embed.swing.JFXPanel; | |
import javafx.scene.Scene; | |
import javafx.scene.web.WebEngine; | |
import javafx.scene.web.WebView; | |
import groovyx.javafx.SceneGraphBuilder; |
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 testmixfx | |
import javafx.embed.swing.JFXPanel | |
import groovyx.javafx.GroovyFX | |
import javafx.application.Platform; | |
import javafx.embed.swing.JFXPanel; | |
import javafx.scene.Scene; | |
import javafx.scene.web.WebEngine; | |
import javafx.scene.web.WebView; | |
import groovyx.javafx.SceneGraphBuilder; |
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 testmixfx | |
import javafx.embed.swing.JFXPanel | |
import groovyx.javafx.GroovyFX | |
import javafx.application.Platform; | |
import javafx.embed.swing.JFXPanel; | |
import javafx.scene.Scene; | |
import javafx.scene.web.WebEngine; | |
import javafx.scene.web.WebView; | |
import groovyx.javafx.SceneGraphBuilder; |
OlderNewer