Notes about Computers, Computing, Computations, Etc.

Critical Software for Good Computing

  1. AltDrag lets Windows 10 have Linux-style “hold down a key and click to move a window” support. 1.48Download
  2. Divvy divides up your screen and lets you move windows to different sections with keyboard shortcuts. Download

Stable Diffusion

Programming

Cache Clean-up

Video Stuff

Change video container from Matroska (mkv) to mp4 (assuming the video codec is supported by mp4):

ffmpeg -i name_of_input_file.mkv -codec copy output_file.mp4
# If there's issues with the audio codec:
ffmpeg -i name_of_input_file.mkv -c:v copy -c:a aac output_file.mp4

Download a Youtube playlist, keeping only the audio in AAC (.m4a) format:

yt-dlp -f 140 -o "%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s" "https://www.youtube.com/playlist?list=PLaro_mvk6VEkTqkmTcUIvr4MnUzfh434-"

Download a Youtube video in a h264 video and AAC audio:

yt-dlp -f 22+140 https://www.youtube.com/watch?v=cnDJa_HZVP0

Photo / Image Stuff

To fix photo dates when people email you photos and you need to import them into your photo manager and your photo manager shows all the photos as taken today even though you know they were taken weeks ago but people are so bad at sending photos….

# Inspect the original timestamp
exiftool -r -DateTimeOriginal path_to_picture_folder
# Inspect the modification timestamp
exiftool -r -FileModifyDate path_to_picture_folder
# If FileModifyDate doesn't match what you need, you can set it to the original timestamp
# Note: The double quotes are important so that the shell doesn't think you're redirecting I/O from a file.
exiftool -r "-FileModifyDate<DateTimeOriginal" path_to_picture_folder

Tiling a Small Image into a Bigger One

Windows lock screen backgrounds don't support tiling so I use ImageMagick to create a large image made of my tiles:

convert -size 2560x1080 tile:image_to_tile.png tiled_img.jpg

Windows

Linux

nVidia Drivers

sudo apt install ubuntu-drivers-common
sudo ubuntu-drivers list --gpgpu
sudo ubuntu-drivers install --gpgpu

Blocking Certain Applications from Network

Condensed from this ServerFault post:

# Make group for no-net access, add user to group
groupadd no-net
usermod -a -G no-net USERNAME
groups USERNAME
# Rules to allow local network access
iptables -A OUTPUT -m owner --gid-owner no-net -d 192.168.1.0/24 -j ACCEPT
iptables -A OUTPUT -m owner --gid-owner no-net -d 127.0.0.0/8 -j ACCEPT
# Rule to block other network access
iptables -A OUTPUT -m owner --gid-owner no-net -j DROP
# Rule to block outbound IPv6
ip6tables -A OUTPUT -m owner --gid-owner no-net -j DROP
# Create a script called ''no-net'' containing the following two lines:
#!/bin/bash
sg no-net "$@"

Add GUI to Ubuntu 22.04 Server

There are a couple ways to install Xfce, I prefer the first option:

  1. apt install xubuntu-core - perfect; includes whisker-menu for a good application launcher.
  2. apt install –no-install-recommends xubuntu-core - boots to GUI, very barebones (not even xfce4-terminal).
  3. apt install xfce4 - gives basic installation, still boots to console, so start GUI with startx.

Don't bother with apt install xfce4 –no-install-recommends because apparently installing xorg is just a recommendation, so startx/startxfce will fail :D

Some Standard Configs for Ubuntu Server 22.04

# Get rid of cloud init
apt purge -y cloud-init
# Disable IPv6 in the kernel by modifying the CMDLINE options in /etc/default/grub:
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"
GRUB_CMDLINE_LINUX="ipv6.disable=1"
update-grub
# Edit /etc/default/keyboard to include:
XKBOPTIONS="ctrl:nocaps"

Enable Newer Kernel on Ubuntu Server 22.04

sudo apt install linux-generic-hwe-22.04

Synology ABB on a Linux

Looking Good

Settings for a good-looking Xfce4 installation:

  • Style: Greybird
  • Icons: Elementary Xfce dark
  • Window Theme: Arc-dark

On Debian these are installed with: sudo apt install greybird-gtk-theme elementary-xfce-icon-theme arc-theme

Setting up Django / PostgreSQL / Nginx on Ubuntu 20.04

Here are some extensive notes on setting this up. I also have a version for CentOS 8 (RIP) but don't maintain/update it.

Setting up Kanboard on Ubuntu 20.04

Writing a Systemd Service file

Sometimes you have to make a program start automatically at boot. Here's how I do it with systemd.

Disable Automounting for Xfce

This came up because I was messing with partition layouts for a project and Xfce kept automatically mounting the drives while I was working on them.

# Don't automount drives
xfconf-query -c thunar-volman -p /automount-drives/enabled -s false
# Don't automount media (CDs?)
xfconf-query -c thunar-volman -p /automount-media/enabled -s false

Backup and Restore a Raspberry Pi

# backup
dd bs=4M if=/dev/mmcblk0 | gzip > /mnt/recovery-usb/backupbot-20210715.img.gz
# restore
gunzip --stdout backupbot-20210715.img.gz | sudo dd bs=4M of=/dev/{whatever the device is}

Postgresql basic commands

Add a user: createuser someusername -P

Create a database: CREATE DATABASE somedb OWNER someusername TEMPLATE template0 ENCODING 'UTF8';

GRANT CREATE ON SCHEMA public TO username;

Postgresql - Upgrade 11 to 13

/usr/share/doc/postgresql-common/README.md

Text and File Manipulation

Add a newline to the start of a file

# In particular, an LRC lyric file.
sed '1 s/^/\n/' */*.lrc -i

Or realize you made a mistake and don't want newlines at the start of every file.

sed -z -i 's/^\n//' */*.lrc

Find file names with non-ASCII characters

LC_ALL=C find . -name '*[! -~]*'

Find lyric files with a BOM

From https://www.yiiframework.com/wiki/570/remove-byte-order-mark-bom-from-files-recursively

# Make a list of the files
grep -rl $'\xEF\xBB\xBF' .  | grep .lrc > file_with_boms.txt
# Remove the BOM
while read l; do sed -i '1 s/^\xef\xbb\xbf//'  "$l"; done < file_with_boms.txt

User Tools