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
// | |
// Two kinds of animals: dogs and cats | |
// | |
// I want greet and leave to be defined such that there are four | |
// different behaviors corresponding to each combination of dog and | |
// cat | |
// | |
class Animal { | |
receive_operation(operation) { | |
console.log("the animal is unresponsive"); |
import java.lang.RuntimeException | |
import java.util.Arrays | |
object VariantWorld2 { | |
class Greet : World.Visitor { | |
fun visit(subject: Dog, arg: String): String { | |
return "$arg is greeted" | |
} | |
fun visit(subject: Cat, arg: String): String { |
(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))) |
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; |
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; |
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) |
First State& | |
Animation | |
AnimationRunning | |
animationDone -> AnimationDone | |
AnimationDone | |
refresh -> Animation | |
Screen | |
Idle | |
animationDone -> Ready | |
Ready |
*.tar.gz | |
.sentinel.* |
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.