Skip to content

Instantly share code, notes, and snippets.

View jaidetree's full-sized avatar

jaide (formerly eccentric-j) jaidetree

View GitHub Profile
@jaidetree
jaidetree / Markdown Test.md
Created April 15, 2024 17:23
Escape markdown in markdown

Markdown example

The text below is **not expanded**:

```cs
int x = 100;
```
@jaidetree
jaidetree / fsm.fnl
Last active May 27, 2023 05:58
Fennel state machine
;; Usage example
(local my-fsm
(fsm.defmachine
{:name :test-fsm
:state {:idle {}
:pending {:url (p.and
p.str?
p.url?)
:started-at p.number?}
:fulfilled {:response {:data p.assoc-table?}
#!/usr/bin/env node
const { Readable, Writable, PassThrough } = require('stream')
const fs = require('fs')
const path = require('path')
const chokidar = require('chokidar')
const { opendir } = require('fs/promises')
const stream = require('./lib/stream')
const flags = {
--
-- PostgreSQL database dump
--
-- Dumped from database version 14beta1
-- Dumped by pg_dump version 14beta1
--
-- Name: us_births_20002014_ssa; Type: TABLE; Schema: public; Owner: runner
--

image

Notes:

  1. Page title is the index route
  2. Content is the index route
  3. Should match partytime route
  4. Both the server and client builds define the partytime route in the exports
(defmacro with-redefs-async
[bindings & body]
(let [names (take-nth 2 bindings)
vals (take-nth 2 (drop 1 bindings))
orig-val-syms (map (comp gensym #(str % "-orig-val__") name) names)
temp-val-syms (map (comp gensym #(str % "-temp-val__") name) names)
binds (map vector names temp-val-syms)
resets (reverse (map vector names orig-val-syms))
bind-value (fn [[k v]] (list 'set! k v))]
`(let [~@(interleave orig-val-syms names)
@jaidetree
jaidetree / slideshow.cljs
Created September 13, 2021 20:20
First draft of feature combining baconjs stream app state library with a lightweight state machine system
(ns montage.features.slideshow
(:require
[framework.fsm :as fsm]
[framework.features :refer [register]]
[framework.reactor :refer [of-type compose-fx]]
[frmaework.stream :as stream]))
(defn transition-delay
[machine]
(/ (get-in machine [:context :transition-delay]) 2))

Emacs Advice Test

Implementing an advising system for fennel-lang for use in the OS X Spacehammer configuration framework.

Original function definition

(defun some-fun (&rest args)
const todosMachine = Machine({
id: "todos",
context: {
todo: "", // new todo
todos: [],
filter: "all"
},
initial: "loading",
states: {
loading: {
# Node Version Manager
# Implemented as a POSIX-compliant function
# Should work on sh, dash, bash, ksh, zsh
# To use source this file from your bash profile
#
# Implemented by Tim Caswell <tim@creationix.com>
# with much bash help from Matthew Ranney
# "local" warning, quote expansion warning
# shellcheck disable=SC2039,SC2016,SC2001