Skip to content

Instantly share code, notes, and snippets.

@phunanon
phunanon / single-dep-builder.ix
Created December 7, 2023 12:32
Builds HTML files with %dep.html% substitution
(import "phunanon/fs")
(import "phunanon/dotenv") ──────
(-> (dotenv) :www (var www))
(-> (ls "*.html")
(var names)
(juxt _ (map (comp read trim)))
(... kv-dict)
(var files))
@phunanon
phunanon / hello.bf
Created September 7, 2023 18:35
"Hello, world!" in Brainfuck
+++++++[>++++++++++<-]>++.
<++++[>+++++++<-]>+.
+++++++..
+++.
>++++[>+++++++++++<-]>.
------------.
[-]
<<[>+>+<<-]>++++++++.>.
+++.
------.
@phunanon
phunanon / Insitux in Deadline.md
Last active July 6, 2023 05:24
Community-led documentation for using Insitux in the Roblox game Deadline
// ==UserScript==
// @name YouTube budget
// @version 0.1.2
// @description Budgets YT time
// @author Patrick Bowen
// @match https://www.youtube.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant none
// ==/UserScript==
@phunanon
phunanon / TypedPipe.ts
Created August 9, 2022 15:01
Strongly types a pipeline of functions.
const pipe =
<Ctx, Ingress, A, B, C, Egress>(
...args:
| [(x: Ingress, ctx: Ctx) => Promise<Egress>]
| [
(x: Ingress, ctx: Ctx) => Promise<A>,
(x: A, ctx: Ctx) => Promise<Egress>
]
| [
(x: Ingress, ctx: Ctx) => Promise<A>,
(var W 80 H 25
chars ".,-~:;=!*#$@"
PI2 (* 2 PI)
speed-A .05 speed-B .05 speed-I .05 speed-J .05
a 0 b 0)
(var last-ms (time))
(function calculate-screen screen
(let prev-ms last-ms)
@phunanon
phunanon / ttt.ix
Last active April 26, 2022 09:59
Insitux tic-tac-toe
(function check
(let [[a _ x] [_ b] [z _ c]] board)
;Check diagonals
(when (or (= a b c) (= x b z)) (return b))
;Check horizontals and verticals
(let board+T (into board (.. map vec board)))
(when (let [w] (find (.. =) board+T)) w))
(function place n xo
(var! board (set-at [(// n 3) (rem n 3)] xo)))
@phunanon
phunanon / discord-ur.ix
Last active October 1, 2023 21:34
Royal Game of Ur implemented for the Insitux Discord bot FaaS-ish apps
;https://insitux.repl.co/
;https://insitux.github.io/
;https://royalur.net/rules/
;https://royalur.net/dice/
(var cmds "1234567ABCDEFG")
(function roll
(times 4 #(rand-int)))
#Longest file name
find . -name '*.cs' | awk 'function base(f){sub(".*/", "", f); return f;} \
{print length(base($0)), $0}'| sort -nr | head -2
#Longest line
find . -name '*.cs' -print | xargs awk '{print length, $0}' | sort -nr | head -1
#Longest namespace
find . -name '*.cs' -print | xargs awk '{print length, $0}' |sort -nr | grep namespace | head -1
// ==UserScript==
// @name Telegram Dark mode
// @version 0.2
// @match https://web.telegram.org/*
// ==/UserScript==
setTimeout(() => {
var styles = [
["body, .tg_head_split, .im_page_wrap, .im_dialogs_search_field, .im_record_bg",
[["backgroundColor", "#000"], ["color", "#fff"]]],