LOST TECHNOLOGY

Cheat sheet for things I do, but always forget how to do:

Do not use these yourself. There is a good chance the syntax is all fucked up because I don't know what I'm doing.

This site uses the Google's JavaScript spying thingy for stats. You should probably block https://www.googletagmanager.com and disable JavaScript on lost.technology if you care about that. It won't break nothin' on your end.

Updated 2024-05-28.

Audio

Replay Gain:
$ mp3gain -a -k *mp3
$ loudgain -a -k *
$ metaflac --add-replay-gain *.flac
recursively: $ find ./* -name "*.flac" -exec metaflac --add-replay-gain {} \;

BASH

Sort directories by size or number of files:
$ du --human-readable | sort --human-numeric-sort -r | head
$ du -h --max-depth=1 | sort -rh
$ find ./ -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n

Resume stopped jobs (accidentally CTRL Z in BASH) use fg to return to foreground

Rename extensions:
$ rename .htm .html *.htm (check man page)

Rename extensions recursively:
$ find ./ -type f -exec rename 's/\.old/\.new/' '{}' \;

Add reminder to script:

#!/bin/bash
#set -v
read -p "Did you mount BM1 yet? " -n 1 -r
echo    # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
rsync -aP --delete ~/hikarisym/audio/ ~/bm1/audio-backup/
fi

Locale/unicode fix: Add to .bashrc
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

Make changes active:
$ source ~/.bashrc

Start shit automatically: Create script. Add su - username -c "/path/to/script" to /etc/rc.local

screen flow control: CTRL a then f (e.g., to pass CTRL s to the running program—CTRL q to resume from accidental CTRL s)

Generate example.com/001 to example.com/010 sequence
$ seq -f "example.com/%03g" 10

Subtitle extraction from MKV
$ for f in *.mkv; do ffmpeg -i "$f" -c:s copy "${f%.mkv}.ass"; done

yt-dlp w/ login
$ /usr/bin/yt-dlp --cookies-from-browser chrome URL

Browsing

Chromium stops playing MP4 and WEBM videos on the YouTube: Disable hardware acceleration (Nvidia, Leap 15/15.1).
[Update: Damn it, I forgot I already figured this out previously, and had to figure it out anew.]

Unfuck Google: Make https://www.google.com/search?q=%s&pws=0&gl=us&gws_rd=cr the default search engine.
Make https://www.google.com/search?tbs=li:1&q=%s&pws=0&gl=us&gws_rd=cr the default search engine. (This removes country-specific redirection and uses Verbatim mode instead of "ignore your quotation marks, because fuck you" mode.)

2024 attempt at above: https://www.google.com/search?tbs=li:1&q=%s&pws=0&gl=us&gws_rd=cr (this is what happens when I forget I already found a solution and end up re-creating it)

WGET -c continue -e execute -r recursive -l levels -nd no directories -A accept list of file types -H span hosts -i file instead of URL
$ wget -c -e robots=off -r -l 1 -nd -A jpeg,jpg,png,PNG,JPG,JPEG -H URL (extensions are probably not case sensitive)

Checksums

$ cfv -C -t sfv * [-t sfv is the default; cfv by itself will check files if a .sfv etc. is present]
$ md5sum filename > md5.txt then md5sum -c md5.txt to check
$ echo -n string | md5sum
(Recursively) $ find -type f \( -not -name "md5sum.txt" \) -exec md5sum '{}' \; > md5sum.txt

Encryption

# cryptsetup luksDump /dev/sda5
(confirm key slot 0)
# cryptsetup luksAddKey /dev/sda5 -S 1
(add passphrase to key slot 1, etc.)

Mounting noauto luks with entries in crypttab and fstab for /mnt/point
# systemctl start mnt-point.mount

GPG (key expired, extend/renew expiration date
$ gpg --list-keys
$ gpg --edit-key [UID]
> expire
> key 1 (etc.)
> save

Encoding

$ echo "ROT-13 text" | tr '[A-Za-z]' '[N-ZA-Mn-za-m]'

Files

$ fdupes -Srd
Specifiy directory with above; will prompt; make selections; use DEL key to delete duplicates.

Games

Anbernic RG35XX

Garlic OS (fresh install)

Exit game: Double-press Menu. Resume with A; new game with Start.

Retroarch: Menu X

Batocera

Aspect ratio unfucking: Set to Core Provided.

MAME

dip switch menu = tab

Images

$ mogrify -strip

Rotate:
[rotate 270-degrees counterclockwise] $convert input.jpg -rotate -270 output.jpg

Crop:
$ mogrify -crop 640x620+0+0 file.png
(produces 640x620 image with an offset of 0+0)
$ convert image.png -gravity South -chop 0x20 result.png
(removes 20 pixels from bottom; use North, etc.)
$ convert image.png -crop 640x620+0+0 cropped.png
(produces 640x620 image with an offset of 0+0)

GIF:
$ convert -delay 128 -loop 0 sequence*.png output.gif
add delay example: $ convert -delay 86 sequentialfiles* -delay 256 separate.png -loop 0 delaybeforeloop.gif
$ ffmpeg -i source.mp4 -pix_fmt rgb24 output.gif
(Resize by adding -vf "scale=iw/2:ih/2" to halve width and height, for example.)
$ ffmpeg -framerate 8 -pattern_type glob -i '*.png' -c:v libx264 -pix_fmt yuv420p output.mp4
$ convert -delay 8 -loop 0 *png output.gif

Webp, lossless:
$ convert input.png -define webp:lossless=true output.webp

Slideshow:
$ feh -FZzrxD8 ./
(F fullscreen, Z zoom, z random, r recursive, x borderless, D delay 8 seconds) V verbose, d show path and filename
$ feh -ZzrdD8 --scale-down --action1 'echo %F | xclip -i'
(Not fullscreen. Press 1 to copy path to image.)
--info 'echo %wx%h' to display resolution

$ feh -FZzrxVdD8 --info 'echo %wx%h' --scale-down --action1 'echo %F | xclip -i' ./

iPad

Install libimobiledevice-utils and ifuse
$ idevicepair pair
$ usbmuxd -f -v
$ ifuse [desired mount point]
$ fusermount -u [mount point]

irssi

CTRL A ? for help
CTRL A CTRL V for entering digraphs.

KDE

Lock screen clock:
Edit: /usr/share/plasma/look-and-feel/org.kde.breeze.desktop/contents/components/Clock.qml
text: Qt.formatTime(timeSource.data["Local"]["DateTime"]) //12 hrs
to
text: Qt.formatTime(timeSource.data["Local"]["DateTime"], "hh:mm") // 24 hrs change hh:mm to hh:mm:ss to add seconds to the clock

Metadata

$ exiftool [file]

$ webpinfo [file]

Microsoft Office

Force Word to paste plain text: File | Options | Advanced | Cut, copy, and paste | change defaults, but leave "Show Paste Options button when content is pasted" box checked or it won't work, because fuck you, that's why.

Monitors

KDE hates me (multi-monitor bugs) -- Delete folder ~/.local/share/kscreen/
Use xrandr, put display layout script in ~/.xinitrc

glxgears runs at 1FPS on monitors attached to second video card, synchronized to vertical refresh.

Old laptop with 2x HD as headless "server." Grub does not like LVM, but RAID 1 without LVM okay. Blank screen with laptop-mode-tools.

Networking

DD-WRT web thingy dies: telnet in and httpd -h /www

sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 user@location:/directory-to-mount/ /local/mountpoint/

Raspberry Pi DHCP Client Daemon failes to start after upgrading to Bullseye:
Change /etc/systemd/system/dhcpcd.service.d/wait.conf lines:
FROM:
[Service]
ExecStart=
ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -w
TO:
[Service]
ExecStart
ExecStart=/usr/sbin/dhcpcd -q -w

NFS

Stop NFS Services
# service portmap stop
# service nfs-kernel-server stop
# apt --purge remove nfs-kernel-server nfs-common portmap

Powkiddy RGB30

Press X to add game to favorites
(If you Google it, it says to press Y, but it's the top button, in any case.)

PDFs

$ pdftk allthesefiles* cat output name-of-new.pdf

$ qpdf --decrypt source.pdf destination.pdf

RAID and LVM

# mdadm --assemble --scan
# lvdisplay
# vgchange -a y [VG Name]
$ lsblk -f

Stop check
# echo idle > /sys/devices/virtual/block/md0/md/sync_action

Make RAID1 and LVM more bigger

(This is from memory, so you should really verify this first.)

  1. Fail drive to replace
  2. Remove drive to replace
  3. Replace drive to replace (hey, you marked these ahead of time so you know which is which, right?)
  4. Partition new drive
  5. Add new drive (maybe lable the drives too)
  6. Check rebuild progress with mdstat
  7. Repeat with other drive
  8. Make PV bigger
  9. Make VG bigger
  10. Make LV bigger
  11. Make file system bigger

Raspberry Pi

Problem: Black screen with mouse cursor.
Solution: Remove ~/.config/lxsession/LXDE-pi/autostart (or update to include contents of /etc/xdg/.../autostart copy)
https://forums.raspberrypi.com/viewtopic.php?t=215757

rsync

Directories only; no files
$ rsync -a -f"-! */" source/ destination/
or rsync -a -f"+ */" -f"- *" source/ destination/
or rsync -a --include='*/' --exclude='*' source/ destination/
Note: These omit symlinks.

