Skip to content

Instantly share code, notes, and snippets.

View chrisdone-artificial's full-sized avatar

Chris Done chrisdone-artificial

View GitHub Profile
;; 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)
@chrisdone-artificial
chrisdone-artificial / times.el
Created May 13, 2024 13:35
parsing todoist style times in emacs lisp
(rx-define do-rx
(and word-start
(or
;; today/tomorrow
(and (group-n 1 "tom") (optional "orrow"))
(or (and (group-n 1 "tod") (optional "ay")))
;; next <thing>
(and "next "
(group-n 2 (or "week" "month" "year")))
;; in x <duration>
@chrisdone-artificial
chrisdone-artificial / hell-http.hs
Last active June 30, 2024 21:17
hell-http.hs demo
#!/usr/bin/env hell
-- How to run this:
--
-- socat TCP-LISTEN:8081,fork,reuseaddr,max-children=20 EXEC:"./handler.hell"
main = do
line <- Text.getLine
let content =
Text.concat ["<h1>Hello, World!</h1><p>This is generated by Hell.</p><pre>", line, "</pre>"]
(defcustom albero-width 30
"Width of the albero window.")
(defvar albero-expanded (make-hash-table :test 'equal))
(defun albero-win-config-hook ()
(let ((w (albero-window)))
(when w
(albero-adjust-win w))))
bash-3.2$ ghc T.hs && ./T
[1 of 2] Compiling Main             ( T.hs, T.o ) [Source file changed]
[2 of 2] Linking T [Objects changed]
(a) -> (a)
Bool
Bool
Type error
CallStack (from HasCallStack):
 error, called at T.hs:126:16 in main:Main
@chrisdone-artificial
chrisdone-artificial / 0readme.md
Last active December 12, 2023 10:55
Copy tab title + url as rich text bookmarklet

You need to enable dom.events.asyncClipboard.clipboardItem for it to work, via about:config.