Skip to content

Instantly share code, notes, and snippets.

View tmikeschu's full-sized avatar

Mike Schutte tmikeschu

View GitHub Profile
e |--0-0-0-0h2p0---0-----------------------
B |--3-3-3-------3---3-----2---------3-----
A |--0-0-0-------------------0---------0---
D |----------------------------------------
A |----------------------0-------0---------
D |0-------------------------------3-----3-
@tmikeschu
tmikeschu / react.js
Created March 6, 2023 14:37
Mocking Chakra's menu for slightly better performance.
// __mocks__/@chakra-ui/react.js
const React = require('react');
const actual = jest.requireActual('@chakra-ui/react');
const MenuContext = React.createContext({});
const useMenuItem = props => {
const {
onMouseEnter: onMouseEnterProp,
@tmikeschu
tmikeschu / machine.js
Last active May 3, 2021 20:06
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@tmikeschu
tmikeschu / machine.js
Created June 11, 2020 17:13
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
const isBrowser = typeof window !== "undefined"
// We check for event support via functions in case they've been mocked by a testing suite.
export const supportsPointerEvents = () =>
isBrowser && window.onpointerdown === null
export const supportsTouchEvents = () =>
isBrowser && window.ontouchstart === null
export const supportsMouseEvents = () =>
isBrowser && window.onmousedown === null
@tmikeschu
tmikeschu / machine.js
Created March 26, 2020 21:04
Generated by XState Viz: https://xstate.js.org/viz
const DATES_TAB = {
target: "dates",
actions: ["sendGAEvent"],
}
Machine({
id: "app",
initial: "fetchAttendee",
context: {
lastScreen: "schedule",
friendId: undefined,
@tmikeschu
tmikeschu / machine.js
Created February 4, 2020 22:09
Generated by XState Viz: https://xstate.js.org/viz
const BOOK_OR_REVIEW = { BOOK: '#schedule', DATES: '#dates' };
const machine = Machine({
id: 'app',
initial: 'fetchAttendee',
context: {
lastScreen: 'schedule',
friendId: undefined,
friendTimeId: undefined,
someoneNewTimes: new Set(),
@tmikeschu
tmikeschu / machine.js
Created December 29, 2019 17:31
Generated by XState Viz: https://xstate.js.org/viz
const machineConfig = {
initial: "idle",
id: "main",
context: {
initialTime: 0,
currentTime: 0,
notificationTimes: []
},
states: {
idle: {
@tmikeschu
tmikeschu / machine.js
Created December 23, 2019 01:07
Generated by XState Viz: https://xstate.js.org/viz
const BOOK_OR_REVIEW = { BOOK: '#schedule', DATES: '#dates' };
const appMachine = Machine(
{
id: 'app',
initial: 'codeOfConduct',
context: {
lastScreen: 'schedule',
selectedAttendee: undefined,
},
states: {
@tmikeschu
tmikeschu / machine.js
Last active December 22, 2019 04:57
Generated by XState Viz: https://xstate.js.org/viz
const BOOK_OR_REVIEW = { BOOK: '#schedule', DATES: '#dates' };
const routesMachine = Machine(
{
id: 'routes',
initial: 'codeOfConduct',
context: {
lastScreen: '',
},
states: {