Instantly share code, notes, and snippets.

View proxy-store.mjs
const state = {}
const listeners = []
let aid
const handler = {
set: function setter (obj, prop, value) {
let old = obj[prop]
if (old !== value) {
obj[prop] = value
if (aid) {
window.cancelAnimationFrame(aid)
View simple-store.mjs
var listeners = []
var state = {}
var noop = x => x
function subscribe (fn) {
listeners.push(fn)
}
function unsubscribe (fn) {
listeners.splice(listeners.indexOf(fn), 1)
View Server.py
# -*- coding: utf-8 -*-
#test on python 3.4 ,python of lower version has different module organization.
import http.server
from http.server import HTTPServer, BaseHTTPRequestHandler
import socketserver
PORT = 8080
Handler = http.server.SimpleHTTPRequestHandler
View config.json
{
"base": 18,
"scale": {
"ratio": "perfectFourth",
"steps": 8
},
"colors": {
"primary": [
{
"label": "transparent",
View component.js
var preact = require('preact')
module.exports = function Component (name, obj) {
name = name || 'F'
obj = obj || {}
var fn = function () { preact.Component.call(this) }
Object.defineProperty(fn, 'name', { value: name })
fn.prototype = Object.create(preact.Component.prototype)
fn.prototype = Object.assign(fn.prototype, obj)
if (obj.getDefaultProps &&
(typeof obj.getDefaultProps === 'function')) {
View component.js
var html = require('bel')
var morph = require('nanomorph')
var inWindow = require('in-window')
var onload = require('on-load')
module.exports = function Component (options) {
options = options || {}
var template = options.template
var should = options.should || function () { return true }
var added = options.added
View ro-sham-beaux.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>👊✋✌️</title>
<style>
/* RESET */
* {
margin: 0;
padding: 0;
View build.sh
#!/usr/bin/env node
var path = require('path')
var parse = require('minimist')
var browserify = require('browserify')
var args = parse(process.argv.slice(2))
var entries = args._
var output = args.o || args.output
var main = args.m || args.main
var url = args.url || output
View remove.js
function remove (state, data) {
var active = state.active.concat()
var i = 0
var l = active.length
var item
for (i; i<l; i++) {
item = active[i]
if (item.id === data.id) {
break
}