Skip to content

Instantly share code, notes, and snippets.

obsessing over statecharts

Stephen Bussard sbussard

obsessing over statecharts
Block or report user

Report or block sbussard

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View exampleRef.js
import React, { useState } from "react";
let ChildComponent = ({ setRef }) => <div ref={setRef}>{/* content */}</div>;
let ParentComponent = () => {
let [ref, setRef] = useState();
useEffect(() => {
if (ref) {
// whatever you want to use ref for
View dont.jsx
let itemData = [
{ name: 'Chair', price: '$199', id: 'abc123' },
{ name: 'Table', price: '$799', id: 'def456' }
let ItemList = ({ items }) => (
{{ name, price, id }) => (
<li key={id}>{`${name} - ${price}`}</li>
View do.jsx
let itemData = [
{ name: 'Chair', price: '$199', id: 'abc123' },
{ name: 'Table', price: '$799', id: 'def456' }
let Item = ({ description, id }) => <li key={id}>{description}</li>;
let makeProps = ({ name, price, id }) => ({
description: `${name} - ${price}`
View serializeForm.babel.js
// given a form element
// get its children that have a name attribute
// map to { name, value } objects
// reduce individual into one { [name]: value } object
export default formElement => Array.from(formElement.querySelectorAll('[name]'))
.map(({ name, value }) => ({ name, value }))
.reduce((current, item) => ({ ...current, []: item.value }), {});
sbussard /
Last active Sep 30, 2017
skydiving in minecraft with teachcraft
from mcpi import minecraft
from mcpi import block
from minecraftstuff import MinecraftTurtle
from random import randint
import time
import os.path, sys
mc = minecraft.Minecraft.create(address="", name="steve")
block_air = 0
sbussard / aws-cognito-authentication-demo.babel.js
Created Dec 30, 2016
how to authenticate an aws cognito user in the browser
View aws-cognito-authentication-demo.babel.js
import AWS from 'aws-sdk/global';
import S3 from 'aws-sdk/clients/s3';
import {
} from 'amazon-cognito-identity-js';
const REGION = 'some-string-value';
const USER_POOL_ID = 'some-string-value';
sbussard / gist:7796aac53012a40bf26a1d13135c8ee2
Created Aug 26, 2016
A list of things, and something to do
View gist:7796aac53012a40bf26a1d13135c8ee2
Let's say you have a list of items, and something to do with each item. You want to be able to tell the system when to do the thing on an item, and to be able to select what item to do the thing on. For convenience sake, you want to be able to choose the next item or the previous item, or any item in the list (by index of course).
The difference between this and a reducer, for example, is that this system provides an interface for outside interaction.
Right now the class assumes that the list of items are dom elements, children of some parent element, and the task to be applied is toggling a css class. This is already useful for a wide variety of applications, including carousels, image sliders and slide shows. But essentially it only works on the front end.
sbussard /
Last active Jul 12, 2016
push build output to github pages
#!/usr/bin/env bash
git checkout -b _build_staging_
git add -f $BUILD_DIR
git commit -am add_build_ouput
git subtree split --prefix $BUILD_DIR -b gh-pages
git push origin gh-pages -f
git checkout -
You can’t perform that action at this time.