Skip to content

Instantly share code, notes, and snippets.

View ShMcK's full-sized avatar

Shawn McKay ShMcK

View GitHub Profile
@ShMcK
ShMcK / StableDiffusionUI_SageMaker.ipynb
Last active April 12, 2024 16:45
Config for running Automatic1111 Stable Diffusion WebUI on an AWS SageMaker Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ShMcK
ShMcK / machine.js
Created September 5, 2019 04:08
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@ShMcK
ShMcK / machine.js
Created August 26, 2019 00:00
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@ShMcK
ShMcK / xstateful-react-state-views.jsx
Created September 23, 2018 22:02
Conditionally rendered state components
<Display>
<Time />
<ClockMachine.State
is="AlarmGroup.Ringing"
render={() => <AlarmSetIndicator ringing />}
/>
<ClockMachine.State
is={['AlarmGroup.AlarmSet', 'AlarmGroup.Snoozing']}
render={() => <AlarmSetIndicator />}
/>
@ShMcK
ShMcK / xstateful-react-provider.jsx
Last active September 23, 2018 21:58
xstateful-react-provider
import * as React from 'react'
import { Display, Time } from './components'
import ClockMachine from './Machine'
export default class Clock extends React.Component {
render() {
return (
<ClockMachine.Provider>
<ClockMachine.Control onDidMount={this.init}>
@ShMcK
ShMcK / xstateful-react-machine.js
Created September 23, 2018 21:56
xstateful-react machine setup
import { Machine } from 'xstate'
import { createStatefulMachine } from '@avaragado/xstateful'
import { createReactMachine } from '@avaragado/xstateful-react'
import machineState from './state.json'
// a stateless machine
const machine = Machine(machineState)
// a stateful machine
const xsf = createStatefulMachine({ machine })
@ShMcK
ShMcK / alarm-xstate.json
Created September 23, 2018 21:53
Alarm Clock XState Config
{
"initial": "Normal",
"states": {
"Normal": {
"on": {
"ALARM_ON": "AlarmSet"
}
},
"AlarmGroup": {
"initial": "AlarmSet",
@ShMcK
ShMcK / decouple-state-as-prop.js
Created July 23, 2018 14:33
decouple-state-as-prop
import { withStatechart } from "react-automata"
import alarmMachine from "./alarmMachine"
const AlarmClock = ({ machineState }) => {
switch (machineState.value) {
case "Snoozing":
return <Clock />
case "Ringing":
return <Clock ringing />
default:
@ShMcK
ShMcK / scxml-example.scxml
Created July 22, 2018 16:30
scxml example
<parallel id="p">
<transition event="done.state.p" target="someOtherState"/>
<state id="S1" initial="S11">
<state id="S11">
<transition event="e4" target="S12"/>
</state>
<state id="S12">
<transition event="e1" target="S1Final"/>
@ShMcK
ShMcK / testStatechart.js
Created July 20, 2018 04:13
testStatechart
import { testStatechart } from 'react-automata'
import alarmChart from './alarmChart'
import AlarmClock from './AlarmClock'
test('run all tests', () => {
testStatechart({
statechart: alarmChart,
}, AlarmClock)
})