Skip to content

Instantly share code, notes, and snippets.

View jLouzado's full-sized avatar

Joel Louzado jLouzado

View GitHub Profile
@tusharmath
tusharmath / patch.js
Last active September 20, 2020 11:54
Virtual DOM library in 500bytes
const typeOf = ob => ob.toString()
const forEach = (fn, l) => typeOf(l) === '[object Object]'
? forEach(k => fn(l[k], k), Object.keys(l))
: Array.from(l).forEach(fn)
export const patch = (elm, node) => {
if(elm === node) return elm
if(typeOf(elm) === '[object Text]') {
elm.textContent = node.textContent
@andymatuschak
andymatuschak / States-v3.md
Last active October 7, 2024 00:46
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@PurpleBooth
PurpleBooth / README-Template.md
Last active October 19, 2024 20:53
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@kevincennis
kevincennis / v8.md
Last active October 9, 2024 02:55
V8 Installation and d8 shell usage

Installing V8 on a Mac

Prerequisites

  • Install Xcode (Avaliable on the Mac App Store)
  • Install Xcode Command Line Tools (Preferences > Downloads)
  • Install depot_tools
    • $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
    • $ nano ~/.zshrc
    • Add path=('/path/to/depot_tools' $path)