Skip to content

Instantly share code, notes, and snippets.

@acidDrain
acidDrain / edit-subtitles.sh
Created November 14, 2020 00:27
Example of how to edit subtitles in a video / media file
#!/bin/sh
# the below command exports only the subtitles/text from the mkv video to a plain-text srt file
ffmpeg -i video.mkv -an -vn -map 0:2 -c:s:0 srt sub.srt
# this command replaces any text in the subtitles matching "some text to change" with "new text"
sed -E 's/(some text to change)/new text/g' -i sub.srt
# this command mixes the subtitles back in with the video and audio into a new media file
ffmpeg -i video.mkv -i sub.srt -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s copy video-new-subtitles.mkv
@acidDrain
acidDrain / mp4-to-gif.sh
Last active November 13, 2020 21:15
Use ffmpeg to convert mp4 to an animated gif
#!/bin/sh
DEBUG="${DEBUG:-}"
if [ -n "$DEBUG" ]; then
set -x
fi
# This script uses ffmpeg to convert an mp4 to a gif
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>Matrix</title>
<link
rel="shortcut icon"
type="image/ico"
href="data:image/x-icon;base64,xxx"
@acidDrain
acidDrain / continuations.js
Last active December 18, 2021 21:34
Example of the continuation-passing style of programming
const square = x => x*x;
const squareCallback = (x, callback) => callback(x*x);
const squareCurry = (x) => callback => callback(x*x);
const squarePromise = (x) => ({ then: resolve => resolve(x*x) })
const toContinuation = (v) => (callback => callback(v));
@acidDrain
acidDrain / termguicolors.sh
Created September 30, 2020 08:17
Check your terminal emulator's support for true colors
#!/usr/bin/env bash
#------------------------------------------------------------------------------#
# Execute with source termguicolors.sh && truecolor #
#------------------------------------------------------------------------------#
DEBUG="${DEBUG:-}"
if [[ -n $DEBUG ]]; then
set -x
@acidDrain
acidDrain / Linux-Disk-Utilities.md
Last active April 8, 2021 04:19
Quick and dirty list of Linux disk utilities and output samples

Linux Disk Utilities

lsblk

$ lsblk
NAME                      MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
nvme0n1                   259:0    0 953.9G  0 disk
├─nvme0n1p1               259:1    0   512M  0 part  /boot/efi
├─nvme0n1p2               259:2    0   244M  0 part  /boot
@acidDrain
acidDrain / install-docker-debian.sh
Last active September 15, 2020 09:10
Script to install docker and docker-compose on debian for x86_64 and aarch64/arm64 architectures
#!/usr/bin/env bash
set -Eeuo pipefail
PLATFORM_ARCH="$(uname -m)"
PLATFORM_ARCH_APT=
if [[ $PLATFORM_ARCH = "aarch64" ]]; then
PLATFORM_ARCH_APT="arm64"
elif [[ $PLATFORM_ARCH = "x86_64" ]]; then
@acidDrain
acidDrain / locale-fixes.md
Last active September 15, 2020 08:27
Fix for typical/common locale errors/issues

Locale Setup/Quick Fixes

It doesn't hurt to first install the following dependencies (not sure which are optional/required):

  • libencode-locale-perl
  • liblocale-gettext-perl
  • locales
  • python-apt-common
  • util-linux-locales
@acidDrain
acidDrain / base.css
Last active October 20, 2021 22:06
CSS Resets/Base
html {
box-sizing: border-box;
max-width: 70ch;
padding: 3em 1em;
margin: auto;
line-height: 1.75;
font-size: 1.25rem;
}
*,
@acidDrain
acidDrain / iperf-comments.md
Last active April 9, 2021 01:47
iperf info

iPerf Testing

Without diagnostic information like CPU % utilization or load average, memory/swap usage, packets per second, etc., I can only shoot from the hip.

  • My first guess would be disk I/O. What's CPU %wa look like? I have gigabit fiber at home and when I'm downloading large files they start off strong at 98-101 MBps before dropping down to ~70 MBps because of disk write speed - high disk %wa is always the indicator. (P.S. b4 a pedantic commenter,I'm saying mega bytes per second, not mega bits per second). You can run some performance and tuning tests with iperf. Check out this part of the iperf documentation on Tuning TCP.

For example, here's a test on my local network