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 / rss_read.groovy
Created June 30, 2025 17:33 — forked from kdabir/rss_read.groovy
Parsing rss in groovy
// define the url
def url = "http://news.google.com/news?ned=us&topic=h&output=rss"
def rss = new XmlSlurper().parse(url)
println rss.channel.title
rss.channel.item.each {
println "- ${it.title}"
}
@ppazos
ppazos / xml_utils.js
Created June 19, 2025 00:57
Functions to format and render XML content as a string.
// Convierte un documento XML a un string XML
// http://stackoverflow.com/questions/6507293/convert-xml-to-string-with-jquery
function xmlToString(xmlData) {
var xmlString;
//IE
if (window.ActiveXObject) {
xmlString = xmlData.xml;
}
// code for Mozilla, Firefox, Opera, etc.
def subjectUid = '...'
if (!(subjectUid ==~ /([a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12})/))
{
return 'error'
}
return 'ok'
@ppazos
ppazos / parse_csv.groovy
Created February 7, 2025 17:22
Parse simple CSV in groovy
// CSV is simple means it doesn't include commas so there is no value separator like " inside the CSV
// Though we take into account there could be spaces after the commas and before the values, and those are removed
// Though the spaces after the values are not removed so "a , b" would be parsed as ["a ", "b"]
def b = "a, b b, c c c"
b = b.replaceAll(",( )*", ",")
println b
@ppazos
ppazos / sql_like_or_from_list.groovy
Created February 7, 2025 17:16
SQL LIKE OR from list
def a = ["a", "b", "c"]
"value LIKE "+ a.collect {"'%"+ it + "%'"}.join(" OR value LIKE ")
// value LIKE '%a%' OR value LIKE '%b%' OR value LIKE '%c%'
@ppazos
ppazos / class_name_standardization.php
Last active September 19, 2024 05:20
Stanrdardizes class names with generics to a single string
<?php
function snakeToCamelCase(string $input): string
{
return ucfirst(str_replace('_', '', ucwords(strtolower($input), '_')));
}
function getClassNameRecursive($string, $start, $end)
{
@ppazos
ppazos / last_modified_http_header_date_format.groovy
Created August 25, 2024 04:36
Format a date in the Last-Modified HTTP header format
// Formats to comply with https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
println format.format(new Date())
@ppazos
ppazos / mirth_connect_maps.js
Created August 19, 2024 02:53
Shorthand names for accessing the maps in Mirth Connect
function $co(key, value) { if (arguments.length == 1) { return connectorMap.get(key); } else { return connectorMap.put(key, value); } }
function $c(key, value) { if (arguments.length == 1) { return channelMap.get(key); } else { return channelMap.put(key, value); } }
function $s(key, value) { if (arguments.length == 1) { return sourceMap.get(key); } else { return sourceMap.put(key, value); } }
function $gc(key, value) { if (arguments.length == 1) { return globalChannelMap.get(key); } else { return globalChannelMap.put(key, value); } }
function $g(key, value) { if (arguments.length == 1) { return globalMap.get(key); } else { return globalMap.put(key, value); } }
function $cfg(key, value) { if (arguments.length == 1) { return configurationMap.get(key); } else { return configurationMap.put(key, value); } }
function $r(key, value) { if (arguments.length == 1) { return responseMap.get(key); } else { return responseMap.put(key, value); } }
function $(string) {
try { if(responseMap.containsKey(string)) { return
@ppazos
ppazos / paragraph.groovy
Created June 10, 2024 13:18
Generates a paragraph text from a long line, limiting line size and number of words per line
def s = "An EHR_STATUS resource needs to be always created and committed in the new EHR. This resource MAY be also supplied by the client as the request body. If not supplied, a default EHR_STATUS will be used by the service with following attributes"
def ss = s.split(" ")
println ss
def wlimit = 4
def climit = 23
@ppazos
ppazos / encode_decode_hl7_string.js
Created May 29, 2024 20:19
Encode and decode strings for HL7 v2.x messages
function formatHL7String(str)
{
var hl7String = str.replace(/\\/g, '\\E\\');
hl7String = hl7String.replace(/\|/g, '\\F\\');
hl7String = hl7String.replace(/\^/g, '\\S\\');
hl7String = hl7String.replace(/~/g, '\\R\\');
hl7String = hl7String.replace(/&/g, '\\T\\');
return hl7String;
}