Skip to content

Instantly share code, notes, and snippets.

@hekmon
hekmon / mkvattachfonts.sh
Created August 6, 2024 12:49
Analyze SubStationAlpha subtitles (ASS) within a MKV file to extract the used font and add them back to the MKV file as attachments
#!/usr/bin/env bash
set -e
FONTSDIR="/fonts/dir/change/me"
attachment_exists() {
local mkv_file="$1"
local attachment_name="$2"
mkvmerge -i "$mkv_file" | grep -q -E "^Attachment ID [0-9]+: .+ file name '$attachment_name'$"
@hekmon
hekmon / probe_gop.sh
Created July 25, 2024 18:03
Count GOP (Group Of Pictures) and their frames (I, P and B frames) within a video file
#!/usr/bin/env bash
set -e
GOP=0
iframes=0
totiframes=0
pframes=0
totpframes=0
bframes=0
@hekmon
hekmon / ffmpeg_vmaf.sh
Last active February 23, 2026 09:46
ffmpeg w vmaf
# ffmpeg v8 with cuda 13.1 on Ubuntu 24.04 on WSL2 with optional support of CUDA for RTX 5000 series (SM_120)
# https://docs.nvidia.com/video-technologies/video-codec-sdk/13.0/ffmpeg-with-nvidia-gpu/index.html#compiling-for-linux
# https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
# https://developer.nvidia.com/cuda-downloads (if you want CUDA)
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
sudo apt-get -y install cuda-toolkit-13-1
@hekmon
hekmon / README.md
Last active July 21, 2025 16:01
EDF Time based Tempo prices

Simply include the file within your configuration.yaml file like this:

# ...
template: !include templates.yaml
# ...

You will need prices input number from this gist and the RTE Tempo extension.

@hekmon
hekmon / README.md
Last active February 2, 2026 15:53
EDF Tarif Bleu prices within Home Assistant

Simply include the file within your configuration.yaml file like this:

# ...
input_number: !include input_numbers.yaml
# ...

Restart your Home Assistant to update the values (reloading YAML will not be enough).

@hekmon
hekmon / README.md
Last active June 26, 2022 19:55
Linux TCP tuning for CIFS over WAN/VPN

TCP Tuning for CIFS over VPN/WAN

If your bandwitch allows it, this will enable stutter free streaming of 4K remuxes over CIFS/VPN/WAN.

Install

sudo wget 'https://gist.github.com/hekmon/78b30ae8cb76b076d01bddaf79b2c693/raw/d063a1bee463745ce2b8ded41475b5d9c179c7b4/sysctl.conf' -O '/etc/sysctl.d/90-CIFS_over_WAN.conf'
sudo sysctl -p
@hekmon
hekmon / awscliv2.sh
Last active May 23, 2023 16:02
AWS CLI v2 - install and update on a bash based linux system
#!/bin/bash -e
# https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html#cliv2-linux-install
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-completion.html
echo "* Switching to tmp folder..."
cd "$(mktemp -d)"
echo
echo "* Downloading the AWS cli..."
wget -q "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -O awscliv2.zip
@hekmon
hekmon / chroot.sh
Last active September 7, 2020 11:04
Quick live rescue chroot script
#!/bin/bash -e
ROOT=$1
HOME=$2
if [ ! -b "$ROOT" ]
then
echo "First parameter (/) is not a block device" >&2
exit 1
fi
@hekmon
hekmon / dp_autostop.go
Last active February 1, 2021 17:39
Golang "autostop" design pattern: controller with clean context stop (avoid Start() Stop() workflow)
package foobar
import (
"context"
"errors"
)
// Controller is a base pattern controller
type Controller struct {
ctx context.Context