Skip to content

Instantly share code, notes, and snippets.

Francesco Pira pirafrank

Block or report user

Report or block pirafrank

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pirafrank
pirafrank / exif_datetime_setter.sh
Last active Sep 28, 2018
Update EXIF datetime data from filename pattern (if not set) or update file timestamps from EXIF metadata (if it is set)
View exif_datetime_setter.sh
#!/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 Sep 19, 2018 — forked from subfuzion/curl.md
curl POST examples
View curl.md

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 Sep 17, 2018
A simple script to create a folder with a random name to be served by a web server
View share.sh
#!/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 / ssh_host_key_digest_calculator.sh
Last active Sep 14, 2018
Script to calculate digest of SSH host keys with different algorithms. Output is in HEX and Base64 formats.
View ssh_host_key_digest_calculator.sh
#!/bin/bash
keylist="/etc/ssh/ssh_host_rsa_key.pub /etc/ssh/ssh_host_dsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ed25519_key.pub"
printf "\n%s\n" "$(hostname)"
for keyfile in $keylist; do
if [ -f $keyfile ]; then
printf "\n $keyfile\n"
printf " %-6s -- %-6s -- " "SHA256" "HEX"
awk '{print $2}' $keyfile | base64 -d | sha256sum -b | awk '{print $1}'
@pirafrank
pirafrank / hex_to_base64_and_back.sh
Created Sep 14, 2018
convert hex string to base64 string and viceversa
View hex_to_base64_and_back.sh
# 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
View markdown_cheatsheet.md

Markdown Cheat Sheet

THIS IS NOT MY WORK. Credits to the creator of sublimetext-markdown-preview.


This is a sample markdown file to help you write Markdown quickly :)

If you use the fabulous [Sublime Text 2/3 editor][ST] along with the [Markdown Preview plugin][MarkdownPreview], open your ST2 Palette with CMD+⇧+P then choose Markdown Preview in browser to see the result in your browser.

@pirafrank
pirafrank / speedtest.sh
Created Jun 15, 2018
internet speedtest from command line
View speedtest.sh
wget --output-document=/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip
@pirafrank
pirafrank / ip6tables_rules.sh
Last active Jun 12, 2018
disable IPv6 on iptables
View ip6tables_rules.sh
ip6tables -P INPUT DROP
ip6tables -P FORWARD DROP
ip6tables -P OUTPUT ACCEPT
@pirafrank
pirafrank / docker_jessie.sh
Last active May 28, 2018
Install Docker on Debian Jessie (Debian 8.x)
View docker_jessie.sh
#!/bin/bash
# install latest docker-ce release on debian jessie (debian 8.x) or newer
# you need to run this script as root
apt-get update
apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
@pirafrank
pirafrank / download_entire_website.sh
Last active May 26, 2018
Quick script that use wget to download an entire website
View download_entire_website.sh
#!/bin/bash
if [[ $# != 2 ]]; then
echo "Error: wrong number of arguments"
echo ""
echo "Usage: ./download-entire-website.sh <domain> <url>"
echo "Example ./download-entire-website.sh websitetodownload.com www.websitetodownload.com/page/"
echo ""
exit -1
fi
You can’t perform that action at this time.