Skip to content

Instantly share code, notes, and snippets.

View Nexarian's full-sized avatar

Christopher Pitstick Nexarian

View GitHub Profile
@Nexarian
Nexarian / python-build.sh
Last active July 1, 2026 03:07
Build Python
export PYTHON_VERSION=3.14.6
sudo apt-get install -y curl gcc libbz2-dev libev-dev libffi-dev libgdbm-dev liblzma-dev libncurses-dev libreadline-dev libsqlite3-dev libssl-dev make tk-dev wget zlib1g-dev libgdbm-compat-dev build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev checkinstall libncursesw5-dev lzma-dev lcov libgd-perl libperlio-gzip-perl lzma
cd ~
curl -O https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz
tar -xvzf Python-${PYTHON_VERSION}.tgz
# Alternatively, you an eliminate the prefix parameter and use `sudo make altinstall` to install it in your home directory.
cd ~/Python-${PYTHON_VERSION}
./configure \
@Nexarian
Nexarian / python-build.sh
Created June 13, 2026 13:52
Build Python
export PYTHON_VERSION=3.14.6
sudo apt-get install -y curl gcc libbz2-dev libev-dev libffi-dev libgdbm-dev liblzma-dev libncurses-dev libreadline-dev libsqlite3-dev libssl-dev make tk-dev wget zlib1g-dev libgdbm-compat-dev build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev checkinstall libncursesw5-dev lzma-dev lcov libgd-perl libperlio-gzip-perl lzma
cd ~
curl -O https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz
tar -xvzf Python-${PYTHON_VERSION}.tgz
# Alternatively, you an eliminate the prefix parameter and use `sudo make altinstall` to install it in your home directory.
cd ~/Python-${PYTHON_VERSION}
./configure --prefix=/opt/python/${PYTHON_VERSION} --disable-gil --enable-shared --enable-optimizations --enable-ipv6 LDFLAGS=-Wl,-rpath=/opt/python/${PYTHON_VERSION}/lib,--disable-new-dtags
@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