Skip to content

Instantly share code, notes, and snippets.

View mergebandit's full-sized avatar

Scott Silvi mergebandit

View GitHub Profile
@mergebandit
mergebandit / machine.js
Last active May 25, 2021 14:19
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@mergebandit
mergebandit / machine.js
Last active May 24, 2021 20:18
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@mergebandit
mergebandit / 00.dockerfile.md
Created May 26, 2020 19:56
TIL-Lab49/Docker layers matter. A lot.

I recently came across a Dockerfile that was taking 23 minutes to build that looked something like the following:

... setup

mkdir app
WORKDIR app

RUN npm config set registry "<some npm registry url>"
RUN npm config set some_other_key ""
@mergebandit
mergebandit / clearing-jest-mocks.md
Last active May 26, 2020 19:54
TIL-Lab49/Clearing Jest Mocks

Mocking Services

When mocking services in jest, given:

const someMethodMock = mockService.someMethod as jest.Mock;
beforeEach(() => {
  jest.clearAllMocks()
})
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@mergebandit
mergebandit / ComponentProp.md
Created May 5, 2020 15:58
TIL-Lab49/React-Router

React Router

TIL - under the hood RR uses React.createElement for any inline functions passed to ...} /&gt;. If you don't want your component to fully remount, use ... } /&gt; instead.

@mergebandit
mergebandit / machine.js
Created March 23, 2020 17:09
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
const service = {
addMfa: mfaOpt => {
console.log("service call: addMfa", mfaOpt);
return Promise.resolve(mfaOpt);
},
deleteMfa: mfaOpt => {
console.log("service call: deleteMfa", mfaOpt);
return Promise.resolve(mfaOpt.mfaId);
},
verifyMfa: mfaOpt => {
@mergebandit
mergebandit / machine.js
Last active February 28, 2020 21:02
Generated by XState Viz: https://xstate.js.org/viz
/*
We now have a fully baked delete example where we update context
*/
const service = {
addMfa: (mfaOpt) => Promise.resolve(mfaOpt),
deleteMfa: (mfaOpt) => Promise.resolve(mfaOpt.id)
}
const notificationMachine = Machine({
id: 'notification',
@mergebandit
mergebandit / machine.js
Created February 27, 2020 21:43
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions