Skip to content

Instantly share code, notes, and snippets.

@fiddlerwoaroof
fiddlerwoaroof / hoot.md
Created April 9, 2024 05:25
Another Hoot

Seeing if this is still a thing

Testing

@fiddlerwoaroof
fiddlerwoaroof / README.md
Created December 14, 2021 23:29
JSON narrowing commands for emacs

If you load this in emacs and open a file with a JSON buffer, the command M-x fwoar/dive will let you type a key and replace the contents of the buffer with either the value of the corresponding key (if the JSON value of the buffer is an object) or an array of the corresponding value for each object in an array (if the JSON value of the buffer is an array). M-x fwoar/return will pop the most recently used key off the stack and replace the buffer contents with the corresponding contents of the original JSON object.

This is mainly a prototype, but it's already useful for quickly zooming in on large JSON documents.

@fiddlerwoaroof
fiddlerwoaroof / README.md
Last active October 1, 2021 04:08
Dynamic state transition graphs from an XState machine

Some code for generating graphs from unit tests runs or other contexts where you want to visualize the dynamic behavior of an XState machine.

node src/address-book.js config |
  unflatten |
  dot -Gsize=15,15\! -Gdpi=100 -Tpng > graph.png

graph

First State&
Animation
AnimationRunning
animationDone -> AnimationDone
AnimationDone
refresh -> Animation
Screen
Idle
animationDone -> Ready
Ready
@fiddlerwoaroof
fiddlerwoaroof / machine.js
Last active January 27, 2021 03:50
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@fiddlerwoaroof
fiddlerwoaroof / hnparse.js
Created November 3, 2020 09:37
Reactive HTML parsing
const ch = require("cheerio");
const fetch = require("node-fetch").default;
const getLeadingNum = (v) => parseInt(v.split(" ")[0], 10);
function HNParser(html) {
if (! (this instanceof HNParser)) {
return new HNParser(html);
}
this.html = html;
@fiddlerwoaroof
fiddlerwoaroof / Tree.java
Created September 22, 2020 22:42
Tree Encoding
package co.fwoar.java.tree;
import java.util.ArrayDeque;
import java.util.Deque;
public class Main {
static class Tree {
public int val;
public Tree left;
public Tree right;
@fiddlerwoaroof
fiddlerwoaroof / .gitignore
Last active September 21, 2021 19:28
Minimal Nix Docker
*.tar.gz
.sentinel.*
(defun fwoar--find-lisp-project-root (dir-name)
(let ((root (locate-dominating-file dir-name
(lambda (n)
(directory-files n nil "^[^.#][^#]*[.]asd$")))))
(when root
(cons 'lisp root))))
(cl-defmethod project-roots ((project (head lisp)))
(list (cdr project)))