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 / setup_java.sh
Created October 31, 2020 19:31
A script to download Oracle JDK (versions from 9 to 11). Licence restrictions apply. Read them on: https://www.oracle.com/downloads/licenses/javase-license1.html#licenseContent
#!/bin/bash
function calculate_url {
curl -sSL $baseurl | \
grep 'linux-x64_bin.tar.gz' | head -n1 | \
grep -E "data-file[=0-9a-zA-Z'//\.%-_]*" -o | \
cut -d"'" -f2 | cut -d'/' -f3- | \
sed s@/otn/@/otn-pub/@g | sed s@^@https://@g
}
@pirafrank
pirafrank / instagram_download.py
Last active October 27, 2020 08:28
Use Pythonista to download an image from Instagram. Usage via the share extension or run it straight from your home screen (in this case it will get the url from the iOS clipboard). Save this file in the 'This Phone' path in Pythonista, then download this shortcut: https://www.icloud.com/shortcuts/d45759eb469b445b943049bf8488e995
#!python2
# this script is for Pythonista 2 and 3
# author: Francesco Pira (fpira.com)
import sys
import requests
from bs4 import BeautifulSoup
import re
import clipboard
@pirafrank
pirafrank / ephemeral
Created October 19, 2020 21:06
an ephemeral text editor in your browser. create a new bookmark and paste the raw content of this gist inside in the url field. enjoy!
data:text/html;base64,PCFET0NUWVBFIGh0bWw+DQo8IS0tDQogIFlvdSBjdXJpb3VzIDpQDQogLS0+DQo8aHRtbCBsYW5nPSJlbiI+DQo8aGVhZD4NCiAgPG1ldGEgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmljZS13aWR0aCwgaW5pdGlhbC1zY2FsZT0xLjAiPg0KICA8dGl0bGU+RXBoZW1lcmFsIFRleHQgRWRpdG9yPC90aXRsZT4NCiAgPHN0eWxlPg0KICAgIGJvZHkgew0KICAgICAgdGV4dC1hbGlnbjogY2VudGVyOw0KICAgICAgZm9udC1mYW1pbHk6IEFyaWFsLCBIZWx2ZXRpY2EsIHNhbnMtc2VyaWY7DQogICAgfQ0KICAgIC5iZWNvb2wgew0KICAgICAgbGluZS1oZWlnaHQ6MS41Ow0KICAgICAgZm9udC1zaXplOjE4cHg7DQogICAgICBmb250LWZhbWlseTogbW9ub3NwYWNlOw0KICAgICAgbWluLWhlaWdodDogMTBlbTsNCiAgICAgIHBhZGRpbmc6IDE1cHg7DQogICAgICBib3JkZXI6IDJweCBzb2xpZCAjMzMzMzMzOw0KICAgICAgYm9yZGVyLXJhZGl1czogNXB4Ow0KICAgICAgbWFyZ2luLWxlZnQ6IDN2dzsNCiAgICAgIG1hcmdpbi1yaWdodDogM3Z3Ow0KICAgICAgdGV4dC1hbGlnbjogbGVmdDsNCiAgICB9DQogICAgLmZvb3RlciB7DQogICAgICBwYWRkaW5nLXRvcDogMTBweDsNCiAgICAgIGZvbnQtc2l6ZTogMC45ZW07DQogICAgfQ0KICA8L3N0eWxlPg0KPC9oZWFkPg0KPGJvZHk+DQogIDxkaXYgY2xhc3M9InRvcCI+DQogICAgPHA+DQogICAgICBKdXN0IGEgcHJldHRpZXIgPGNvZGU+Y29udGVudGVkaXRhYm
@pirafrank
pirafrank / hetzner.sh
Created October 18, 2020 19:12 — forked from Knight1/hetzner.sh
Hetzner Cloud create temporary Windows Servers
#!/bin/bash
ID=`hcloud server list | tail -1 | grep Windoof | awk '{print $1;}'`
CONTEXT=`hcloud context active`
if [ "$CONTEXT" != "testing" ]; then
echo "[CRIT] Aborting, wrong context"
exit
fi
@pirafrank
pirafrank / s3_kms_docker_registry_policy.json
Created October 4, 2020 17:41
AWS policy to host a private docker registry on an AWS-KMS encrypted S3 bucket. Attach it to a new IAM user to get Access and Secret keys that only allow access to the given bucket.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
@pirafrank
pirafrank / nordvpn_download.sh
Created January 7, 2020 19:54
download .ovpn files per country from nordvpn website
#!/bin/bash
country="$1"
# e.g. fr, it, de, etc.
mkdir -p "$country/UDP"
cd $country/UDP
curl -sSL https://nordvpn.com/ovpn | grep -E "\/$country[0-9]*.nordvpn.com" | grep 'UDP' | cut -d'"' -f2 | xargs wget
cd ..
mkdir TCP
@pirafrank
pirafrank / ssh_host_key_digest_calculator.sh
Created June 3, 2020 09:37
Script that calculates digest of SSH host keys (different algorithms, output in HEX and Base64) and generates SSHFP DNS entries
#!/bin/bash
# available as gist at https://gist.github.com/pirafrank/df40b2b082b91ed79036b328a3f010da
# keep it in this order to match SSHFP numbers
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"
SSHFP=0
algolist="sha256 sha1 md5"
@pirafrank
pirafrank / jwtBody.js
Created May 25, 2020 09:16
extract jwt body with no validation
# sometimes you only need to get JWT body data without validating it
# WARNING: use this only if you have already validated the token in earlier steps in the chain
const jwt = "eyJ0eX...";
const jwtBodyJson = JSON.parse(Buffer.from(jwt.split(".")[1], "base64").toString());
@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 / scaleway.py
Last active April 22, 2020 22:03
dummy script to create, list and delete VMs on scaleway. differently from scaleway_pythonista.py, this is meant to be run on PC
#! python2
#import console
#import dialogs
import urllib2
import json
import requests
import time
api_token = "aaabbb11-9087-5678-1234-000000aaaaaa"