Skip to content

Instantly share code, notes, and snippets.

View cmlarsen's full-sized avatar

Caleb Larsen cmlarsen

  • Deep in the woods of Michigan
View GitHub Profile
@cmlarsen
cmlarsen / machine.js
Last active March 23, 2021 15:17
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@cmlarsen
cmlarsen / today
Last active November 16, 2020 17:16
Today script for Todoist
#!/bin/bash
WHITE="\033[1;37m"
BROWN="\033[0;33m"
RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
PURPLE="\033[0;35m"
CYAN="\033[0;36m"
@cmlarsen
cmlarsen / StupidSimpleSharedState.js
Last active July 6, 2020 20:22
A bare bones shared state system using a pub/sub pattern and Reacts underlying useState hooks. See example in this Repl: https://repl.it/@cmlarsen/SharedState
import React, {useState, useEffect, useRef, useCallback, useMemo} from 'react'
import * as ReactDOM from 'react-dom'
import {get, set} from 'lodash'
//The guts of the pub/sub system
const sharedState = {
//Holds the state, this is mutable, but could easily be locked down
state: {},
//holds the watchers.
watchers:{},
@cmlarsen
cmlarsen / StupidSimpleSharedState.js
Created July 6, 2020 19:14
A bare bones shared state system using a pub/sub pattern and Reacts underlying useState hooks.
import React, {useState, useEffect, useRef, useCallback, useMemo} from 'react'
import * as ReactDOM from 'react-dom'
import {get, set} from 'lodash'
//The guts of the pub/sub system
const sharedState = {
state: {},
watchers:{},
watch (bitOfState, callback) {
if (!this.watchers[bitOfState]) {
@cmlarsen
cmlarsen / gist:82b688a431f8caed1285
Last active August 29, 2015 14:11
Garage Browse Build List
/*
*
* categoryOrder is the sort order for the item within the category
*/
var myJson = [
{
"userName" : "Wile E. Coyote",
"build" : {
"id" : 1234567890,
"name" : "Cheesy Rider",