Skip to content

Instantly share code, notes, and snippets.

@nijave
nijave / chinese_switches.md
Created April 25, 2026 17:19
Table of Chinese switch OEMs and brands

Complete brand catalog with evidence tiers

The following table organizes every identified brand by the strength of evidence linking it to the shared OEM ecosystem. All these brands sell switches built around Realtek chipsets (primarily RTL8373-CG + RTL8224-CG for 2.5GbE models and RTL9303 + RTL8261BE for 10GbE models) in near-identical or identical hardware configurations.

Tier 1 — Confirmed via manufacturer's own documentation or PCB markings:

Brand Key evidence Likely OEM source
Hasivo Original manufacturer Sichuan Hasivo Electronics
MokerLink Hasivo-branded PCBs inside units; Hasivo website OEM pages; "HS_" firmware prefix Sichuan Hasivo Electronics
@nijave
nijave / sas3-table.py
Created January 17, 2026 17:59
Print out disk information for zpool disks attached to a SAS3 controller
#!/usr/bin/env python3
"""
Usage: sas3-table.py <controller #>
Takes <controller #> like you'd pass to sas3ircu
Requires
- sas3ircu (assumes passwordless sudo)
- lsblk
@nijave
nijave / serverpartdeals.py
Last active February 14, 2025 01:15
serverpartdeals.com $/TiB
import re
import niquests
import sys
from bs4 import BeautifulSoup
def parse_page(soup):
drives = soup.find_all(class_="boost-pfs-filter-product-bottom")
for drive in drives:
@nijave
nijave / openssl-hash.sh
Created June 16, 2024 21:08
OpenSSL PBKDF2
#!/usr/bin/env sh
set -e
pw=$(tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 20)
iterations=100000
eval $(echo -n "$pw" | openssl enc -pbkdf2 -pass pass:/dev/stdin -aes-256-cbc -P -md sha256 -iter $iterations | grep -E '^(salt|key)')
pwHash={PBKDF2}${iterations}\$${salt}\$${key}
echo "$pwHash"
@nijave
nijave / ddl-triggers.sql
Created June 6, 2024 00:26
Sync DDL changes over Postgres logical replication
-- create log table (source side)
CREATE TABLE ddl_log (
id integer PRIMARY KEY,
object_tag TEXT,
ddl_command TEXT,
timestamp TIMESTAMP
);
CREATE SEQUENCE ddl_log_seq;
-- create log function (source side)
@nijave
nijave / ubuntu-k8s.sh
Created March 27, 2024 22:09
Kubernetes and cri-o v1.29 repo setup for Ubuntu 22.04 (jammy)
K8S_VERSION_MINOR=1.29
# Repos for cri-o
curl -fsSL https://pkgs.k8s.io/addons:/cri-o:/stable:/v${K8S_VERSION_MINOR}/deb/Release.key |
gpg --dearmor -o /etc/apt/keyrings/cri-o-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/cri-o-apt-keyring.gpg] https://pkgs.k8s.io/addons:/cri-o:/stable:/v${K8S_VERSION_MINOR}/deb/ /" |
tee /etc/apt/sources.list.d/cri-o.list
# Repo for Kubernetes tools/components
curl -fsSL https://pkgs.k8s.io/core:/stable:/v${K8S_VERSION_MINOR}/deb/Release.key |
@nijave
nijave / tg-tldr.sh
Created December 13, 2023 22:18
Terragrunt pretty print
# 1. Find colored lines
# 2. Strip out useless lines
# 3. Strip empty "colored" lines
grep --color=never $'\x1b''\[[0-9;]*' \
| grep -vE 'Terraform has been|Initializing |use this backend unless the backend configuration changes|commands will detect it and remind you to do so if necessary|Refreshing state...|Read complete after |Reading...| copy_backend_before_init |Terraform has compared your real infrastructure|No changes.' \
| sed -E '/^'$'\x1b''\[0m'$'\x1b''\[32m/d'
sudo dnf install -y VirtualBox-server
# Make a vhd
qemu-img create -f vpc test.vhd 8G
virt-format -a test.vhd --partition=gpt --filesystem=ntfs
echo 'write /readme.txt "readme"' | guestfish -a test.vhd -m /dev/sda1
mkdir test
vboximg-mount --image $(pwd)/test.vhd --rw --root test
mkdir testfs
@nijave
nijave / dd-k8s-ns.sh
Created June 1, 2023 15:32
Docker Desktop Kuberentes Auto Provision Namespace
docker run --rm --privileged --pid=host ubuntu:22.04 \
nsenter -t 1 -m -u -n -i \
sh -c "sed -i '/enable-admission-plugins/{/NamespaceAutoProvision/b; s/$/,NamespaceAutoProvision/}' /etc/kubernetes/manifests/kube-apiserver.yaml"
python3 -c '
import json
import sys
from urllib.parse import urlparse, parse_qs
print(json.dumps(parse_qs(urlparse(sys.argv[1]).query)))
'