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 / 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 June 14, 2023 15:19
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;
@checco
checco / json-test.rb
Created October 13, 2016 09:57
JSON API call test
require 'uri'
require 'net/http'
url = URI("http://www.hostelspoint.com/webservices/affiliates/json.php?IDSite=2336&requestType=AvailSearchCity&day=11&year_month=2016-11&nights=1&guests=1&currency=EUR&cat=&lang=en&order=&room_type=&city=190")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["cache-control"] = 'no-cache'
@checco
checco / HotelAvailRQ.rb
Last active October 17, 2016 08:00
OTA_HotelAvailRQ with class NET:Http
require 'uri'
require 'openssl'
require 'net/http'
url = URI("https://www.hostelspoint.com/xml/xml.php")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@checco
checco / HotelDescriptiveInfoRQ.rb
Last active October 17, 2016 07:59
OTA_HotelDescriptiveInfoRQ with class NET:Http
require 'uri'
require 'openssl'
require 'net/http'
url = URI("https://www.hostelspoint.com/xml/xml.php")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE