Skip to content

Instantly share code, notes, and snippets.

View walking-octopus's full-sized avatar
💣
Surviving WW3

walking-octopus

💣
Surviving WW3
  • Kiev, Ukraine
  • 20:36 (UTC +03:00)
View GitHub Profile
@walking-octopus
walking-octopus / 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)))]))
@walking-octopus
walking-octopus / 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
@walking-octopus
walking-octopus / 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;")