Skip to content

Instantly share code, notes, and snippets.

View thomsh's full-sized avatar
💭
🥝

Thomas thomsh

💭
🥝
View GitHub Profile
@thomsh
thomsh / NUC11TNHi5.md
Last active December 2, 2022 09:25
NUC11TNHi5 setup with hardware acceleration for video decode

Intel NUC NUC11TNHi5 setup with hardware acceleration for video decode

Using Ubuntu 22.04 graphical session on x11 (but very few diff with wayland)
With this setup the nuc can play 4k60fps video in Kodi, Firefox, Chrome without any issue.

Install intel stuff

apt-get install -qy \
  intel-gpu-tools intel-media-va-driver-non-free \
  intel-microcode vainfo libva2 libva-x11-2
cat < /etc/modprobe.d/i915.conf
@thomsh
thomsh / Fix no sound via HDMI on boot with ubuntu 22.04 and Samsung tv Q80A.md
Last active December 1, 2022 10:58
Fix no sound via HDMI on boot with ubuntu 22.04 and Samsung tv Q80A

Fix no sound via HDMI on boot with ubuntu 22.04 and Samsung tv Q80A

Symtoms

Using an Intel NUC11TNHi5 ,Tiger Lake, I've no HDMI sound on boot on a Samsung TV model Q80A.

Running ubuntu 22.04, kernel 5.15.0-53-generic, with intel-media-va-driver-non-free and enable_fbc=1 enable_guc=3 fastboot=1 as option for i915 module_
Bug is present on wayland and xorg/x11

I can fix this either via

  • unpluging the HDMI cable
#!/usr/bin/env python3
""" Deletes all tweets below a certain retweet threshold.
You have to create an app on twitter, and follow their process to have the required creds
and setup write permissions.
"""
import tweepy
from datetime import datetime
import os
#!/usr/bin/env bash
#
# Script to remove GPG user (recipient) with git-crypt
#
# It will re-initialize git-crypt for the repository and re-add all keys except
# the one requested for removal.
#
# Note: You still need to change all your secrets to fully protect yourself.
# Removing a user will prevent them from reading future changes but they will
# still have a copy of the data up to the point of their removal.
#!/opt/chef-workstation/embedded/bin/ruby
require "chef/encrypted_data_bag_item"
require "json"
if ARGV.length != 2
puts "usage: decrypt_databag.rb /path/to/cipher_json_data_bag KEY"
abort
end
cipherdata_path = ARGV[0]
#!/opt/chef-workstation/embedded/bin/ruby
require "chef/encrypted_data_bag_item"
require "json"
if ARGV.length != 2
puts "usage: encrypt_databag.rb /path/to/plain_json_data_bag KEY"
abort
end
plaindata_path = ARGV[0]
@thomsh
thomsh / kernel-settings-for-desktop.sh
Last active July 15, 2020 02:01
Desktop kernel settings WIP
#!/usr/bin/env bash
# Enable all sysrq https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html
sysctl -w kernel.sysrq=1 # 1 mean all
# Ask the kernel to keep 3% of the ram free
sysctl -w vm.min_free_kbytes="$(grep '^MemTotal:' /proc/meminfo |awk '{print int($2*0.03)}')"
# Ask the kernel to keep 3% of the ram for admin things
sysctl -w vm.admin_reserve_kbytes="$(grep '^MemTotal:' /proc/meminfo |awk '{print int($2*0.03)}')"
@thomsh
thomsh / update-iptables.sh
Created March 20, 2020 04:07
A simple iptables script works well with iptables-persistent (but don't validate rule)
#!/usr/bin/env bash
# Simple script to handle iptables rule before swithing to nftable
# This script should not be interrupted in case of error : this will break iptables
# Add custom script in /etc/iptables.d
set -x
CUSTOM_RULES="/etc/iptables.d"
DISABLE_SSH_RULE="/etc/firewall-disable-auto-ssh" # create this file to disable ssh auto rule
if [ "$(id -u)" -ne 0 ];then
echo "Re-run $0 as root"
@thomsh
thomsh / git-crypt-rm-gpg-user.sh
Last active October 19, 2023 05:14 — forked from Falkor/git-crypt-rm-gpg-user.sh
Allow you to rotate your git-crypt key and re-encrypt your repository after removing GPG user (Safer version)
#!/usr/bin/env bash
#
# Script to remove GPG user (recipient) with git-crypt
#
# It will re-initialize git-crypt for the repository and re-add all keys except
# the one requested for removal.
#
# Note: You still need to change all your secrets to fully protect yourself.
# Removing a user will prevent them from reading future changes but they will
# still have a copy of the data up to the point of their removal.
@thomsh
thomsh / docker_clean.sh
Created March 3, 2020 01:31
Clean & freeup ressources when using docker manualy.
#!/usr/bin/env bash
set -euxo pipefail
echo "[*] Clean up exited or created but unused containers"
docker ps -a -q -f status=exited |xargs -r -- docker rm -v
docker ps -a -q -f status=created |xargs -r -- docker rm -v
echo "[*] Remove dangling images"
docker images -f dangling=true -q |xargs -r -- docker rmi
echo "[*] Purge system ressources & volumes"
docker volume prune -f
docker system prune -f