Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
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 / 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 -)"
@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)