Skip to content

Instantly share code, notes, and snippets.

View checco's full-sized avatar
🐗
I'm always hungry

Francesco Latini checco

🐗
I'm always hungry
View GitHub Profile
@checco
checco / unique_index.sh
Created August 16, 2024 12:46
On Nexus 3.71.0, after the migration from OrientDB to H2 all "auto increment" columns in the H2 database have been reset to start at "1"
#!/bin/bash
NEXUS_BIN=/opt/sonatype/nexus
NEXUS_DATA=/opt/sonatype/sonatype-work/nexus3
h2sql() {
echo "> $@" >&2
java -cp "$NEXUS_BIN"/system/com/h2database/h2/*/h2-*.jar org.h2.tools.Shell -url jdbc:h2:"$NEXUS_DATA"/db/nexus -sql "$@"
}
schema=$(h2sql "SCRIPT NODATA")
@checco
checco / kubectl-run-with-pvc.sh
Created July 15, 2024 07:08 — forked from yuanying/kubectl-run-with-pvc.sh
kubectl run with PVCs
#!/bin/bash
IMAGE="gcr.io/google-containers/ubuntu-slim:0.14"
COMMAND="/bin/bash"
SUFFIX=$(date +%s | shasum | base64 | fold -w 10 | head -1 | tr '[:upper:]' '[:lower:]')
usage_exit() {
echo "Usage: $0 [-c command] [-i image] PVC ..." 1>&2
exit 1
}
@checco
checco / bulk_delete_workouts.js
Created May 1, 2024 10:16
Bulk delete workouts on Garmin connect, via development tool console
function deleteWorkouts() {
const deleteWorkoutElements = document.querySelectorAll('.delete-workout');
if (deleteWorkoutElements.length === 0) {
console.log('No more "delete-workout" elements found.');
return;
}
deleteWorkoutElements[0].click();
@checco
checco / recursive-md5sum.sh
Created October 20, 2023 12:45
Print a md5 checksum for directories recursively
#!/bin/bash
for dir in `find . -type d -not -path '*/.*'`;
do
echo -en "${dir}: ";
find ${dir} -type f -not -path '*/.*' -exec md5sum {} \; | md5sum | awk '{print $1}';
done
@checco
checco / fusionauth_migration_from_mysql_to_psql.sh
Last active June 7, 2021 13:53
Migrate FusionAuth from MySQL to PostgreSQL on DigitalOcean
# FusionAuth database has tables which don't have primary keys this is a problem from the Digital Ocean perspective,
# because they are using row-based replication with the MySQL engine to provide backups and read replicas.
# We have migrated 2 environments, from MySQL 8 to PostgreSQL 12
# pgloader help
docker run --rm --name pgloader dimitri/pgloader:latest pgloader --help
# run pgloader
docker run --rm --name pgloader dimitri/pgloader:latest pgloader --no-ssl-cert-verification --verbose --debug \
"mysql://odyssey-auth:${mysql_password}@${digitalocean_mysql_host}:25060/odyssey-auth"
@checco
checco / remove_merged_branches.sh
Created November 7, 2019 10:12
Remove all merged GIT branches
#!/bin/bash
git for-each-ref --format '%(refname:short)' refs/heads | grep -v master | xargs git branch -D
@checco
checco / postgres-owner-grants.sql
Last active September 11, 2024 08:55
How to change OWNER for DATABASE, SCHEMA or TABLE on AWS RDS PostgreSQL. An how to REASSIGN owner for all objects on AWS RDS PostgreSQL
--
-- Change database owner
--
ALTER DATABASE "db_name" OWNER TO user;
--
-- List schemas
--
@checco
checco / vault-upgrade.sh
Last active October 21, 2023 08:39
[deprecated] Bash script to upgrade Vault to the latest release on Linux
#!/bin/bash
url="https://releases.hashicorp.com/vault"
latest_version=`curl -s ${url}/ | grep -A6 "<a href=\"../\">../</a>" | grep vault | cut -d '_' -f 2 | cut -d '<' -f 1`
bin="/usr/local/bin/vault"
install () {
cd /tmp && \
/bin/wget -q ${url}/${latest_version}/vault_${latest_version}_linux_amd64.zip && \
/bin/unzip -qq vault_${latest_version}_linux_amd64.zip
@checco
checco / terraform-upgrade.sh
Last active October 21, 2023 08:39
[deprecated] Bash script to upgrade Terraform to the latest minor or major release on Linux
#!/bin/bash
url="https://releases.hashicorp.com/terraform"
latest_version=`curl -s ${url}/ | grep -A6 "<a href=\"../\">../</a>" | grep terraform | cut -d '_' -f 2 | cut -d '<' -f 1`
bin="/usr/local/bin/terraform"
install () {
cd /tmp && \
/bin/wget -q ${url}/${latest_version}/terraform_${latest_version}_linux_amd64.zip && \
/bin/unzip -qq terraform_${latest_version}_linux_amd64.zip
@checco
checco / rw_ro_access.sql
Last active March 22, 2024 08:32 — forked from oinopion/read-access.sql
How to create a read only user in AWS RDS PostgreSQL and a user with superuser privileges on AWS RDS PostgreSQL
--
-- Read only
--
-- Create a group
CREATE ROLE postgres_ro_group;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO postgres_ro_group;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO postgres_ro_group;