Skip to content

Instantly share code, notes, and snippets.

View xanoni's full-sized avatar
🐱
I'm a cat

Linus Xanoni xanoni

🐱
I'm a cat
View GitHub Profile
@xanoni
xanoni / proxy.sh
Created August 7, 2021 03:41
MacOS: turn system-wide proxy settings on/off
#! /usr/bin/env bash
INTERFACES="wi-fi|USB 10/100/1000 LAN"
if [ "${1}" == "on" ] || [ "${1}" == "enable" ]; then
OLD_IFS=${IFS}; IFS="|"
for interface in ${INTERFACES}; do
echo -en "Enabling SOCKS proxy for ${interface}\n"
networksetup -setautoproxyurl "${interface}" " "
networksetup -setautoproxystate "${interface}" off
@xanoni
xanoni / fan-toggle.sh
Created August 7, 2021 03:37
MacOS: toggle fan connected to USB hub
#! /usr/bin/env -S bash -ex
/usr/local/bin/uhubctl -p3 -atoggle
@xanoni
xanoni / socks-set.sh
Created August 7, 2021 03:31
MacOS: quickly switch between SOCKS and HTTP(S) proxies
#!/usr/bin/env -S bash -e
PROXY_CONF_FILE="$HOME/.proxyconfig"
TOR_HTTP_PORT=8118
I2P_HTTP_PORT=4444
IFACES="Wi-Fi|USB 10/100/1000 LAN"
if [ -z "$1" ]; then
@xanoni
xanoni / hostname-set.sh
Created August 7, 2021 03:01
MacOS: switch between 2 hostnames
#! /usr/bin/env -S bash -e
DEFAULT_NAME="X"
CUSTOM_NAME="Y"
# Print current hostname
echo -en "\nCurrent:\n---\n"
scutil --get HostName
scutil --get LocalHostName
scutil --get ComputerName
@xanoni
xanoni / monerod-i2p.conf
Last active August 19, 2021 08:20
monerod: configure inbound I2P tunnel
# File: ~/.bitmonero/monerod.conf
[...]
tx-proxy=i2p,127.0.0.1:4447,25 # to send transactions via I2P
pad-transactions=1 # anti traffic analysis
# Get tunnel address for below line from /var/lib/i2pd/destinations
anonymous-inbound=<TUNNEL_ADDR>.b32.i2p:18084,127.0.0.1:18084,25
[...]
@xanoni
xanoni / scp-delete-during-transfer.sh
Last active August 3, 2021 06:59
scp-delete-during-transfer.sh: for when you're running out of disk space and need to scp a file out while deleting chunks of it
#! /usr/bin/env -S bash -e
SSH_USERHOST="user@host"
REMOTE_PATH="/tmp/disk_backup.img"
OUT_PATH="./$(basename ${REMOTE_PATH})"
TMP_PATH="/tmp/ssh-big-copy"
SLICES=200
echo -e "\nGetting from ${SSH_USERHOST}: ${REMOTE_PATH}\n"
> hdparm benchmark 1/2 (/dev/mapper/cryptssd):
/dev/mapper/cryptssd:
150 MB in 2.01 seconds = 74.80 MB/sec
Timing O_DIRECT disk reads: 232 MB in 3.02 seconds = 76.83 MB/sec
> hdparm benchmark 2/2 (/dev/mapper/cryptssd):
/dev/mapper/cryptssd:
150 MB in 2.01 seconds = 74.57 MB/sec
Timing O_DIRECT disk reads: 232 MB in 3.02 seconds = 76.75 MB/sec
> dd benchmark 1/1 (bs=512M):
write test:
> dd benchmark 1/1 (bs=1M):
write test:
5120+0 records in
5120+0 records out
5368709120 bytes (5.4 GB, 5.0 GiB) copied, 44.1281 s, 122 MB/s
read test:
5120+0 records in
5120+0 records out
> dd benchmark 1/1 (bs=1M):
write test:
5120+0 records in
5120+0 records out
5368709120 bytes (5.4 GB, 5.0 GiB) copied, 47.4326 s, 113 MB/s
read test:
5120+0 records in
5120+0 records out
> dd benchmark 1/1 (bs=1M):
write test:
5120+0 records in
5120+0 records out
5368709120 bytes (5.4 GB, 5.0 GiB) copied, 62.1796 s, 86.3 MB/s
read test:
5120+0 records in
5120+0 records out