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 / escape_js_vars_in_string_literal.gsp
Created January 17, 2026 17:42
In Grails, the Goovy variables in GSP can be accessed by ${var} but that's also how JS string literals access variables, giving an error in GSP
// Here Groovy prints the '$', leaving it for the JS to evaluate the variable correctly on the client side.
let btnAuthorize = `<a href="merge/${'$'}{record.id}/authorize" class="btn btn-primary">Authorize</a>`;
// This will fail if record is a JS object
let btnAuthorize = `<a href="merge/${record.id}/authorize" class="btn btn-primary">Authorize</a>`;
@ppazos
ppazos / ehr_mege.groovy
Created January 17, 2026 16:21
Basic operations to track virtual merge on EHRs
//ehrs = ['A', 'B', 'C', 'D', 'E', 'F']
// TODO: the canonical should be initialized with the identities: A: A, ... so when asking for the canonical of an unmerged EHR, it gives the same EHR back
canonical = [:]
history = []
// A => B : [A: B]
// C => B : [C: B, A: B]
// B => E : [C: E, A: E, B: E]
// merge secondaryEhr into primaryEhr
@ppazos
ppazos / linux_commands.sh
Last active November 14, 2025 21:34
Useful linux commands
# Find big files
find / -type f -size +500M -ls
# Monitor file changes in folder
inotifywait -e modify,delete,move -m -r logs
@ppazos
ppazos / colums_with_type.sql
Created October 19, 2025 01:53
Get columns with a specific type from mysql
SELECT
TABLE_SCHEMA,
TABLE_NAME,
COLUMN_NAME,
DATA_TYPE
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
DATA_TYPE = 'datetime' AND TABLE_SCHEMA = 'atomik'
ORDER BY
@ppazos
ppazos / hapi_fhir_extract_patient_names.java
Created August 11, 2025 22:12
Read all the names and extensions from given and family names from a patient resource instance in HAPI FHIR.
Patient fhirPatient = ...
for (HumanName name : fhirPatient.getName())
{
// family names with extensions
StringType familyElement = name.getFamilyElement();
if (familyElement != null) {
System.out.println("Family: " + familyElement.getValue());
for (Extension ext : familyElement.getExtension()) {
System.out.println(" Family Extension: " + ext.getUrl() + " = " + ext.getValue());
@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%'