Skip to content

Instantly share code, notes, and snippets.

@ptrcnull
Last active June 14, 2023 21:26
Show Gist options
  • Save ptrcnull/e54d8a9fd4b7e39595741daa338ffcd0 to your computer and use it in GitHub Desktop.
Save ptrcnull/e54d8a9fd4b7e39595741daa338ffcd0 to your computer and use it in GitHub Desktop.
random code/shell snippets

running a qemu vm with display and network

qemu-system-x86_64 -cpu host -accel kvm -m 16G -smp 8 -bios /usr/share/OVMF/OVMF.fd -drive format=raw,file=/dev/sda -net nic,model=e1000 -net user -usbdevice tablet -vga qxl -vnc :0

generate boarding pass aztec from scanned pdf417

wl-paste -t image/png | ZXingReader /dev/stdin -bytes | xargs -I{} ZXingWriter -size 800x800 AZTEC {} meow.png

creating mapped entries for every twemoji svg

curl https://raw.githubusercontent.com/muan/unicode-emoji-json/main/data-by-emoji.json | np 'stdin().map(Object.entries).map(x => ["assets/svg/" + x[0].codePointAt(0).toString(16) + ".svg", "named/" + x[1].slug + ".svg"]).filter(([name, slug]) => fs.existsSync(name)).forEach(([name, slug]) => fs.linkSync(name, slug))'

pulse/pipewire stuffs

pactl load-module module-native-protocol-tcp listen=0.0.0.0
pactl load-module module-zeroconf-publish
...
pactl unload-module module-native-protocol-tcp

parallel

ls | grep -v .py | parallel python3 optimize.py {} | sort
find . -name 'APKBUILD' | rg -v unmaintained | parallel -j50 test-aport-fetch {}
find . -name 'py3-*.apk' | parallel tar tvf {} '|' rg site-packages '|' rg -F 0.0.0

sysctls

sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1

smb client

doas smbclient -L //10.0.100.52/
doas smbclient //10.0.100.52/Confidential

disable cores

for core in {2..15}; do echo 0 | doas tee /sys/devices/system/cpu/cpu$core/online; done

android db

adb install-multiple -i "com.android.vending" *.apk

socat

socat -v OPENSSL-LISTEN:9990,verify=0,cert=./test.internal.pem,key=./test.internal-key.pem,fork tcp:127.0.0.1:1234

sort packages by installed side

< /lib/apk/db/installed | np 'apkindex().sort((a, b) => a.I - b.I).reverse().slice(0, 50).map(x => ([ x.P, x.I ]))'

print maintainers with trailing space

zcat /var/lib/mirror/edge/testing/x86_64/APKINDEX.tar.gz | np 'new Set(apkindex().map(pkg => pkg.m)).map(Array.from).filter(name => name?.endsWith(" "))'

remove six

apkgquery 'any(pkg.Depends, {.Pkgname == "py3-six"})' | wrl {( cd $(apkbuild-path $line); abuild fetch unpack; rga -e 'import six' -e 'from six import' src; echo "=== ^ $line ^ ==="; restdin cat )}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment