Skip to content

Instantly share code, notes, and snippets.

View 4piu's full-sized avatar
ROLLING BACK

4piu 4piu

ROLLING BACK
View GitHub Profile
@4piu
4piu / lxc-audio.cfg
Created August 6, 2026 04:28
Allow LXC container to play audio using host device
# Audio Configuration
# Create a file on host: /etc/udev/rules.d/99-lxc-audio.rules
# ACTION=="add", SUBSYSTEM=="sound", ENV{DEVNAME}!="", RUN+="/usr/bin/setfacl -m u:101000:rw $env{DEVNAME}"
# EOF
# Replace 101000 with the your mapped user ID for unprivileged container
# !!! This rule must be executed after 73-seat-late.rules !!!
lxc.cgroup2.devices.allow = c 116:* rwm
lxc.mount.entry = /dev/snd dev/snd none bind,optional,create=dir
@4piu
4piu / lxc-nv-gpu-unprivileged.cfg
Last active July 31, 2026 02:03
Access Nvidia GPU on host from unprivileged LXC
# NVIDIA GPU passthrough
# These needs to be put before including common.conf ¯\_(ツ)_/¯
lxc.cgroup2.devices.allow = c 195:* rwm
lxc.cgroup2.devices.allow = c 509:* rwm
lxc.cgroup2.devices.allow = c 236:* rwm
lxc.mount.entry = /dev/nvidia0 dev/nvidia0 none bind,optional,create=file
# in case you have another GPU
lxc.mount.entry = /dev/nvidia1 dev/nvidia1 none bind,optional,create=file
lxc.mount.entry = /dev/nvidiactl dev/nvidiactl none bind,optional,create=file
@4piu
4piu / nix-nonroot.md
Created April 15, 2026 05:35
Install Nix on Linux without root
@4piu
4piu / homebrew-nonroot.md
Created April 15, 2026 05:14
Install Homebrew on Linux without root

Install Homebrew on Linux without root

Working on a system without root privilege is challenging when you need to install utilities. Homebrew is a popular rootless package manager widely used on macOS and Linux. However, installing Homebrew typically requires temporary root access to write to /home/linuxbrew.

While you can install to any other writable directory, this approach is unsupported and prevents access to pre-built binaries ("bottles")—meaning almost everything must be compiled from source, which is slow and tedious. This guide provides a workaround using PRoot to "fake" a writable /home/linuxbrew directory for your user, allowing Homebrew to function seamlessly without root access.

Install PRoot

Find the latest PRoot binary from Gitlab - PRoot

Locate URL to the binary in Build > Jobs > Stage=dist, for example: https://gitlab.com/proot/proot/-/jobs/2370229665/artifacts/download?file_type=archive

@4piu
4piu / macOS-utilities.md
Created April 8, 2026 18:02
Collection of personal macOS utilities

A lightweight uninstaller that removes apps along with their related leftover files.

A display management tool for controlling resolution, scaling, brightness, and virtual displays.

@4piu
4piu / hotkey-activated-loop.ahk
Created January 17, 2026 03:19
AutoHotKey example: hotkey activated loop, skip if window not in focus.
#Requires AutoHotkey v2.0
#SingleInstance Force
#MaxThreadsPerHotkey 2
windowTitle := "ahk_exe notepad.exe"
#HotIf WinActive(windowTitle)
+F1:: {
static running := false
running := !running
@4piu
4piu / slurm-feeder.sh
Created January 2, 2026 19:10
Avoid QoS error when submitting large number of slurm tasks. The script dispatch new task when previous one is completed.
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -lt 1 ]]; then
echo "Usage: $0 COMMAND_FILE" >&2
exit 1
fi
CMD_FILE=$1
MAX_JOBS=${MAX_JOBS:-20}
@4piu
4piu / 00_sync_chat.py
Created November 1, 2025 16:25
Download Telegram chats medias with iyear/tdl
#!/usr/bin/env python3
"""
Sync Telegram chats using tdl (Telegram Downloader).
This script fetches the chat list, processes channels and groups,
exports chat data, and manages download folders.
"""
import json
import sys
@4piu
4piu / ts-update.sh
Created October 19, 2025 00:57
Update timestamps (touch) for files under specified directory.
#!/bin/bash
# Global variable for verbose mode
VERBOSE=false
# Function to update timestamps recursively
update_timestamps() {
local dir="$1"
local full_path
@4piu
4piu / 00suppress_kmsg.sh
Created September 8, 2025 03:31
Disable kernel message output on /dev/ttyS0 once user logged in. Handy if you have to work over TTY. Put this under /etc/profile.d/
if [ "$(tty)" = "/dev/ttyS0" ] && [ $(cat /proc/sys/kernel/printk | awk '{print $1}') -gt 1 ]; then
echo "Suppressing low-priority kernel messages on serial console."
dmesg -n 1
fi