Skip to content

Instantly share code, notes, and snippets.

View kyleshevlin's full-sized avatar

Kyle Shevlin kyleshevlin

View GitHub Profile
@kyleshevlin
kyleshevlin / machine.js
Created December 22, 2019 21:04
Generated by XState Viz: https://xstate.js.org/viz
const filterSubStates = filterName => ({
initial: "disabled",
states: {
disabled: {
on: { [`ENABLE_${filterName}`]: "enabled" }
},
enabled: {
initial: "asc",
on: {
[`DISABLE_${filterName}`]: "disabled"
@kyleshevlin
kyleshevlin / machine.js
Created December 22, 2019 20:54
Generated by XState Viz: https://xstate.js.org/viz
const filterSubStates = filterName => ({
initial: "disabled",
states: {
disabled: {
on: { [`ENABLE_${filterName}`]: "enabled" }
},
enabled: {
initial: "asc",
on: { [`DISABLE_${filterName}`]: "disabled" },
states: {
@kyleshevlin
kyleshevlin / enumerateDontBooleanate.js
Created December 11, 2019 20:09
enumerateDontBooleanate.js
const isLoading = true // Great, we know we know something is loading
const isLoading = false // We only know we're not loading, ANYTHING ELSE IS POSSIBLE
// In symbolic logic, this is referred to as a _modus tollens_
// the negation of an assertion only tells us that _that_ particular thing
// in the universe is negated, it conveys _no_ logical information about anything else
// Ex. If I have a Mtn Dew in front of me, I will drink it.
// I do _not_ have a Mtn Dew in front of me, therefore I can't assert anything
// about anything I am doing other than _not_ drinking a Mtn Dew
@kyleshevlin
kyleshevlin / machine.js
Created December 5, 2019 22:36
Generated by XState Viz: https://xstate.js.org/viz
const masterView = Machine({
id: 'masterView',
initial: 'idle',
context: {
assetsSelected: 0
},
states: {
idle: {},
selection: {
on: {
@kyleshevlin
kyleshevlin / machine.js
Created December 4, 2019 23:56
Generated by XState Viz: https://xstate.js.org/viz
const assetManagerViewMachine = Machine(
{
id: "assetManagerView",
initial: "closed",
context: {
assetsSelected: 0
},
states: {
closed: {
on: {
@kyleshevlin
kyleshevlin / machine.js
Created December 4, 2019 23:41
Generated by XState Viz: https://xstate.js.org/viz
const assetManagerViewMachine = Machine({
id: 'assetManagerView',
initial: 'closed',
states: {
closed: {
on: {
OPEN_SIDE: 'side',
OPEN_MASTER: 'master'
}
},
@kyleshevlin
kyleshevlin / function.sh
Created December 2, 2019 19:23
List all local git branches and sort by date of the last commit
function blist () {
git br --sort=-committerdate --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:green)%(committerdate:relative)%(color:reset) - %(authorname)'
}
@kyleshevlin
kyleshevlin / machine.js
Created November 27, 2019 00:17
Generated by XState Viz: https://xstate.js.org/viz
const toastMachine = Machine({
id: 'toast',
initial: 'poweredOff',
states: {
poweredOff: {
on: { POWER_ON: 'poweredOn.hist' }
},
poweredOn: {
on: { POWER_OFF: 'poweredOff' },
type: 'parallel',
@kyleshevlin
kyleshevlin / machine.js
Created November 22, 2019 04:28
Generated by XState Viz: https://xstate.js.org/viz
const ifAtFirstYouDontSucceed = Machine({
id: 'tryTryAgain',
initial: 'idle',
context: {
tries: 0
},
states: {
idle: {
on: { TRY: 'trying' }
},
@kyleshevlin
kyleshevlin / machine.js
Created November 20, 2019 03:07
Generated by XState Viz: https://xstate.js.org/viz
const lightBulbMachine = Machine({
id: 'lightBulb',
initial: 'unlit',
states: {
unlit: {
on: {
BREAK: 'broken',
TOGGLE: 'lit'
}
},