Skip to content

Instantly share code, notes, and snippets.

View pirate's full-sized avatar
🗃️
Archiving all the things!

Nick Sweeting pirate

🗃️
Archiving all the things!
View GitHub Profile
@pirate
pirate / iterated_prisoners_dillema.html
Created February 7, 2025 14:07
Mini JS web game allowing you to simulate iterated prisoners dillema rounds against a bot character with a few different strategies
<!-- Iterated prisoners dillema mini JS web game by Nick Sweeting on 2025-02-07 https://blog.sweeting.me -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Iterated Prisoner's Dilemma Game</title>
<style>
/* Basic Styles */
body {
font-family: sans-serif;
@pirate
pirate / usernames.txt
Last active February 5, 2025 23:05
Untaken 3-letter Usernames on Github
None of these 3 letter-only usernames below are available anymore as of 2021.
However, if you use numbers and symbols, or accept 4 letters, you can definitely find a free one.
Check responsibly. Don't spam the github API/support, it's not a race, there are plenty free if you have imagination.
agq, ahq, aqf, aqg, aqp, aqt, aqf, aqy, atq, auh, ayp, azj, azq, bey, bgt, bgx, bhq, bkk, bkq, bmq,
bpp, bpq, bqa, bqc, bqg, bqi, bqj, bql, bqn, bqo, bqp, bqr, bqt, bqy, buo, buq, bwz, bxe, bxo, bxw,
bzn, bzp, cfl, ckg, ckq, cnq, cpq, cpz, cqa, cqe, cqf, cqg, cqk, cqo, cqp, cqf, cqx, cqz, cud, cuh,
cuk, cuo, cfl, cxe, czo, dkq, dnq, dqg, dqi, dqk, dqo, dqs, dsr, dtq, dxe, eaj, eaq, ebq, ecl, ecy,
eer, efq, efy, egq, egx, ehh, ehz, eiu, eiw, eiy, ejx, eoq, eou, epj, eqa, eqb, eqf, eqg, eqj, eqk,
eqs, eqf, eqw, eqz, erq, etq, eub, euf, euj, euq, euf, efq, efy, ewy, ewz, exn, eyh, eyj, eyn, eyq,
@pirate
pirate / dxp4800_plus_lspci_fio_tests.txt
Last active January 30, 2025 22:50
lspci and fio speed testing the internal and main nvme slot speeds on a UGREEN DXP4800 Plus NAS
# This is the output of testing the nvme slot speeds on a UGREEN DXP4800 Plus NAS
# The internal slot is limited to PCIe 3.0 speeds and 25w compared to the main slots at PCIe 4.0 speeds and 75w.
# https://www.reddit.com/r/homelab/comments/1bya4n1/ugreen_nas_ama/m9sqojt/
root@ugnas[~]# fio --filename=/dev/nvme2n1 --direct=1 --rw=read --bs=1M --ioengine=libaio --iodepth=32 --numjobs=1 --name=seq_read_test --size=10g
seq_read_test: (g=0): rw=read, bs=(R) 1024KiB-1024KiB, (W) 1024KiB-1024KiB, (T) 1024KiB-1024KiB, ioengine=libaio, iodepth=32
fio-3.33
Starting 1 process
Jobs: 1 (f=1): [R(1)][-.-%][r=3360MiB/s][r=3360 IOPS][eta 00m:00s]
seq_read_test: (groupid=0, jobs=1): err= 0: pid=5961: Thu Jan 30 14:39:40 2025
@pirate
pirate / truenas_enable_boot_write.sh
Last active January 29, 2025 00:49
Commands to enable read-write / apt install on the boot pool for TrueNAS scale
# enable read-write / apt install on the boot pool for TrueNAS scale
mount -o remount,rw 'boot-pool/ROOT/24.10.2/usr'
chmod +x /bin/apt*
chmod +x /usr/bin/dpkg
apt-get update
/usr/local/libexec/disable-rootfs-protection
@pirate
pirate / docker-compose-backup.sh
Last active January 26, 2025 23:38
Backup a docker-compose project, including all images, named and unnamed volumes, container filesystems, config, logs, and databases.
#!/usr/bin/env bash
### Bash Environment Setup
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
# set -o xtrace
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
@pirate
pirate / uuid7.py
Last active January 25, 2025 15:11
Pure python all-in-one UUIDv7 Implementation with graceful degradation between ms, µs, and ns timestamp precision
#!/usr/bin/env python3
# A single-file pure-python implementation of UUIDv7: (e.g. 01941230-851a-77fd-9b0b-8c8eac3b2d23)
# - makes sure UUIDv7s are always generated in alphabetic order (using system time + nanoseconds + extra monotonic random bits)
# - store millisecond, microsecond, nanosecond / variable precision timestamps all using same format
# - graceful degradation in precision, falls back to monotonic urandom bytes depending on user-provided timestamp precision
# - fully compatible with standard UUIDv7 spec (48 bit millisecond unix epoch time with rand_a & rand_b monotonic randomness)
# - allows you to generate a UUIDv7 with a given timestamp (of any precision), and parse the timestamp back out from any UUIDv7
# - helps guarantee that UUIDv7s generated back-to-back in the same thread are always monotonically sortable
# - helps lower the risk of UUIDv7s colliding with other UUIDv7s generated in other threads / on other machines
@pirate
pirate / strip_bad_filename_characters.sh
Last active January 22, 2025 00:49
Bash script to remove accents and special characters from filenames recursively.
#!/usr/bin/env bash
# Recursively remove all special characters from filenames by renaming them to their ASCII normalized forms.
#
# By default it does a dry run, to actually move the files uncomment the `mv -vi ...` line.
#
# This is useful for cleaning up network shares that will be shared via SMB/NFS between Unix/macOS/Windows
# where non-ASCII filenames can sometimes cause "file does not exist" errors when trying to access the files.
#
# This script removes leading/trailing whitespace in filenames and replaces accents and non-english
# characters with their ASCII equivalent, if no ASCII equivalent exists, it removes the character e.g.:
@pirate
pirate / Install FreeNAS SCALE on a partition and create a mirror.md
Created January 18, 2025 09:05 — forked from gangefors/Install FreeNAS SCALE on a partition and create a mirror.md
How to install TrueNAS SCALE on a partition instead of the full disk

Install TrueNAS SCALE on a partition instead of the full disk

The TrueNAS installer doesn't have a way to use anything less than the full device. This is usually a waste of resources when installing to a modern NVMe which is usually several hundred of GB. TrueNAS SCALE will use only a few GB for its system files so installing to a 16GB partition would be helpful.

The easiest way to solve this is to modify the installer script before starting the installation process.

@pirate
pirate / udm_fancontrol_setup.sh
Created June 4, 2024 10:34
Setup Unifi Dream Machine (UDM, UDM-SE, etc.) automatic fan speeds control to lower temps and increase hard drive lifespan.
#!/bin/bash
# Installs and configures fancontrol to automatically run Unifi Dream Machine (UDM) fans harder & lower temperatures.
#
# Context: Unifi equipment typically runs *very* hot from the factory unless you customize it.
# I don't want my hard drives to run as hot as they let them get by default (55ºC+), because it shortens lifespan (ideal temp is ~35-45C).
#
# Further Reading:
# - https://linux.die.net/man/8/fancontrol
# - https://community.ui.com/questions/Unifi-Dream-Router-fan-speed/1cb9cf18-e8a0-44b4-8402-ee9bac367bc0
# - https://www.reddit.com/r/Ubiquiti/comments/13imgqj/udm_pro_fan_speed_is_this_normal/
@pirate
pirate / cat_chat.tsx
Created December 24, 2024 09:11
A very simple dumb v0 app that lets you chat with your cat (listens for cat meows using browser microphone and then lets you type meows back).
'use client'
import { useState, useEffect, useRef } from 'react'
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
type Message = {
sender: 'human' | 'cat'
content: string