Skip to content

Instantly share code, notes, and snippets.

View jamestthompson3's full-sized avatar

jamestthompson3

View GitHub Profile
@jamestthompson3
jamestthompson3 / tilemap.html
Last active September 5, 2023 22:13
render 2D tilemap WebGL
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=yes"
/>
<style>
canvas {
const terminal = {}
const input = {}
const terminalText = {}
const showmode = {}
const text = {}
const col = {}
const TEXT_CURSOR = textContent => `<span id="cursor">${textContent}</span>`;
let cursor;
@jamestthompson3
jamestthompson3 / recursiveWatch.js
Created April 3, 2020 13:39
Recursively watch files in a project and restart process on change.
"use strict";
const fs = require("fs");
const cluster = require("cluster");
/*
* GET IT ALL RUNNING
*/
if (cluster.isMaster) {
cluster.setupMaster({
@jamestthompson3
jamestthompson3 / machine.js
Last active January 28, 2020 10:00
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jamestthompson3
jamestthompson3 / machine.js
Last active January 23, 2020 16:22
Generated by XState Viz: https://xstate.js.org/viz
const achievementsStates = {
id: 'achievements-select',
initial: 'ACHIEVEMENTS_IDLE',
states: {
ACHIEVEMENTS_IDLE: {},
ACHIEVEMENTS_PENDING: {
meta: {match: 'ACHIEVEMENTS_PENDING'},
invoke: {
src: 'fetchAchievements',
onDone: 'ACHIEVEMENTS_SUCCESS',
@jamestthompson3
jamestthompson3 / machine.js
Last active January 22, 2020 13:25
Generated by XState Viz: https://xstate.js.org/viz
const achievementsStates = {
initial: 'idle',
states: {
idle: {},
ACHIEVEMENTS_PENDING: {
invoke: {
src: 'fetchAchievements',
onDone: 'ACHIEVEMENTS_SUCCESS',
onError: 'ACHIEVEMENTS_ERROR'
}
@jamestthompson3
jamestthompson3 / voronoi.js
Last active October 29, 2018 18:08
React Voronoi
import * as React from "react"
import { voronoi } from "@vx/voronoi"
class Voronoi extends React.Component {
tile = null
componentDidMount() {
this.renderPoints()
}
export const AddPopup = ({ open, onChange, handleSubmit, text, closeModal }) => (
<Popup
open={open}
onSubmit={e => {
e.preventDefault()
handleSubmit().then(() => closeModal())
}}
>
<StyledInput autoFocus value={text} onChange={onChange} />
<Button style={{ float: 'right' }} type="submit">
const LikesList = ({
user: { likes, user },
updateFunctions: { addLike, deleteLike },
isOpen,
text,
handleChange,
toggleModal
}) => (
<Fragment>
<ListHeader>
const Likes = compose(
modalHandler,
textHandler,
getContext({ updateFunctions: PropTypes.object, user: PropTypes.object })
)(LikesList)