Skip to content

Instantly share code, notes, and snippets.

View ppazos's full-sized avatar
🌎
All around

Pablo Pazos Gutiérrez ppazos

🌎
All around
View GitHub Profile
@ppazos
ppazos / gist:c0bcdd3ed90aafa9d489
Created March 27, 2015 00:13
Groovy get all fields and values
object.class.declaredFields.findAll{!it.synthetic}.collectEntries{ [ (it.name):this."$it.name" ] }
public class SimpleEchoServer implements Runnable {
private int port;
private LinkedList<Socket> openClients = new LinkedList<Socket>();
private boolean cleaningUp = false;
public SimpleEchoServer(int port) {
this.port = port;
}
@ppazos
ppazos / Groovy DSL test.groovy
Created August 20, 2016 06:19
Groovy DSL test
// testing groovy DSL
// http://docs.groovy-lang.org/docs/latest/html/documentation/core-domain-specific-languages.html
COMPOSITION = 'COMPOSITION'
// constructor for patient's stuff
def create( what )
{
[to: { patient ->
switch (what) {
@ppazos
ppazos / closure_filters.groovy
Last active September 13, 2016 23:09
Externalize filters by using closures
/**
* We have two functions with exactly the same code, but one has a filter, so I want to use the same code
* but inject the filter by using a closure:
*/
// Filters
def filter_between = { min, max, n ->
return min < n && n < max
}
@ppazos
ppazos / check_null_and_empty_lists.groovy
Created November 15, 2016 02:35
groovy check null and empty list, return somethig instead
def nuli = null
def empi = []
def algi = [1,2,3]
println nuli ?: empi
println nuli ?: algi
println empi ?: algi
@ppazos
ppazos / Mirth Channels Code Generator Sample.groovy
Created June 16, 2017 07:43
Mirth Channels Code Generator Sample
class Channel {
def id = UUID.randomUUID().toString() // java.util.UUID
def name
def enabled = true
def revision = 1
def source
def destinations = []
def preprocessing
enum ChangeType {
CREATION(249 as short),
AMENDMENT(250 as short),
MODIFICATION(251 as short),
DELETED(523 as short)
// TODO: SYNTHESIS, ATTESTATION, UNKNOWN?
private final short value
[
{
"fields": {
"status": "During Check In"
},
"required": false,
"name": "Check In",
"complete": true
},
{
/*
https://stackoverflow.com/questions/7380226/find-word-in-html
*/
function wrapWord(el, word)
{
var expr = new RegExp(word, "i");
var nodes = [].slice.call(el.childNodes, 0);
for (var i = 0; i < nodes.length; i++)
{
var node = nodes[i];
@ppazos
ppazos / CustomValidationTagLib.groovy
Created July 10, 2017 09:20 — forked from hussainanjar/CustomValidationTagLib.groovy
Extension of Grails ValidationTagLib
package com.hussain.pf
import groovy.xml.MarkupBuilder
import org.apache.commons.lang.StringEscapeUtils
import org.codehaus.groovy.grails.plugins.web.taglib.ValidationTagLib
class CustomValidationTagLib extends ValidationTagLib {
/**