Skip to content

Instantly share code, notes, and snippets.

@iammerrick
iammerrick / app.js
Created Jul 25, 2019
Coordinate character states with state machines allowing for async transitions.
View app.js
const app = new PIXI.Application({ transparent: true });
const { Machine, interpret, send, sendParent, assign } = window.XState;
document.body.appendChild(app.view);
// Invoked child machine
const CharacterMachine = a => {
return Machine({
id: "Kolohe",
initial: "active",
View url.js
console.log('Loaded by a url!');
@iammerrick
iammerrick / spy.js
Last active Jan 11, 2019
Determine if a user called "then" on registration promise.
View spy.js
const spyInstance = (on, replace, spy) => {
const _real = on[replace];
on[replace] = function(...args) {
const ret = _real.apply(this, args);
const newRet = spy(args, ret, this);
if (newRet) return newRet;
return ret;
};
};
View concise.js
requestIdleCallback(function tick() {
requestIdleCallback(tick);
});
@iammerrick
iammerrick / PanGesture.js
Last active Aug 31, 2018
Panning Mobile Web
View PanGesture.js
import React from 'react';
import ReactDOM from 'react-dom';
import { getPointRelativeToElement, getDistanceBetweenPoints } from 'utilities/geometry';
const THRESHOLD = 10;
const pointFromTouch = (touch) => ({ x: touch.clientX, y: touch.clientY });
class PanGesture extends React.Component {
constructor() {
View .vimrc
set nocompatible
call plug#begin('~/.vim/plugged')
Plug 'chriskempson/base16-vim'
Plug 'tpope/vim-surround'
Plug 'scrooloose/nerdtree'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'pangloss/vim-javascript'
Plug 'Valloric/YouCompleteMe', { 'do': './install.py --tern-completer' }
Plug 'SirVer/ultisnips'
@iammerrick
iammerrick / NestedRoutes.js
Created Feb 23, 2017
React Router 4 is fundamentally different because it allows for nested routes that rely on parent context. This facilitates recursive routes and other B-E-A-UTIFUL things.
View NestedRoutes.js
import React from 'react'
import {
BrowserRouter as Router,
Route,
Link
} from 'react-router-dom'
const BasicExample = () => (
<Router>
<div>
View DynamicList+Height.js
import React, { Component } from 'react';
import {List, CellMeasurer} from 'react-virtualized';
import moment from 'moment';
const days = 3000;
const today = days / 2;
const daysToShow = 3;
const height = 180;
const rowRenderer = ({
View texts.messageformat
You will receive {numberOfTexts, plural,
=0 {no more texts.}
=1 {{duration, plural,
=0 {1 more text.}
=1 {1 text tomorrow.}
other {1 text within # days.}
}}
other {{duration, plural,
=0 {{numberOfTexts} more texts.}
=1 {{numberOfTexts} texts tomorrow.}
You can’t perform that action at this time.