Skip to content

Instantly share code, notes, and snippets.

@mys721tx
mys721tx / uc_brand_colors.json
Created September 16, 2026 03:44
UC Brand Colors
{
"title": "University of California Brand Colors",
"date": "2026-09-15",
"subtitle": "Primary blue and yellow/gold from each campus's official brand guidelines",
"columns": [
"Campus",
"Blue",
"Yellow / Gold"
],
"campuses": [
@mys721tx
mys721tx / swu.py
Created April 5, 2026 22:08
Separative work unit calculation
import math
def val(x):
"""Value function V(x)."""
if x == 0 or x == 1:
return 0
return (1 - 2 * x) * math.log((1 - x) / x)
@mys721tx
mys721tx / summarizer.py
Created June 28, 2025 03:27
Call GPT to summarize a book
import re
import openai
import os
openai.api_key = "YOUR_OPENAI_API_KEY"
# Load the text (replace with your actual file path)
with open("pg14833.txt", "r", encoding="utf-8") as f:
text = f.read()
@mys721tx
mys721tx / homebridge.sh
Last active December 2, 2024 05:27
homebridge container
pacstrap -K -c /var/lib/machines/homebridge base systemd dbus nodejs-lts-iron npm make gcc net-tools sudo which run-parts
@mys721tx
mys721tx / canton_network.py
Created June 11, 2024 22:18
Show the namesake relationship of every town named "Canton" in the United States
# %%
import csv
import networkx as nx
from networkx.drawing.nx_agraph import write_dot
# %%
# Create a directed graph
G = nx.DiGraph()
# Open and read the TSV file
@mys721tx
mys721tx / admin_actions.py
Created June 11, 2024 22:16
Projecting Wikipedia admin actions to 2d
# %%
import pandas as pd
import numpy as np
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt
import umap
# %%
# specify the file path
@mys721tx
mys721tx / 16to8.sh
Created May 20, 2024 20:12
Convert 16 bit images to 8 bit
#!/bin/bash
for f in Default/*.tif; do
convert "$f" -auto-level -depth 8 "8bit/$(basename "$f")"
done
@mys721tx
mys721tx / sudo.patch
Created March 31, 2023 17:54
Enabling TouchID support for sudo on Mac
--- /etc/pam.d/sudo 2023-03-31 09:17:20.230708973 -0700
+++ sudo 2023-03-31 09:14:05.772051938 -0700
@@ -1,4 +1,6 @@
# sudo: auth account password session
+auth optional /opt/homebrew/lib/pam/pam_reattach.so ignore_ssh
+auth sufficient pam_tid.so
auth sufficient pam_smartcard.so
auth required pam_opendirectory.so
account required pam_permit.so
@mys721tx
mys721tx / iss_tle.R
Last active June 13, 2022 11:22
ISS ground track plotter
library(tidyverse)
library(asteRisk)
library(ggmap)
library(lubridate)
getLatestSpaceData()
iss_tle <- read_file(
"https://celestrak.com/NORAD/elements/gp.php?CATNR=25544&FORMAT=tle"
) %>%
@mys721tx
mys721tx / kittens.js
Created January 4, 2021 04:04
Kitten Game
can_build = (b) => {
c = gamePage.bld.getPrices(b).map(
(p) => {
if (!gamePage.resPool.get(p.name).unlocked) {
return false
}
if (gamePage.resPool.get(p.name).maxValue === 0) {
if (gamePage.bld.get(b).val < 200) {
return true
}