pages/ Mineral Existence


Inspired by the grimoire of Fred Bednarski, this is my place to put assorted snippets of code (which may or may not be cursed, so use at your own risk). Have fun, poke around, but remember that this information may be totally borked.

To change the extensions of audio files in a directory:

for file in *.m4a; do ffmpeg -i "${file}" "${file/%m4a/ogg}" && rm $file; done

To download the mp3 audio (or the best audio if that fails) of a youtube video:

youtube-dl --add-metadata -i -x -f mp3/bestaudio "video_link"

To download a playlist of music from youtube (more stable for playlists than youtube-dl):

youtube-dlc -o '%(playlist_index)s - %(title)s.%(ext)s' -x -f mp3/bestaudio "[playlist url]"

To forward your port 8388 to a server's port 8384 (can be used to get the web interface for syncthing remotely):

ssh -L username@yourserver

To sanitize a file name (the .opus can be any extension):

mv "$file" "$(echo "${file%.opus}" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g").opus"

To push file changes over ssh:

rsync -azP --delete ~/Folder/ user@123.456.8.910:/home/name/Folder

To dither and shrink an image (courtesy of Thomasorus with some modification for personal preference):

mogrify -format gif -filter Triangle -define filter:support=2 -thumbnail $size -monochrome -unsharp 0.25x0.08+8.3+0.045 -dither FloydSteinberg -colors 2 -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace gray -normalize $from

To simply dither of an image:

convert image.png -colorspace gray -ordered-dither o8x8 image_dithered.png

Super simple, but to make a div element take up the whole height of a veiwport

height: 100vh;

This is something pretty specific (and simple), but this is how I fixed my audio continuously muting in Manjaro i3:

alsactl restore

To play a streaming file

mplayer -prefer-ipv4 -playlist kexp128.mp3.m3u

Grab some html from the Noita wiki

curl "" | awk '/table class="spell"/ {for(i=1; i<=69; i++) {getline; print}}'

Find all files which match a given regex

grep -rnw 'dir/' -e 'pattern'