Skip to content

Instantly share code, notes, and snippets.

View chrisdone-artificial's full-sized avatar

Chris Done chrisdone-artificial

View GitHub Profile
@chrisdone-artificial
chrisdone-artificial / default.conf
Last active December 10, 2024 11:02
keyd - disable super
[ids]
*
[main]
leftmeta = layer(mymeta)
[mymeta:C]
1 = M-1
2 = M-2
@chrisdone-artificial
chrisdone-artificial / cps.hs
Created November 19, 2024 21:34
CPS'd eval
eval :: env -> Term env t -> t
eval erm trm = eval erm trm id where
eval :: env -> Term env t -> (t -> r) -> r
eval env (Var v) k = k (lookp v env)
eval env (Lam e) k = k (\x -> eval (env, x) e id)
eval env (App e1 e2) k =
eval env e1 $ \f ->
eval env e2 $ \x ->
k (f x)
eval _env (Lit a) k = k a
@chrisdone-artificial
chrisdone-artificial / 0readme.md
Last active November 19, 2024 21:22
Ackermann in Hell vs GHCi

GHCi:

ghci> main
4093
it :: ()
(4.05 secs, 3,864,385,304 bytes)

Hell:

@chrisdone-artificial
chrisdone-artificial / example.hs
Last active November 19, 2024 15:36
variants - total matching
type A = Variant (ConsL "Age" Int (ConsL "Name" Text NilL))
demo :: A
demo = LeftV 1
demo' :: A
demo' = RightV (LeftV "x")
match :: String
match = runAccessor demo $ ConsA show $ ConsA Text.unpack NilA
@chrisdone-artificial
chrisdone-artificial / reflect-cron.hell.hs
Created November 15, 2024 13:51
reflect cron hell script
root@fsn1-cd-1:~# cat /root/brossa-cd/scripts/reflect-cron.hell
#!/usr/bin/env hell
-- assumes: jq, docker
main = do
input <- Text.readProcessStdout_ $ Process.proc "docker" ["ps","--format","json"]
let lines = Text.lines input
Monad.forM_ lines \json -> do
labels' <- Main.jq json [".Labels","-r"]
;; Initial version copied from Pawel Szulc
(define-derived-mode tla-mode fundamental-mode "tla"
"Major Mode For Editing TLA language code."
(setq font-lock-defaults '(tla-highlights))
(font-lock-add-keywords nil '(("\\\\\\*.+" . font-lock-comment-face)))
(font-lock-add-keywords nil '(("====.+" . font-lock-doc-face)))
(font-lock-add-keywords nil '(("----.+" . font-lock-doc-face)))
(font-lock-add-keywords nil '(("(\\*.+" . font-lock-doc-face)))
(setq-local comment-start "\\* ")
@chrisdone-artificial
chrisdone-artificial / 0readme.md
Last active November 1, 2024 07:48
fast-tags vs hasktags vs ghc-tags

⚠️ Testing Emacs tags generation specifically. I've updated one which fast-tags was lacking -e.

I thought I'd upgrade my hasktags to fast-tags, but discovered that it's not much faster. The much bigger saving is to pipe fd into it rather than letting either fast-tags/hasktags do its own recursive directory searching. They appear to be egregiously slow in comparison to fd.

I added ghc-tags, and that's the slowest for recursive cold run. It's the fastest on a warm run with fd.

Confirmation that they're all producing outputs of roughly similar size.

#!/usr/bin/env hell
-- Check all the prefixes and permitted delimiters against
-- <https://www.conventionalcommits.org/en/v1.0.0/>
main = do
title <- Environment.getEnv "PR_TITLE"
if List.or $
List.map (\prefix ->
ghci> runReader (runParserT (do a <- local (+1) ask; b <- ask; pure (a,b)) "" "") 0
Right (1,0)