This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import json | |
| def bdecode(bencoded_bytes): | |
| def decode_int(b, i): | |
| j = b.find(b'e', i) | |
| return int(b[i:j]), j + 1 | |
| def decode_bytes(b, i): | |
| colon = b.find(b':', i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # ============================================================================== | |
| # Pure Bash Bencode to JSON Converter | |
| # ============================================================================== | |
| # Usage: curl ... | bash bdecode.sh | |
| # Dependencies: od, tr, sed (Standard POSIX tools) | |
| # ============================================================================== | |
| set -e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # Minimal pure-Python inotify example (no external packages) | |
| import ctypes | |
| import ctypes.util | |
| import os | |
| import struct | |
| import sys | |
| import errno | |
| import selectors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ncat -lk -p 8000 --sh-exec ' | |
| { | |
| read request | |
| url_path=$(echo "$request" | awk "{print \$2}" | sed "s|//\+|/|g") | |
| current_path=${url_path%/} | |
| echo $current_path > /dev/stderr | |
| html=$(tree "$url_path" -H .) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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; } | |
| ' _ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
NewerOlder