Skip to content

Instantly share code, notes, and snippets.

Avatar

Francesco Pira pirafrank

View GitHub Profile
@pirafrank
pirafrank / run_other_teams.ps1
Created Nov 19, 2021
Powershell script to open another instance of Microsoft Teams desktop application. This script runs the app as another user, you need to create another local Windows user before running the script. Check the link the comments to find out how. Tested on Windows 10 and Microsoft Teams v1.4.00.29469 (64-bit, last updated on 11/19/2021)
View run_other_teams.ps1
# Read me:
#
# You need to do some setup before running this script.
# Check the link below.
#
# Run this script as admin in powershell.
# By the way if you run it in a standard powershell it will
# prompt to open a new shell as admin.
#
@pirafrank
pirafrank / cloudflareDoH.mobileconfig
Last active Nov 5, 2021
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
View cloudflareDoH.mobileconfig
<?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>
@pirafrank
pirafrank / checkrun.sh
Created Oct 18, 2021
checkrun - a function to get try-catch in bash
View checkrun.sh
function checkrun {
if [ $1 -ne 0 ]; then
echo "$2"
exit 2
fi
}
function test1 {
echo "test1" && \
echo "print 2"
@pirafrank
pirafrank / httpserver.py
Created May 21, 2020
python3 -m http.server PORT for a CORS world
View httpserver.py
#!/usr/bin/env python3
# It's python3 -m http.server PORT for a CORS world
from http.server import HTTPServer, SimpleHTTPRequestHandler
import sys
class CORSRequestHandler(SimpleHTTPRequestHandler):
@pirafrank
pirafrank / kube_tools.sh
Created May 3, 2021
Install useful tools for Kubernetes
View kube_tools.sh
#!/bin/bash
folder="${HOME}/.local/bin"
echo "
Running as : $(whoami)
Home folder: $HOME
Install dir: $folder
"
@pirafrank
pirafrank / symlink.ps1
Created Feb 7, 2021
PowerShell script to create NTFS symlinks on Windows. It uses UNIX-like args placement.
View symlink.ps1
@pirafrank
pirafrank / ssh-copy-id.ps1
Created Feb 7, 2021
ssh-copy-id as Windows PowerShell script. Put it in a folder in your PATH
View ssh-copy-id.ps1
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 Jan 31, 2021
scripts to dump docker volume to a tar.gz file and import from it
View docker_vol_dump.sh
#!/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 Jan 27, 2021
Install vim from source (+python3 +ruby and more) on Ubuntu 20.04 Focal Fossa
View vim_install.sh
#!/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 Nov 15, 2020
Scriptable script to list your Hetzner servers in the app and on widgets. Requires iOS 14+ and Scriptable 1.6
View hetzner.js
// 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.