Skip to content

Instantly share code, notes, and snippets.

View grational's full-sized avatar

Giuseppe Ricupero grational

View GitHub Profile
@grational
grational / test.groovy
Last active April 9, 2024 08:27
empovered-text sample
@GrabResolver('https://jitpack.io')
@Grab('com.github.grational:empovered-text:v0.5.0')
import it.grational.text.EmpoveredText
String original = """<p><strong>Informazioni Azienda <em>ENZA <u>BUTTIGLIERI</u></em> S.A.S. DI <u>VINCENZA BUTTIGLIERI E C.</u></strong></p><p>L'azienda&nbsp;<strong>ENZA BUTTIGLIERI S.A.S. DI VINCENZA BUTTIGLIERI E C.</strong>, con partita IVA 01639160090 e codice fiscale <em>italico <u>01639160090</u></em>, ha come attivit\u00e0 prevalente Servizi dei saloni di barbiere e parrucchiere ed \u00e8 registrata con il codice Ateco prevalente: 96.02.01 . L'ultimo fatturato disponibile \u00e8 del [anno] ed \u00e8 di {fatturato}. La sua forma giuridica \u00e8 Societ\u00e0 in accomandita semplice e la sua sede legale si trova in VIA NIELLA 29 R - 17100 SAVONA, in provincia di SV.</p><p>ENZA BUTTIGLIERI S.A.S. DI VINCENZA BUTTIGLIERI E C. <u>ha raggiunto un fatturat</u>o nel 2021 di \u20ac&nbsp;0&nbsp;e nel 2022 di \u20ac&nbsp;0&nbsp;con una differenza di \u20ac&nbsp;0,00</p><ul><li>&nbsp;La
@grational
grational / vim-recover.sh
Created March 2, 2020 09:37
vim-recover: recover all the vim orphan swap files
#!/usr/bin/env bash
# vim-recover: recover all the orphan swap files
# @version: 0.5b
# @require: set directory=~/.config/nvim/swap_files//
# @author: Giuseppe Ricupero
# @e-mail: [email protected]
set -euo pipefail
IFS=$'\n\t'
vim_flavour=/usr/bin/vim
@grational
grational / crontab
Last active November 21, 2019 17:16
It's a simple crontab wrapper to avoid discarding your crontab file by mistake
#!/usr/bin/env bash
set -euo pipefail
crontab_bin=/usr/bin/crontab
if (( ${#@} != 1 )); then
echo 1>&2 "${0##*/} <param>"
exit 1
fi
if [[ $1 == '-r' ]]; then
{
"meta": {
"uuid": "0b6caa79-1aef-4ade-b575-464f54705b0b",
"request": {
"path": "iol/cc/A1235678/kpi/leads",
"qparams": {
"min_date": "2017-02-23",
"max_date": "2017-05-23",
"time_aggregation": "month",
"leads_aggregation": "lead"
import it.italiaonline.rnd.filters.TextFilter;
/**
* This class includes simple test cases for the AddressSmartCap filter
* <p>
* A couple of arrays are defined with input / expected_output and a for loop
* to couple them checking against the SmartCap filter.
* @author Giuseppe Ricupero
* @date 26/10/16 10.26
*/
@grational
grational / IOL-smart-cap-usage.java
Created June 27, 2016 09:23
This class is just a simple test cases for the SmartCap filter
import it.italiaonline.rnd.filters.TextFilter;
/**
* This class includes simple test cases for the SmartCap filter
* <p>
* A couple of arrays are defined with input / expected_output and a for loop
* to couple them checking against the SmartCap filter.
* @author Giuseppe Ricupero
* @date 27/06/16 09.12
*/
@grational
grational / build.gradle
Created May 26, 2016 09:45
Simple gradle configuration to run a java standalone binary
// Apply the java plugin to add support for Java
apply plugin: 'java'
// Apply the application plugin to run standalone artifacts
apply plugin: 'application'
// In this section you declare where to find the dependencies of your project
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
#!/bin/bash
# set -e: if a command fails, it will make the whole script exit
# set -u: treat unset variables as an error, and immediately exit.
set -eu
SCRIPT_NAME="${0##*/}"
usage() {
echo "${SCRIPT_NAME} usage:"
echo '<*> [-P | --profile] <local|test|production>'
@grational
grational / python_parametric_sub.py
Created November 11, 2015 16:54
Replace a matching group with a name passed as parameter with another parameter
import re
from functools import partial
pattern = '^[a-zA-Z0-9-_]*_(?P<pos>[A-Z]\d\d)_T\d{4}(?P<fID>F\d{3})L\d{2}A\d{2}(?P<zID>Z\d{2})(?P<cID>C\d{2})\.tif$'
filename = '151006_655866_Z01_T0001F015L01A02Z01C03.tif'
def replace_closure(subgroup, replacement, m):
if m.group(subgroup) not in [None, '']:
start = m.start(subgroup)
@grational
grational / extractLanding.java
Created November 9, 2015 16:16
Extract central field of the landing url
import java.util.regex.Matcher;
import java.util.regex.Pattern;
String input = "https://test-landing.seat.it/Ristoranti_di_SCHIRALLI_ANTONIO_14b9/home.html";
//Extract services
final Pattern landingPattern = Pattern.compile(":\\/\\/.*\\/(.*)\\/");
Matcher m = landingPattern.matcher(input);
if(m.find()) {