Skip to content

Instantly share code, notes, and snippets.

@iwconfig
iwconfig / batch-process-rclone.sh
Created October 7, 2025 10:47
run rclone copy/sync/whatever in batches of ≤ N files
# batches of 200 with a ~5-180 seconds delay
# the `cat "{}" >/dev/null &` pre‑caches the vfs, reducing telegram io load and speeding rclone.
find /some/dir -type f -printf '%P\n' -exec sh -xc 'cat "{}" >/dev/null &' \; |
xargs -n200 -d '\n' bash -c '
printf "%s\n" "$@" |
rclone -v sync --check-first --transfers 4 -PM --files-from - \
/some/dir/ some-remote:some/remote/dir/ --error-on-no-transfer &&
{ s=$((RANDOM % 176 + 5)).$RANDOM; echo sleeping $s seconds; sleep $s; }
' _
@iwconfig
iwconfig / asdf.sh
Last active June 22, 2025 13:38
executes a set of commands in sequence and each output can be wrapped in html <details> code. useful for reproducing stuff in GH issues. WIP: will perhaps make it usable for anything thus not hardcode stuff
#!/usr/bin/env bash
# reproduce commands and wrap output in spoilers
set -eu
export LC_ALL=C
# defaults:
FILE=test.txt
DIR=/tmp
REMOTE=teldrive-testbench:
@iwconfig
iwconfig / no-subscription-nag.sh
Created May 6, 2025 20:52
This removes the no-subscription reminder in Proxmox VE/BS, adapted from the helper-script. I ended up not needing it, so I'm dumping it here.
#!/bin/bash
echo "Supporting the software's development team is essential."
echo "Check their official website's Support Subscriptions for pricing."
echo "Without their dedicated work, we wouldn't have this exceptional software."
if ! dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; then
sed -i '/data\.status.*{/{s/\!//;s/active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
echo "Disabled subscription nag. Please reload your browser cache."
fi
@iwconfig
iwconfig / pipx-bin.py
Created April 30, 2025 21:15
Modified `pipx` executable for use within a Flatpak environment, setting up necessary environment variables to isolate `pipx` from the host system. Replace the content of `pipx` with `pipx-bin.py`.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
import os
import sys
if __name__ == '__main__':
BASE_DIR = f'{os.environ['HOME']}/.var/app/com.vscodium.codium-insiders'
os.environ['PIPX_HOME'] = f'{BASE_DIR}/data/pipx'
@iwconfig
iwconfig / paste-to-file.py
Created April 18, 2025 20:56
A simple utility for quickly scaffolding files without having to manually create directory structures or files beforehand. It lets you paste text where the very first line (a # comment) specifies the file path. It then writes the rest of the text into that file, automatically creating any necessary directories.
import os
def main():
print("Paste your text (end with an EOF signal: Ctrl-D on Unix/Mac, Ctrl-Z then Enter on Windows):")
try:
# Read multiline text from standard input until EOF
input_text = []
while True:
line = input()
input_text.append(line)
@iwconfig
iwconfig / hashbench.py
Created April 8, 2025 11:59
Compare performance of SHA-256 and BLAKE2 on your CPU. Useful for choosing encryption mode for Borg repositories, for example.
import hashlib
import time
data = b'a' * (10**6) # 1 MB of data
# Benchmark SHA-256
start = time.time()
for _ in range(1000):
hashlib.sha256(data).hexdigest()
print("SHA-256 time:", time.time() - start)
@iwconfig
iwconfig / telegramBotCreator.js
Created April 4, 2025 13:58
Create telegram bots automatically (from your browser's dev console)
/*
Create telegram bots automatically (from your browser's dev console)
1. Go to https://web.telegram.org/a/
2. Open dev console
3. Copy paste this code
4. Adjust the number of bots and sleep settings to your liking (`addBots` and `sleep`)
5. Execute
6. Collect token, wait and repeat this step
@iwconfig
iwconfig / restic
Created September 10, 2024 14:32
Execute restic repository scripts as sub commands of restic itself. E.g. `restic-foo backup [...]` can be executed as `restic foo backup [...]`. Inspired by https://forum.restic.net/t/recipes-for-managing-repository-environment-variables/1716/2
#!/usr/bin/env bash
## Place this file in /usr/local/bin and make it executable.
## reference: https://forum.restic.net/t/recipes-for-managing-repository-environment-variables/1716/2
REPO_NAME="$1"
REPO_SCRIPT="/usr/local/sbin/restic-$REPO_NAME"
# Check if the corresponding script exists and is executable
if [ -x "$REPO_SCRIPT" ]; then
@iwconfig
iwconfig / textburrito.py
Created August 4, 2024 18:44
Wraps regular text or shell commands by a specific width. Does hard wraps, word wraps and shell wraps. Handles prefixes and suffixes, initial and subsequent. Returns a wrapped string by default.
#!/usr/bin/env python3
import shlex
def wrap(string, width, prefix='', initial_prefix='', subsequent_prefix='', suffix='', initial_suffix='', subsequent_suffix='', word_wrap=False, cmd_wrap=False, join=True, join_with='\n'):
lines = []
if word_wrap or cmd_wrap:
for line in string.strip().splitlines():
line_list = []
line_length = 0
for word in shlex.split(line, posix=False) if cmd_wrap else line.split():
@iwconfig
iwconfig / proxmox-config-parser.py
Created August 3, 2024 19:53
Parser for Proxmox .conf files
#!/usr/bin/env python3
import configparser
import json
from pprint import pp
def parse_proxmox_config(file_path):
parser = configparser.ConfigParser(allow_no_value=True, delimiters=':')
with open(file_path, 'r') as file:
content = file.read()