Skip to content

Instantly share code, notes, and snippets.

View jongrim's full-sized avatar

Jon Grim jongrim

View GitHub Profile
@jongrim
jongrim / machine.js
Last active October 27, 2020 19:57
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jongrim
jongrim / machine.js
Last active October 27, 2020 19:52
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
Cases
New
assign to self -> Assigned
assign to other -> Assigned
delete -> Delete
add note -> New
fraud tagging -> New
custom status -> New
Assigned
disposition -> Closed
@jongrim
jongrim / machine.js
Last active March 12, 2020 17:51
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
import { renderHook } from '@testing-library/react-hooks';
import useInterval from './useInterval';
const cb = jest.fn();
test('useInterval waits for the delay to call the callback', () => {
jest.useFakeTimers();
renderHook(() => useInterval(cb, 1000));
jest.advanceTimersByTime(1200);
expect(cb).toHaveBeenCalledTimes(1);
/**
* Taken from https://overreacted.io/making-setinterval-declarative-with-react-hooks/
* and converted to TypeScript
*/
import { useEffect, useRef } from 'react';
function useInterval(callback: Function, delay?: number | null) {
const savedCallback = useRef<Function>();
// Remember the latest callback.
@jongrim
jongrim / machine.js
Last active November 20, 2019 15:46
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jongrim
jongrim / machine.js
Created November 11, 2019 04:12
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jongrim
jongrim / SketchSystems.spec
Created November 8, 2019 02:16
Traffic light
Traffic light
Red*
timeout -> Green
Green
timeout -> Yellow
Yellow
timeout -> Red
@jongrim
jongrim / make-branch.md
Last active October 14, 2019 21:33
Simple function to make and push a branch

Add this to your .zshrc file

make-branch() {
  git checkout -b $1
  git push origin $1
}

Then use it: