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 / symlink.ps1
Created February 7, 2021 10:58
PowerShell script to create NTFS symlinks on Windows. It uses UNIX-like args placement.
@pirafrank
pirafrank / ssh-copy-id.ps1
Created February 7, 2021 10:57
ssh-copy-id as Windows PowerShell script. Put it in a folder in your PATH
function print($str) {
Write-Host "$str"
}
if ( $($args.Count) -ne 2 -And $($args.Count) -ne 3 ) {
$scriptName = $MyInvocation.MyCommand.Name
print("Usage: .\$scriptName [args...] pubKeyFile user@host")
exit
}
@pirafrank
pirafrank / docker_vol_dump.sh
Created January 31, 2021 22:50
scripts to dump docker volume to a tar.gz file and import from it
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: ./$0 tar_archive_name volume_name"
exit 1
fi
tararchive="$1"
volname="$2"
BASEDIR="$HOME/docker_vol_exports"
@pirafrank
pirafrank / vim_install.sh
Last active March 18, 2023 12:02
Install vim from source (+python3 +ruby and more) on Ubuntu 20.04 Focal Fossa (GUI options enabled)
#!/bin/bash
# Remove old vim installs
sudo apt-get remove vim vim-runtime gvim vim-tiny \
vim-common vim-gui-common vim-nox gvim
# install vim-gtk deps
sudo apt-get build-dep vim-gtk
# install some more deps
@pirafrank
pirafrank / hetzner.js
Created November 15, 2020 11:00
Scriptable script to list your Hetzner servers in the app and on widgets. Requires iOS 14+ and Scriptable 1.6
// Your Hetzner API token
// Go to Cloud Console > [your project] > Security > API tokens
const token = "PUT_YOUR_TOKEN_HERE" // main
// urls
let listServersUrl = "https://api.hetzner.cloud/v1/servers"
let widget = await createWidget(listServersUrl)
if (config.runsInWidget) {
// The script runs inside a widget, so we pass our instance of ListWidget to be shown inside the widget on the Home Screen.
@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 / 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 / cloudflareDoH.mobileconfig
Last active January 24, 2024 19:57
iOS, iPadOS and tvOS 14 support MDM profile to set encrypted DNS requests (DNS-over-HTTPS and DNS-over-TLS) on cellular and Wi-Fi connection. To install, open this page from your device and click ‘Raw’ on the one of your choice in the GitHub page. Then continue installation in Settings app. Browse https://1.1.1.1/help after installing to check it
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>DNSSettings</key>
<dict>
<key>DNSProtocol</key>