Skip to content

Instantly share code, notes, and snippets.

View Lotti's full-sized avatar

Valerio Riva Lotti

View GitHub Profile
@Lotti
Lotti / php_set.sh
Last active December 7, 2023 17:57
Bash script to set PHP executable in $PATH variable. To be used in Windows with MSYS2 MINGW64 bash shell. PHP releases must be already installed on a dedicated path.
#!/bin/bash
THIS_SCRIPT_PATH="/path/to/this/script"
PHP_VERSION=""
PHP_INSTALLATION_FOLDER="/path/to/php/versions"
PHP_FOLDER_PREFIX="php-"
PHP_PATH_PREFIX="${PHP_INSTALLATION_FOLDER}/${PHP_FOLDER_PREFIX}"
PHP_PATH="${PHP_PATH_PREFIX}${PHP_VERSION}"
if [[ -n "${PHP_VERSION}" ]]; then
@Lotti
Lotti / download_couchdb.sh
Created April 29, 2021 14:57
Downloads documents from couchdb
OUTPUT_COUCHDB_URL=xxxx
OUTPUT_COUCHDB_DBNAME=xxxx
OUTPUT_COUCHDB_USERNAME=xxxx
OUTPUT_COUCHDB_PASSWORD=xxxx
TMP_FILE=tmp-output.json
FOLDER=docs
LIMIT=1000
SKIP=0
rm -Rf "./${FOLDER}"
@Lotti
Lotti / scp_app.sh
Created April 29, 2021 14:56
Download application folder from a Cloud Foundry deployment through ssh
#!/bin/bash
#CONFIG
APP_NAME="$1"
DIR_NAME="."
REMOTE_PATH="~/app"
EXCLUDE="$2"
#----------------
APP_GUID=$(bx -q cf app ${APP_NAME} --guid)
@Lotti
Lotti / jq_explode.sh
Created April 29, 2021 14:36
script to split array of objects in separated file. bash, input: json file, output: json files
FILE=discovery-insurance.json
FOLDER=docs-insurance
rm -Rf "./${FOLDER}"
ROWS=$(jq '.results | length' "./${FILE}")
if [[ "${ROWS}" -eq "0" ]]; then
echo "ARRAY WITH ZERO ELEMENTS. EXIT."
break
fi
@Lotti
Lotti / skill-Pizza-a-domicilio.json
Created April 26, 2021 20:36
Skill Watson Assistant "Pizza a domicilio"
{
"intents": [
{
"intent": "capabilities",
"examples": [
{
"text": "che aiuto mi puoi dare?"
},
{
"text": "che suggerimenti puoi darmi?"