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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / 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