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 / vagrant-hosts.sh
Created April 8, 2016 15:41
Script that return a list of running Vagrant machine (IP HOSTNAME), so you can copy and paste it on your /etc/hosts
#!/bin/bash
interface="eth0"
hosts=`vagrant status | grep running | awk '{print $1}'`
if [ `echo ${hosts} | wc -w` -gt '0' ]
then
for host in ${hosts}
do
ip=`echo "ip a sh dev ${interface} | grep 'inet ' | sed 's/\// /g'" | vagrant ssh ${host} | awk '{print $2}'`
@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 / 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
@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 / PingRQ.rb
Last active October 17, 2016 08:01
OTA_PingRQ 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 / send-telegram.py
Last active January 22, 2017 23:36
Python 3 script which permit to your bot to send messages in a group chat or a single person
#!/usr/bin/env python3
import urllib3
import certifi
import sys
# Generate a bot ID here: https://core.telegram.org/bots#botfather
bot_id = ''
chat_id = ''
@checco
checco / url_check.py
Last active August 1, 2018 15:13
Python script that checks the HTTP status code of an URL. You have to write a list of URLs (url_list.csv), with the desired status code on the second column (if the second column is empty it takes a 200 like default value). You can use this script for automatic testing some URLs of your internal/external environment
#!/usr/bin/env python
import requests
file = "url_list.csv"
with open(file, 'r') as f:
for line in f:
line += ' '
url = line.split(' ')[0].strip()
@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 / 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 / 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
--