Skip to content

Instantly share code, notes, and snippets.

View tmikeschu's full-sized avatar
💭
black lives matter

Mike Schutte tmikeschu

💭
black lives matter
View GitHub Profile
@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: {
@tmikeschu
tmikeschu / machine.js
Created November 24, 2019 19:22
Generated by XState Viz: https://xstate.js.org/viz
function createUUID() {
var dt = new Date().getTime();
var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
var r = (dt + Math.random() * 16) % 16 | 0;
dt = Math.floor(dt / 16);
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
});
return uuid;
}