Video

NOTE: Sometimes better to put -ss after -i

Subtitle extraction from MKV
$ for f in *.mkv; do ffmpeg -i "$f" -c:s copy "${f%.mkv}.ass"; done

$ ffmpeg -ss 00:00:30 -i orginalfile -t 00:00:05 -vcodec copy -acodec copy newfile

ffmpeg excerpt by frames:
$ ffmpeg -ss 00:00.0 -i source.mkv -frames:v [number of frames] -vcodec copy -an output.mp4

Crop bottom:
$ ffmpeg -i input.mov -filter:v "crop=1920:1024:0:0" output.mov

With 180-degree flip:
$ ffmpeg -ss 00:00:30 -i orginalfile -t 00:00:05 -vcodec copy -acodec copy -metadata:s:v:0 rotate=180 newfile

Use ffmpeg to join videos, concatenate with text file in same directory.
cat.txt example:
file nameoffile01.mov
file nameoffile02.mov
$ ffmpeg -f concat -safe 0 -i cat.txt -c copy outputfile.mov

Convert to hardsubs:
$ ffmpeg -i video.mkv -vf subtitles=video.mkv out.avi
(This can fail if the original subtitle track doesn't have a file name; fix that or...)

mkvinfo file to identify track, then
$ mkvextract tracks file.mkv tracks 2:outputsubfile.ssa (for example)
then use that instead.
(I haven't figured out how to unfuck the timing yet for clips without hardsubbing first before clipping.)
(Probably best to clip with -c:s copy output.mkv before re-encoding to hardsub mp4 or avi.)

𝕏-Twitter compatibility
$ ffmpeg -i input.avi -c:v h264 -c:a aac output.mp4
$ ffmpeg -ss 00:00:00.0 -i input.mkv -t 00:00:06.9 -c:v h264 -c:a aac output.mp4
[Note: may need to specify (after video codec) -pix_fmt yuv420p if yuv (48000hz audio probably okay, otherwise specify -ar 44100 if 48000hz)
[Note: may need to specify -ac 2 if the Twitter rejects non-stereo audio]
ffmpeg -ss 00:00:00.0 -t 00:00:06.9 -i input.mkv -c:v h264 -pix_fmt yuv420p -c:a aac -ar 44100 -ac 2 output.mp4
Use -an to remove audio.
Add -map 0:v:0 -map 0:a:1 to select audio track 2

$ mpv --reset-on-next-file=all #to unfuck settings
Alt: Open two copies of the video at the same time.

Subtitle position: r, R

Subtitle delay: z, Z

Subtitle, external: mpv --sub-file=subs.ass video.mkv

# Switched back to vo=gpu but changed hwdec= from auto to vdpau-copy (not vdpau) and seems to be best combo; glitch gone, and warning message gone. As of 2021-09-03, suggest vo=gpu with hwdec=vdpau-copy for this AMD GPU.

config
screenshot-template=~/Pictures/temp/%F_%p_%04n
screenshot-format=webp
screenshot-webp-lossless=yes

input.conf
g sub_step -1
y sub_step +1
s no-osd screenshot video
S screenshot subtitles

$ mpv --slang=enUS https://www.crunchyroll.com/URL
// youtube-dl bug prevents passing login credentials, so only works with free videos
// add slang=enUS to ~/.mpv/config

$ streamlink https://www.crunchyroll.com/URL best
// Save config in ~/.config/streamlink/config

$ youtube-dl --all-subs

$ youtube-dl --write-auto-sub --sub-lang en --skip-download

youtube-dl file name too long:
$ youtube-dl -o "%(id)s.%(ext)s" URL

youtube-dl not picking 4K:
$ youtube-dl -f 'bestvideo[height=2160]+bestaudio' URL

yt-dlp audio only:
$ yt-dlp -x URL

Video test 1:
testvideo.mp4
h264, 1920x1080, 30.000fps
aac, 2ch, 48000Hz

Video test 2:
NASA cat video (YouTube)

Unicode

Linux:
CTRL SHIFT U
2014 — for emdash
2661 ♡

Windows

Search for foo bar exactly:
content:~"*foo bar*"

Install Windows 11 without Microsoft account:
When it asks for Internet, SHIFT F10 for command prompt.
C:\Windows\System32>OOBE\BYPASSNRO
The computer will restart, but offer an "I don't have Internet" option this time.
Continue installation with local account creation.
[NOTE: This works as of 2023-05-20, but may change. The way to go about it has changed before.]

/files/swapcaps.reg
SHA256: e55f02dc0005defdf18f71756293b1816d8b86be9cdc4faca9756823a02eaaea

WordPress

Lightbox. Add rel="lightbox" to URLs.

Other

ispell also install liblingua-ispell-perl

QR code