Skip to content

Instantly share code, notes, and snippets.

@basperheim
basperheim / pg_dump-backup-overview.md
Created June 29, 2024 17:36
Postgres 'pg_dump' overview to backup a database

Postgres 'pg_dump' backup overview

When using pg_dump to back up a PostgreSQL database, here are some important flags and options to consider:

  1. -d, --dbname=NAME: Specifies the name of the database to dump.

  2. -f, --file=FILENAME: Directs the output to the specified file or directory.

  3. -F, --format=c|t|p: Specifies the format of the output file (c for custom, t for tar, p for plain text SQL).

@basperheim
basperheim / compare_files.sh
Created June 29, 2024 16:58
Bash function that compares two files with color-coded printing
compare_files() {
if [ "$#" -ne 2 ]; then
echo "Usage: compare_files <file1> <file2>"
return 1
fi
local file1="$1"
local file2="$2"
if [ ! -f "$file1" ]; then
@basperheim
basperheim / setup-wine-linux-to-play-win-games.md
Created June 27, 2024 18:57
Overview of how to use Wine in Linux to play old 32-bit Windows games

Setup Wine for Linux to play old Windows games

What is the best way to use Wine in Arch Manjaro to run old PC games (from the XP era of Windows, but after DOS, so DOSBOX is NOT an option)?

What are some steps to do this, and pitfalls I should avoid?

Running old PC games on Arch Manjaro using Wine can be a rewarding way to relive some classics from the XP era. Here's a step-by-step guide and some tips to help you get started:

VIM Cheat Sheet

Navigation

  • h: Move cursor left.
  • j: Move cursor down.
  • k: Move cursor up.
  • l: Move cursor right.
  • 0 or ^: Move cursor to the beginning of the line.
  • $: Move cursor to the end of the line.
@basperheim
basperheim / ffmpeg-reduce-mp4-size-good-quality.md
Created March 30, 2024 08:31
Use FFmpeg to reduce an MP4 video file size

Use FFmpeg to reduce an MP4 video file size

To scale down the size of the MP4 file using FFmpeg while maintaining as much quality as possible, you can use the following command:

ffmpeg -i input.mp4 -vf "scale=-2:720" -c:v libx264 -crf 20 -preset slow -c:a copy output.mp4

Explanation of the options used:

Use a custom HTML file in Wails.io

Generate Wails.io project

Create a new Vanilla TS wails.io project with wails init -n myproject -t vanilla-ts.

Add a main.html file in assets

Create a new frontend/src/assets/main.html file:

@basperheim
basperheim / install-virtualbox-arch-linux.md
Created March 8, 2024 07:17
Install VirtualBox on Arch Linux

Install VirtualBox on Arch Linux

Instructions for installing VirtualBox on Arch Linux and selecting the appropriate host modules:

Install the core packages

Install the virtualbox package and choose the appropriate package to provide host modules based on your kernel:

  • For the Linux kernel, install virtualbox-host-modules-arch.
  • For any other kernel (including linux-lts), install virtualbox-host-dkms.
@basperheim
basperheim / extract_audio.py
Created February 24, 2024 13:34
Extract audio from video files using Python and FFmpeg
import os
import subprocess
DRY_RUN = False
# Function to find all video files in the current directory
def find_video_files():
video_files = []
for file in os.listdir('.'):
if file.endswith('.mkv') or file.endswith('.mp4'):
@basperheim
basperheim / reduce_videos.py
Created February 24, 2024 09:02
Use Python & FFmpeg to reduce video sizes
import os
import subprocess
DRY_RUN = False
# Function to find all video files in the current directory
def find_video_files():
video_files = []
for file in os.listdir('.'):
if file.endswith('.mkv') or file.endswith('.mp4'):
@basperheim
basperheim / reduce_mkv_files.py
Last active February 24, 2024 08:03
Reduce size of MKV files in current dir using FFmpeg and Python
import os
import subprocess
DRY_RUN = False
# Function to find all mkv files in the current directory
def find_mkv_files():
mkv_files = []
for file in os.listdir('.'):
if file.endswith('.mkv'):