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 / 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
@4piu
4piu / Tailscale-to-Wireguard.md
Last active February 2, 2026 03:37
Route Tailscale exit node traffic to Wireguard

This script enables you to forward all traffic from a Tailscale exit node through a WireGuard tunnel.

Most mobile devices support only one active VPN connection at a time. As a result, users can't simultaneously use Tailscale for connectivity and route their internet traffic through another VPN. This script provides a workaround by turning a Tailscale exit node into a VPN bridge. When clients use this special exit node, their internet traffic is protected by the VPN while still maintaining Tailscale connectivity.

Requirements:

  • Enable forwarding
  • Tailscale need to run with --netfilter-mode=[off|nodivert] for manual routing control
  • Set Table = off in Wireguard config to manual control ip rules
  • Set PostUp and PreDown script in Wireguard config
@4piu
4piu / dominion-energy-usage-sync.py
Created February 25, 2025 13:18
Get Dominion Energy hourly usage data, then save to SQLite. Login with Selenium+Chrome
import datetime
import logging
import logging.config
import os
import pickle
import pytz
import requests
import sqlite3
from selenium import webdriver
from selenium.webdriver.common.by import By