Skip to content

Instantly share code, notes, and snippets.

View elvisciotti's full-sized avatar

Elvis Ciotti elvisciotti

View GitHub Profile
@elvisciotti
elvisciotti / macPiaDedicatedIp.sh
Created November 2, 2024 00:03
crontab: private internet access reconnect to dedicated IP during specic time interval
# replace xxx with what you get from "piactl get region"
# every 5 minutes, 9 to 18 mon-fri
*/5 9-18 * * 1-5 [[ $(/usr/local/bin/piactl get region) == "xxxx" ]] || (/usr/local/bin/piactl set region xxxx; /usr/local/bin/piactl connect)
@elvisciotti
elvisciotti / intelliJMoveScratches.bash
Created November 1, 2024 10:51
intelliJ: point scratches to google drive
DRIVE_DIR=$HOME/Google\ Drive/My\ Drive/Backups/intellij-scratches
INTELLIJ_DIR=$HOME/Library/Application\ Support/JetBrains/IntelliJIdea2024.2/scratches
mkdir $DRIVE_DIR
mv $INTELLIJ_DIR/* $DRIVE_DIR/
rmdir $INTELLIJ_DIR
ln -s $DRIVE_DIR $INTELLIJ_DIR
@elvisciotti
elvisciotti / handler.js
Last active November 27, 2022 23:14
AWS node function deployed with Terraform - complete example
'use strict';
function shuffle(array) {
let currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
@elvisciotti
elvisciotti / mailer.py
Created March 7, 2021 16:03
Python handler to send a SES mail when a S3 object (with a ruleset mail) is created
# copiata pari pari da https://aws.amazon.com/blogs/messaging-and-targeting/forward-incoming-email-to-an-external-destination/
# https://docs.aws.amazon.com/lambda/latest/dg/with-s3.html
import os
import boto3
import email
import re
from botocore.exceptions import ClientError
from email.mime.multipart import MIMEMultipart
@elvisciotti
elvisciotti / crypt.bash
Created June 12, 2020 10:13
Openssl 1.1 simmetric crypt and decrypt command line on Mac OSx
# crypt all txt files into .env and delete source
OPENSSL_BIN="/usr/local/Cellar/[email protected]/1.1.1g/bin/openssl"
PASSWORD="password-changeme"
for TXT in ~/path/to/*.txt; do
test -f $TXT && \
$OPENSSL aes-256-cbc -pbkdf2 -a -salt -in "${TXT}" -out "${TXT}.enc" -pass pass:${PASSWORD} && \
rm -f "${TXT}"
done
@elvisciotti
elvisciotti / postman-pre-request-sign-hmac-ripe160.js
Last active June 12, 2020 10:09
Postman pre-request script to sign requests adding api-key and api-sign created using HmacRIPEMD160 based on secret and URI, for two different environments
const API_KEYS = {
'prod': {
'key': '',
'secret': '',
},
'uat': {
'key': '',
'secret': '',
}
};
@elvisciotti
elvisciotti / kindleParser.js
Last active June 7, 2020 11:54
Node script to reorganise kindle's "My Clippings.txt" into a human readable markdown file
#!/usr/local/bin/node
/**
* Node script to convert kindle notes into
* ./kindleParse.js > myClippings.md
*/
const endOfLine = "\r\n";
const kindleNoteDelimiter = "==========" + endOfLine;
const titlePrefix = endOfLine + "# ";
const titleSuffix = endOfLine + endOfLine;
@elvisciotti
elvisciotti / README.md
Created May 8, 2020 22:29 — forked from astamicu/Remove videos from Youtube Watch Later playlist.md
Script to remove all videos from Youtube Watch Later playlist

UPDATE 17.10.2019

Only works on old youtube skin.

//added "&disable_polymer=true" after playlist link

Also, saw this now, there is a "remove watched" button.

  1. Open your watch later playlist on youtube.
  2. Open the development console for your browser ( Ctrl+Shift+J for chrome, Ctrl+Shift+K for firefox )
@elvisciotti
elvisciotti / dockertags.sh
Last active August 14, 2022 06:36
Script to fetch docker tags for an image e.g. "dockertags busybox cli"
#!/bin/bash
if [ $# -lt 1 ]
then
cat << HELP
dockertags -- list all tags for a Docker image on a remote registry.
EXAMPLE:
- list all tags for ubuntu:
@elvisciotti
elvisciotti / launch.sh
Last active August 14, 2022 06:37
Python sample script to import not-normalised CSV data into MySQL tables, resolving FK values in memory
# create mysql_latest container
docker run --name mysql57_abc \
-e MYSQL_ROOT_PASSWORD=pass \
-e MYSQL_DATABASE=abc \
-e MYSQL_USER=abc \
-e MYSQL_PASSWORD=abc \
-p 3306:3306 \
-d mysql:5.7
# launch if already created
docker start mysql57_abc