Skip to content

Instantly share code, notes, and snippets.

@akbr
akbr / machine.js
Last active February 16, 2020 19:32
Generated by XState Viz: https://xstate.js.org/viz
const spawnFetch = assign({
fetchService: () => spawn(false, "fetch")
});
const toCurrent = () => send({type:"get"}, {to: "fetch"});
const update = assign((ctx, {data}) => ({
...ctx,
...data
}));
@akbr
akbr / gist:10663723
Last active July 8, 2016 10:48
gulp + browserify
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var libs = ["underscore", "jquery"];
gulp.task("vendor", function () {
var b = browserify();
libs.forEach(function (lib) {
// Important: You must serve your pages as XHTML for this shim to work,
// otherwise namespaced attributes and elements will get messed up.
Object.defineProperty(SVGElement.prototype, 'innerHTML', {
get: function() {
var $child, $node, $temp, _i, _len, _ref;
$temp = document.createElement('div');
$node = this.cloneNode(true);
_ref = $node.children;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
$child = _ref[_i];
/*
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace
so it's better encapsulated. Now you can have multiple random number generators
and they won't stomp all over eachother's state.
If you want to use this as a substitute for Math.random(), use the random()
method like so:
var m = new MersenneTwister();
@akbr
akbr / test.md
Last active December 15, 2015 17:19
Junkification!

Blah blah blah! asgasg

Inline-style: alt text