c.bauherren.ovhLiterally today in the office: colleague walks by, stares at my screen while I'm browsing the xlib manual, utters "that looks dangerous" and walks off. The end is nigh, brethren. High contrasts, information density and lack of corporate art scares the soydev.

Computer Stuff, guide h

lot's to do, sorry for the mess unix join() cmp()

utils

basename

echo "/path/to/file1 /another/path/file2" | xargs -n1 basename

chown

chown -R dawn:wheel .

Changes user and group owenership

mv

Move files from a directory into current directory

mv directory/* .

tree

Generate sitemap

tree -H ./ > sitemap.html

tree displays the directory structure of the current directory. -d option displays only directories. -I option allows to exclude directories that match specific pattern e.g.

tree -I node_modules

In order to exclude multiple directories at once, their names must be separated by | sign, i.e.

tree -I 'node_modules|cache|test_*'

This command will skip node_modules, cache directories (along with their content) from the output, and all directories that match test_* wildcard expression.

sed

Removing all instances of the "<" sign

sed -i 's/>//g' yourfile.md

Change all instances of a string

sed -i 's/webp/avif/g' filename

Creates backup

sed -i.bak 's/webp/avif/g' filename

Remove the pattern "../"

sed -i 's/\.\.\///g' filename.html

Misc

sed -i 's/\<str\>/gif/g' filename.html

s/<str>/gif/g: Substitute (s) str with gif, where < and > ensure that only the exact word str is replaced, not occurrences where str is a part of another word.

@

Loop

for file in *.md; do sed -i 's|\.pix/||g' "$file"; done

removes every instance of .pix/

sed 's/="./="/' filename

sed 's/.md//g' filename

ghostscript

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -r300 -sOutputFile=output-PERCENTSIGNd.png input.pdf

git

Create new repository

git init

git add .

git commit -m "Commit Message"

git branch -M main

git remote add origin git@github.com:username/repo-name.git

git push -u origin main

Generate new SSH key

ssh-keygen -t ed25519 -C "your_email@example.com"

If you are using a legacy system that doesn't support the Ed25519 algorithm, use:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

imagemagick

todo

convert -background none -fill black -pointsize 48 label:"c@avsbq.org·" -virtual-pixel none -distort Arc 360 avsemail.pn

Remove Whitespace

convert -trim

Flip images

To flip horizontally

convert input.jpg -flip output.jpg

To flip vertically

convert input.jpg -flop output.jpg

Dithering

convert tux.webp -resize 384 -dither FloydSteinberg -remap pattern:gray50 tux.webp

Ordered

convert invader.webp -colorspace gray -ordered-dither o8x8 invader2.webp

Rotate

Anti-clockwise

convert dumbbell.jpg -rotate -90 dumbbell1.jpg

Clockwise

Same command as before but! omit the - before 90

Add spiral to image

convert -background none -fill black -pointsize 48 label:"you@email.com" -virtual-pixel none -distort Arc 360 output.png

ffmpeg

For delay

ffmpeg -i a.mp4 -itsoffset 2 -i a.m4a -c:v copy -c:a aac -strict experimental b.mp4

Combine video and audio

ffmpeg -i a.mp4 -i a.m4a -c:v copy -c:a aac -strict experimental b.mp4

converting videos

ffmpeg -i a.mkv -codec copy a.mp4

SSHFS

From local machine

sudo sshfs root@avsbq.org:/var/www/werc/sites/ /mnt/avsbq.org

to debug use

-o debug

Remove offending key

ssh-keygen -R avsbq.org

mpv

mpv -vf=hflip /dev/video0