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 / groovy_code_run.groovy
Last active February 7, 2024 20:03
Groovy load a class from String
GroovyClassLoader gcl = new GroovyClassLoader ();
try {
glc.parseClass (inputString);
// do stuff
} catch (CompilationFailedExcpetion cfe) {
// can't do stuff
}
/* https://stackoverflow.com/questions/9004303/load-script-from-groovy-script
http://groovy-lang.org/integrating.html#integ-groovyshell
@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 / gist:d0353817f74a1385bbf1
Last active September 29, 2020 00:32
Groovy XSD Validation a-la Java
import javax.xml.parsers.SAXParserFactory
import javax.xml.validation.SchemaFactory
import org.xml.sax.SAXException
import org.xml.sax.SAXParseException
import org.xml.sax.ErrorHandler
import javax.xml.transform.Source
import javax.xml.transform.stream.StreamSource
import javax.xml.parsers.SAXParser
import org.xml.sax.XMLReader
import org.xml.sax.InputSource
@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 / price.md
Created December 6, 2016 05:52 — forked from justjanne/Price Breakdown.md
AWS Lightsail vs DigitalOcean, VULTR and Linode

Price breakdown vs DigitalOcean, Vultr, Linode, OVH, and Online.net / Scaleway:

$5/mo

Provider RAM Cores Storage Transfer
LightSail 512MB 1 20GB SSD 1TB
DO 512MB 1 20GB SSD 1TB
@ppazos
ppazos / Groovy Code Generator Sample.groovy
Last active May 18, 2021 15:02
Groovy Code Generator Sample
class Spec {
def classes = []
def model(args)
{
def clazz = new Clazz().named(args.clazz)
if (args.withAttributes)
{
@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