Skip to content

Instantly share code, notes, and snippets.

View Jayphen's full-sized avatar
🏠
Working from home

Jayphen Jayphen

🏠
Working from home
View GitHub Profile
@Jayphen
Jayphen / 🙏.spec.js
Created June 24, 2021 15:58
spy on a component but also keep its implementation
// for when you REALLY need to test the props SomeComponent is rendered with (not recommended)
// create a mock that re-implements the default behaviour
// but allows us to spy on the props
jest.mock('components/SomeComponent', () => {
const original = jest.requireActual('components/SomeComponent')
return jest.fn(original.default)
})
@Jayphen
Jayphen / whatev.js
Last active July 6, 2021 19:35
Page tracking in Sapper
// stores/location.ts
import { writable, derived } from "svelte/store";
import { beforeUpdate } from "svelte";
export interface LocationStore {
current: Location | undefined;
previous: Location | undefined;
}
@Jayphen
Jayphen / machine.js
Created May 13, 2020 14:50
Generated by XState Viz: https://xstate.js.org/viz
function deriveStatus(){}
const stateMachine = Machine(
{
id: 'package',
initial: 'loading',
context: { packageProduct: null, items: {}, price: {}, error: null },
on: {
UPDATE_ITEM: {
actions: 'updateItems',
target: 'validating',
@Jayphen
Jayphen / machine.js
Last active February 19, 2020 22:12
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@Jayphen
Jayphen / SketchSystems.spec
Created February 17, 2020 17:58 — forked from flowt-au/SketchSystems.spec
# "Messages" in this example are synonymous with "events" and "listeners"
# "Messages" in this example are synonymous with "events" and "listeners"
Context menu
Hidden
a show yourself message is received -> Showing
Showing
a menu item is clicked -> Emit message
loss of focus is detected -> Hidden
# Send message indicating that menuitem X was clicked
Emit message
@Jayphen
Jayphen / machine.js
Created February 13, 2020 10:16
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@Jayphen
Jayphen / machine.js
Last active February 6, 2020 13:25
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@Jayphen
Jayphen / neovim-plugins-for-js-ts.vimrc
Last active February 5, 2020 18:12
Vim/Neovim plugins for working with JavaScript, TypeScript, React, GraphQL, Markdown
call plug#begin('~/.config/nvim/plugged')
" Navigating files
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim' " fuzzy finder, like cmd-P in VSCode
Plug 'rbgrouleff/bclose.vim' " dependency for ranger
Plug 'francoiscabrol/ranger.vim' " file browser using vim keybindings
" tmux integration
Plug 'christoomey/vim-tmux-navigator' " move between vim and tmux
@Jayphen
Jayphen / machine.js
Last active February 14, 2020 13:47
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@Jayphen
Jayphen / machine.js
Last active January 6, 2020 16:08
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions