This file contains hidden or 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 a = [ | |
Double.class, | |
Date.class | |
] | |
a.each { clazz -> | |
if (clazz.equals(Double)) println clazz.toString() +" equals Double 1" // OK | |
if (clazz == Double) println clazz.toString() +" equals Double 2" // OK | |
if (Number.isAssignableFrom(clazz)) println clazz.toString() +" anumber 2" // OK: Number is the same or super class of clazz |
This file contains hidden or 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
<?php | |
$emp_payor = $EmployerPayor->findBy([ | |
'AND' => [ | |
['employer_id', '=', $employer->get_id()], | |
'OR' => [ | |
'AND' => [ | |
['valid_to', '>', $dos], | |
['valid_from', 'IS NULL'] | |
], |
This file contains hidden or 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 getDomain1ById(Long sid) { | |
return Domain1.createCriteria().get { | |
createAlias('domain2', 'd2', CriteriaSpecification.LEFT_JOIN) | |
createAlias('domain3', 'd3', CriteriaSpecification.LEFT_JOIN) | |
idEq(sid) | |
'in' ("locationId", locIds) | |
or { | |
isNull("domain2") | |
'in' ("d2.locationId", locIds) | |
} |
This file contains hidden or 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.json.* | |
// NOTE: the prefix / was removed to help the recursion, this step could be done before starting of it can be part of the first recursion | |
def data = [ | |
"name", | |
"category", | |
"context/setting", | |
"context/start_time", | |
"content(3)/data/origin", | |
"content(3)/data/events(1)/time", |
This file contains hidden or 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
// from: https://gist.github.com/two7sclash-zz/c3835d83695b46ca2a6a4b6d71272538 | |
// note: snake case should also take into account spaces, println toSnakeCase("Camel Case Class") actually generates camel _case _class | |
static String toCamelCase( String text, boolean capitalized = false ) { | |
text = text.replaceAll( "(_)([A-Za-z0-9])", { Object[] it -> it[2].toUpperCase() } ) | |
return capitalized ? capitalize(text) : text | |
} | |
static String toSnakeCase( String text ) { | |
text.replaceAll( /([A-Z])/, /_$1/ ).toLowerCase().replaceAll( /^_/, '' ) |
This file contains hidden or 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('com.xlson.groovycsv:groovycsv:1.3') | |
import static com.xlson.groovycsv.CsvParser.parseCsv | |
def csv = new File("amplify_clinic_services.csv").text | |
def csv_iterator = parseCsv(csv) | |
def multiple_columns = [ | |
'SPECIALTY', | |
'BODY PART', |
This file contains hidden or 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.time.TimeCategory | |
import groovy.time.TimeDuration | |
import groovy.json.JsonSlurper | |
import groovy.json.JsonOutput | |
def map = [ | |
_type: 'ORIGINAL_VERSION', | |
uid: [ | |
_type: 'OBJECT_VERSION_ID', | |
value: '12341234' |
This file contains hidden or 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
grailsApplication.getArtefacts("Domain").each { domain -> | |
println domain.toString() | |
domain.getProperties().each { prop -> | |
println prop.name +": "+ prop.type.name // DefaultGrailsDomainClassProperty | |
} | |
} |
This file contains hidden or 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 durations = [ | |
'P1Y', | |
'P2Y', | |
'P1Y1M', | |
'P1Y1M1W', | |
'P1Y1M1W1D', | |
'P1Y1M1D', | |
'P1M', | |
'P1W', |
This file contains hidden or 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 tree1 = [ | |
'path': '/', | |
'children': [ | |
[ | |
'path': '/a(1)', | |
'children': [ | |
[ | |
'path': '/a(1)/b', | |
'children': [] | |
], |