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 / i18n_messages_with_variables.groovy
Created February 22, 2024 01:06
Methods to replace ordered arguments on strings and access certain paths on parsed JSON objects
// UTIL METHODS
/**
* Replaces arguments in error messages: "This {0} is an error for {1}", [a, b] => "This a is an error for b"
*/
private error_message_replace_values(String error_msg, List values)
{
for (int i = 0; i < values.size(); i++)
{
error_msg = error_msg.replace("{$i}", values[i].toString())
@ppazos
ppazos / electron-builder.json
Created February 20, 2024 03:52 — forked from thatisuday/electron-builder.json
A simple electron-builder configuration.
{
"appId": "com.thatisuday.fileio",
"productName": "Electron File IO",
"copyright": "THATISUDAY TECH PVT. LTD.",
"directories": {
"app": ".",
"output": "out",
"buildResources": "build-res"
},
"files": [
@ppazos
ppazos / better-git-branch.sh
Created February 11, 2024 18:58 — forked from schacon/better-git-branch.sh
Better Git Branch output
#!/bin/bash
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NO_COLOR='\033[0m'
BLUE='\033[0;34m'
YELLOW='\033[0;33m'
NO_COLOR='\033[0m'
@ppazos
ppazos / instanceFromName.groovy
Created February 11, 2024 15:52 — forked from neelsmith/instanceFromName.groovy
groovy: get an instance of a class from its name as a string
def objectInstance = Class.forName("NAME.AS.STRING").newInstance()
@ppazos
ppazos / connect_dom_with_lines.js
Last active February 8, 2024 22:51
Connect DOM boxes
Sample https://jsfiddle.net/ppazos/Lngbx0t9/5/
Reference to the drawing API https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/beginPath
Better library https://github.com/anseki/leader-line
# HTML
<canvas id="canvas" width=300 height=300></canvas>
<div style="margin-left: 30px">
@ppazos
ppazos / CommonTagLib.groovy
Created January 21, 2024 16:29 — forked from pledbrook/CommonTagLib.groovy
Example map with enum keys
import org.grails.common.ApprovalStatus
import static org.grails.common.ApprovalStatus.*
class CommonTagLib {
static namespace = "common"
static final STATUS_TO_CSS_CLASS = [
(PENDING): "warning",
(REJECTED): "important",
(APPROVED): "success" ].asImmutable()
@ppazos
ppazos / mirth_http_response_status.js
Created September 15, 2023 05:15
Mirth Connect access to HTTP response status on response transformer
// response transformer
logger.info("RESPONSE TRANSFORMER");
logger.info(msg);
logger.info($('responseStatusLine'));
var statusLine = $('responseStatusLine');
var parts = statusLine.split(' ');
if (parts.length >= 2)
@ppazos
ppazos / webServer.groovy
Created June 30, 2023 01:35 — forked from renatoathaydes/webServer.groovy
A simple web server written in Groovy that provides static and code-generated content
#!/usr/bin/env groovy
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.servlet.*
import groovy.servlet.*
@Grab(group='org.eclipse.jetty.aggregate', module='jetty-all', version='7.6.15.v20140411')
def startJetty() {
def server = new Server(8080)
@ppazos
ppazos / is_subclass.groovy
Created May 18, 2023 02:37
Checking if a class is the same or subclass of another class
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
@ppazos
ppazos / ph_queries.php
Created May 5, 2023 18:35
New API for phresistence queries
<?php
$emp_payor = $EmployerPayor->findBy([
'AND' => [
['employer_id', '=', $employer->get_id()],
'OR' => [
'AND' => [
['valid_to', '>', $dos],
['valid_from', 'IS NULL']
],