Today I Learned
Quick and dirty how-tos I learned recently. Collecting so I don't forget, though very likely these will get outdated as time passes on and they're probably things LLMs already know about anyway.
- Telnet with curl
- LLM search for open source projects
- Allow 3rd party binaries on Mac OS
- Incremental backups with rsync
- Virtual monitors with xrandr
- How to archive data to Blu-Ray M-Disc
- Disable wifi power management
- FreeBSD writable live USB
- X11 clipboard synchronization
Telnet with curl
curl telnet://example.com:80
This is a thing.
LLM search for open source projects
I learned about DeepWiki recently.
It can be used to explore and ask questions about popular open source projects.
Allow 3rd party binaries on Mac OS
When running 3rd party unsigned binaries on Mac, you will be welcomed with a dialog letting you know that you cannot run this app because it's not verified. This requires the user going to System Settings > Privacy & Security and manually allowing the app.
It's ok for a single app, but problematic for cases where you have lots of binaries/libraries. It seems that any newly downloaded binaries are added to quarantine by macOS, which triggers Gatekeeper. A workaround is to remove the quarantine attribute from the files you downloaded:
$ xattr -d com.apple.quarantine *
Incremental backups with rsync
Inspired by https://linuxconfig.org/how-to-create-incremental-backups-using-rsync-on-linux
This script will create incremental backups using rsync. This is achieved by using hard links support of the filesystem.
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
readonly SOURCE_DIR="/home/vptr"
readonly BACKUP_DIR="/mnt/backup/vptr"
readonly DATETIME="$(date '+%Y-%m-%d_%H:%M:%S')"
readonly BACKUP_PATH="${BACKUP_DIR}/${DATETIME}"
readonly LATEST_LINK="${BACKUP_DIR}/latest"
umount /mnt/backup || true
mount /mnt/backup
mkdir -p "${BACKUP_DIR}"
rsync -av --delete \
"${SOURCE_DIR}/" \
--link-dest "${LATEST_LINK}" \
--exclude=".cache" \
--exclude="*/node_modules/*" \
--exclude="Downloads*" \
"${BACKUP_PATH}"
rm -rf "${LATEST_LINK}"
ln -s "${BACKUP_PATH}" "${LATEST_LINK}"
umount /mnt/backup
Virtual monitors with xrandr
xrandr offers powerful screen management capabilities. You can slice single monitor into several virtual screens. Below script is used to split single 4k screen into 3:
+----+----+
| ~1 | |
+----+ ~3 |
| ~2 | |
+----+----+
Save this to virtmon.sh and use it to toggle between virtual screen and original 4k.
#!/bin/sh
if [ -z "$(xrandr --listactivemonitors | grep 'DisplayPort-2~1')" ]; then
xrandr --setmonitor DisplayPort-2~1 1920/470x1080/264+0+0 DisplayPort-2
xrandr --setmonitor DisplayPort-2~2 1920/470x1080/264+0+1080 none
xrandr --setmonitor DisplayPort-2~3 1920/470x2160/264+1920+0 none
xrandr --fb 3840x2160
else
xrandr --delmonitor DisplayPort-2~1
xrandr --delmonitor DisplayPort-2~2
xrandr --delmonitor DisplayPort-2~3
fi
How to archive data to Blu-Ray M-Disc
Here's how to back-up data to BD M-Disc. This assumes we have a M-Disc compatible rewriter.
-
Create an ISO image of your data directory that you want to burn.
$ genisoimage -f -J -joliet-long -r -allow-lowercase -allow-multidot -o <image.iso> <dir> -
Mount the image with
mount -o image.ios /mnt/cdromto check that all data and files look good. If not careful with genisoimage flags it's possible to get truncated 8.3 formatted filenames. -
Burn the image with
growisofs -speed=1 -Z /dev/sr0=image.iso. Make sure to set the speed to one so that it does not mess up large BD M-Discs. Some people were saying that higher speed options may work but it may incorrectly write data to M-Disc since they like slower writes.
At this point we should have an archived copy of your data.
Burn time estimates of ~20GB iso image:
- Medium: Verbatim BD-R 25GB M-Disc
- Rewriter: LG WH16NS40 16X Super Multi M-Disc Blu-Ray BDXL DVD CD Internal Burner Writer Drive
- Time to burn: ~40 mins with the above speed=1 setting.
Disable wifi power management
Power management might interfere with wifi speeds
# install tools
$ apt install wireless-tools
# turn off power management
$ iwconfig wlan0 power off
After module is installed/updated, you can check whether power saving settings are on or not
$ cat /sys/module/iwlwifi/parameters/power_save
The power still can be limited by iwcl or other devices since after reboot iwconfig shows power management on, but parameters file above shows it off.
Debian wiki has a page on Intel wifi chipsets https://wiki.debian.org/iwlwifi
To improve performance of AX210
#/etc/modprobe.d/iwlwifi.conf
options iwlwifi bt_coex_active=0 swcrypto=1 11n_disable=8
#/etc/modprobe.d/iwlmvm.conf
options iwlmvm power_scheme=1
These settings should fix driver crashes.
FreeBSD writable live USB
FreeBSD installation images come with “Live CD” option. If you choose it, the installation image will boot in live cd mode. This is really useful if you want to explore core system from the command line or do some fixes on already installed system.
If you want to install more applications to have a better test drive you’ll be in trouble because root file system is mounted as read-only. The root file system also takes up 100% of space due to how installation image is setup leaving you no room to add new software.
There’s a very simple workaround that lets you put FreeBSD live cd into writable configuration. Boot up into usb image and enter live cd. Then run these commands:
mount -uw /
touch /firstboot
# edit (vi) /etc/fstab and change ro to rw
sysrc root_rw_mount=YES
sysrc growfs_enable=YES
Reboot the system when you’re done. When you boot it up next time, your root will be writable and will expand to the remaining free size of your USB stick.
X11 clipboard synchronization
Clipboard in Linux was always a PITA as far as I can remember. We have three clipboards to work with in X11: primary, secondary and clipboard. Primary buffer is typically used in terminal apps (e.g. when selecting text with mouse), the purpose of secondary is unclear, and the “clipboard” is used by GUI applications such as you web browser and such.
These clipboards are not automatically synced by default. For example, if you select console text and try to paste it in your browser it won’t work out of the box. You can transfer primary buffer context to clipboard with xclip like so:
$ xclip -o | xclip -selection c
Then it will work. But who wants to do this all the time.
There’s a program called autocutsel that can help you with clipboard sync. You just need to install it and add the following to ~/.xinitrc:
if [ -x /usr/bin/autocutsel ]; then
# keep clipboard in sync with primary buffer
autocutsel -selection CLIPBOARD -fork
# keep primary buffer in sync with clipboard
autocutsel -selection PRIMARY -fork
fi
It will start autocutsel in the background when X starts and keep clipboards in sync.