Skip to content

Instantly share code, notes, and snippets.

View pirafrank's full-sized avatar
🎯
Focusing

Francesco Pira pirafrank

🎯
Focusing
View GitHub Profile
@pirafrank
pirafrank / requirements.txt
Last active April 22, 2020 22:05
creating, starting, listing and killing Scaleway VMs via script in Pythonista for iOS
requests
@pirafrank
pirafrank / git_mirror.sh
Created December 17, 2018 23:19
mirror your git repos to make a backup
#!/bin/bash
for url in $(ssh git.example.com ls-urls)
do
echo "Cloning $url ..."
git clone --mirror "$url"
done
@pirafrank
pirafrank / ovpn_generator.conf
Last active January 9, 2019 13:51
Generator of .ovpn files with hardened client config and embedded cert, key and ta.key.
client
dev tun
proto udp
remote <SERVER> <PORT>
resolv-retry infinite
nobind
persist-key
persist-tun
key-direction 1 # <-- DO NOT change this! (server.conf must have: tls-auth ta.key 0)
cipher AES-256-CBC
@pirafrank
pirafrank / exif_datetime_setter.sh
Last active September 28, 2018 16:35
Update EXIF datetime data from filename pattern (if not set) or update file timestamps from EXIF metadata (if it is set)
#!/bin/bash
# Simple script to parse JPG photo filename and set exif datetime,
# creation date and file modification date accordingly.
# Filename pattern is YYYYMMDD_hhmmss.
# Timezone is taken by your PC.
# exec this script by searching for .JPG and .jpg files in given folder
# find . -type f -name "*.JPG" -o -name "*.jpg" -exec /path/to/exif_datetime_setter.sh {} \;
@pirafrank
pirafrank / curl.md
Created September 19, 2018 09:13 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@pirafrank
pirafrank / share.sh
Last active September 17, 2018 23:03
A simple script to create a folder with a random name to be served by a web server
#!/bin/bash
if [ -z "$1" ]; then
echo "Error: no arguments given"
echo "Usage: ./share.sh file1 file2 file3 etc."
exit 1
fi
# Script variables
basepath="/var/www/sharing.example.com"
@pirafrank
pirafrank / hex_to_base64_and_back.sh
Created September 14, 2018 09:23
convert hex string to base64 string and viceversa
# convert hex string to base64 string
| xxd -r -p | base64
# convert base64 string to hex string
| base64 -d | od -t x1 -An
# Example: the whole circle in one command
# convert base64 to binary, to sha256 checksum (string in hex format), to decoded hex data (xxd -r),
# to base64 string, to base64 decoded data (base64 -d), back to hex string
awk '{print $2}' /etc/ssh/ssh_host_ecdsa_key.pub | base64 -d | sha256sum -b | awk '{print $1}' | xxd -r -p | base64 | base64 -d | od -t x1 -An
@pirafrank
pirafrank / speedtest.sh
Created June 15, 2018 08:38
internet speedtest from command line
wget --output-document=/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip
@pirafrank
pirafrank / ip6tables_rules.sh
Last active June 12, 2018 06:58
disable IPv6 on iptables
ip6tables -P INPUT DROP
ip6tables -P FORWARD DROP
ip6tables -P OUTPUT ACCEPT
@pirafrank
pirafrank / firewalld_rules.sh
Last active October 10, 2018 12:32
basic firewalld rules
# basic firewalld rules and commands
# check if running
# systemctl status firewalld
# firewall-cmd --state
# list ports
# firewall-cmd --list-all
# firewall-cmd --list-all --zone=public
# firewall-cmd --list-all --zone=public --permanent