Skip to content

Instantly share code, notes, and snippets.

@Nexarian
Nexarian / wait_for_lans.sh
Created August 5, 2025 03:12
Wait for lans
#!/usr/bin/env bash
# Maximum wait time in seconds
timeout=300
elapsed=0
while [[ $elapsed -lt $timeout ]]; do
up0=$(cat /sys/class/net/wlan0/operstate 2>/dev/null)
up1=$(cat /sys/class/net/wlan1/operstate 2>/dev/null)
@Nexarian
Nexarian / start_nanny.sh
Created August 5, 2025 03:08
Start Nanny
#!/usr/bin/env bash
set -x
export ENV_NAME="nanny-env"
export PYENV_ROOT="/home/christopher/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
import subprocess
import threading
import time
from collections import deque
from dataclasses import dataclass, field
from datetime import datetime
from datetime import time as dt_time
from enum import Enum
from typing import Callable, Deque, Dict, Optional, Set, Tuple
from zoneinfo import ZoneInfo
@Nexarian
Nexarian / TEG-1JG.nmconnection
Created July 20, 2025 15:43
Inverter connection profile example
[connection]
id=TEG-1JG
type=wifi
autoconnect-retries=0
interface-name=wlan1
timestamp=1753015674
[wifi]
cloned-mac-address=permanent
mac-address-randomization=1
@Nexarian
Nexarian / setup_routing_nat_wlan.py
Last active June 22, 2025 20:34
Setup Tesla Wireless network routing on a RPi with multiple Wifi connections
#!/usr/bin/env python3
#########
# Command to run
# sudo -E env PATH="$PATH" ./.venv/bin/python3 ./setup_routing_nat.py
#########
# Auto run
# sudo vim /etc/NetworkManager/dispatcher.d/99-ip-change
#########
@Nexarian
Nexarian / setup_routing_nat.py
Last active February 14, 2025 01:39
IP Routing Prototype in Python
#!/usr/bin/env python3
import os
import socket
import subprocess
import sys
from typing import Any, Dict, Final, List, Tuple
import iptc
import psutil
@Nexarian
Nexarian / ip_routing_ns.sh
Created January 4, 2025 06:13
IP Routing with Namespaces
#!/usr/bin/env bash
set -ex
BRIDGE_NAME="br0"
BRIDGE_IP="192.168.92.1"
setup_bridge() {
echo "Setting up bridge $BRIDGE_NAME"
ip link add name $BRIDGE_NAME type bridge
@Nexarian
Nexarian / ip_routing.sh
Created January 4, 2025 06:13
IP Routing Prototype with direct IP addresses
#!/bin/bash
set -ex
# Function to check if a command succeeded
check_command() {
if [ $? -ne 0 ]; then
echo "Error: $1"
exit 1
fi
@Nexarian
Nexarian / xrdp-setup-x264-no-hw-accel.sh
Last active January 17, 2025 21:38
XRDP setup enabling X264 with no Nvidia or Intel acceleration
#!/usr/bin/env bash
set -e
sudo -v
sudo apt-get update
sudo apt-get dist-upgrade -y
sudo apt-get autoremove -y
~/restart_xrdp.sh
sudo make clean all -j $(nproc)
sudo make install -j $(nproc)
sudo systemctl daemon-reload
sudo service xrdp restart