Skip to content

Instantly share code, notes, and snippets.

View aparatext's full-sized avatar

aparatext

  • Sol-III
  • 21:33 (UTC +02:00)
View GitHub Profile
@aparatext
aparatext / fr-cal.scm
Created February 26, 2026 13:06
French Republican Calender and 20-hour clock in Scheme
#!/usr/bin/env -S guile -q -s
!#
(define (fr-date equinox timestamp)
(define +fr-epoch+ -5594234524)
(define +months+
'(Vendemiaire Brumaire Frimaire
Nivose Pluviose Ventose
Germinal Floreal Prairial
@aparatext
aparatext / ffprint
Last active December 16, 2025 23:19
ffprint, ffprint-ck - human-friendly, 128-bit secure, typo-detecting file fingerprints
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.13"
# dependencies = [ "blake3"]
# ///
from sys import stdin
from blake3 import blake3
from itertools import batched, cycle
ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
@aparatext
aparatext / debug.scm
Created July 16, 2025 13:07
Rust-like debug macro for Scheme
# Racket
(define-syntax (dbg! stx)
(syntax-case stx ()
[(_ expr)
(with-syntax ([expr-str (format "~a" (syntax->datum #'expr))])
#'(let ([result expr])
(begin
(printf "~a = ~a\n" expr-str result)
result)))]))
@aparatext
aparatext / autoname-workspaces.py
Last active May 4, 2025 10:14
Auto-name Sway/i3wm Workspaces
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "i3ipc",
# ]
# ///
# autoname-workspaces: adds icons to the workspace name for each open window.
# Refactored https://github.com/OctopusET/sway-contrib/blob/master/autoname-workspaces.py
;; Triangle of Power operator in Scheme.
;; Tested in Racket, Guile, and Chicken; portable under R6RS+.
;; See https://mathcenter.oxford.emory.edu/site/math108/logs/
;; and https://www.youtube.com/watch?v=sULa9Lc4pck
;; and https://math.stackexchange.com/questions/30046/alternative-notation-for-exponents-logs-and-roots/165225#165225
;; to learn about "Triangle of Power" notation
;; Exponents Logs Radicals (triangle) operation
(define-syntax elr
#!/usr/bin/env fish
set version_id (curl https://raw.githubusercontent.com/IntellectualSites/CurseForge-version-identifier/main/versions.json -s | jq '.[] | select(.name == "'$argv[2]'") | .id')
set mod_id (python3.12 -c 'import cloudscraper, sys; print(cloudscraper.create_scraper().get(f"https://legacy.curseforge.com/minecraft/mc-mods/{sys.argv[1]}").text)' $argv[1] | awk '
/<span>Project ID<\/span>/ {
getline
gsub(/<[^>]*>/, "", $0)
print $0
}' | string trim)
function mv.ln --description 'Move a file/directory, create symlink in old location. Includes undo flag.'
argparse 'u/undo' -- $argv
or return
if [ (count $argv) -ne 2 ]
and [ not $_flag_undo ]
echo "Usage: mv.ln [-u|--undo] <source> <destination>"
return 1
end
@aparatext
aparatext / now.fish
Created July 29, 2022 16:18
A tiny Fish script to fetch some basic info on Ubuntu Touch
#!/usr/bin/env fish
set TIME (date +%H:%M)
set DATE (set LANG en_us_88591; date +"%b %d, %a")
set MEM_USE (free -t | awk 'FNR == 2 {printf("%.1f"), $3/$2*100}')
set CPU_USE (cat /proc/loadavg | awk '{ printf("%.2f"), $0;}')
set BATT (cat /sys/class/power_supply/battery/capacity)
set MISSED_CALLS (sqlite3 ~/.local/share/history-service/history.sqlite "SELECT COUNT(*) FROM 'voice_events' WHERE timestamp >= datetime('now','-1 hour') AND missed=1;")