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
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 {
/**
@ppazos
ppazos / number_parse.groovy
Created September 13, 2017 14:55
Parsing numbers in Java/Groovy considering locale symbols
def ss = ["12345", "3.14159", "-200.5", "37,1", "1,111,111.55"]
def format = java.text.NumberFormat.getInstance()
println format.class // DecimalFormat
/*
12345 class java.lang.Long
3.14159 class java.lang.Double
-200.5 class java.lang.Double
@ppazos
ppazos / get_emails.groovy
Created October 4, 2017 17:57
Gmail mail list name and email extraction
// Line Format
// email,
// name <email>,
// "name" <email>,
// Group 2 will have the name if available
// Group 3 will have the email
def raw = $/
aaa@mail.com,
@ppazos
ppazos / random_datetime.groovy
Created October 20, 2017 01:24
Generates random date with time between two given dates
import groovy.time.TimeCategory
random = new Random()
Date randomDate(Range<Date> range) {
def res = range.from + random.nextInt(range.to - range.from + 1)
use( TimeCategory ) {
res = res + random.nextInt(24).hours + random.nextInt(60).minutes + random.nextInt(60).seconds
}
res
@ppazos
ppazos / filter_on_select.html
Created January 7, 2018 19:13
Two selects, one has filters, the options on the other select are hidden when the filter changes.
<script>
// change the filter_select to filter items in the target select
filter_select = document.getElementById('filter_select_id');
filter_select.onchange = function (ev) {
var target_select = document.getElementById('target_select_id');
for (i = 0; i < target_select.children.length; i++)
{
option = target_select.children[i];
$(option).show(); // show option if previously hidden from selecting another filter
@ppazos
ppazos / mysql_install.txt
Created February 24, 2018 22:19
Install MySQL on Linux Mint / Ubuntu
sudo apt-get install mysql-server
set the password for root user ("toor" for dev env)
# check mysql is installed
mysql -u root -p
toor
show databases;
exit;
@ppazos
ppazos / remove_openjdk_linux.txt
Created February 25, 2018 05:09
uninstall openjdk and dependencies from Linux Mint / Ubuntu
I found that you can use the following to remove the openjdk-7-jre on Ubuntu 13.04:
sudo apt-get autoremove openjdk-7-jre
Press 'y' and then press enter when prompted to confirm this change. This should also clean up all the additional dependency libraries that were installed with it.
I also found you can use the following command to perform additional clean up:
sudo apt-get purge openjdk*