Skip to content

Instantly share code, notes, and snippets.

import { odd as local_odd } from "./b";
export var counter = 0;
export default function even(n) {
console.log("even has run %s times", counter++);
return n === 0 || local_odd(n - 1);
}
export var counter = 0;
function inc_a(cb){
console.log(counter++);
if(counter < 100) {
setTimeout(inc_a, 0, [ cb ]);
} else {
cb();
}
}
@matthewrobb
matthewrobb / async-templates.js
Created June 27, 2014 15:05
Async YUI Micro Templates
require(traceur.RUNTIME_PATH);
function compile() {
var tpl = Micro.precompile("ello <%= govna %>") + "";
tpl = [
"(async function() {",
tpl.slice(tpl.indexOf("{") + 1, tpl.length - 1),
"})();"
].join("\n");
(function(global){
"use strict";
function fnToBlob(fn) {
var body = (fn && fn.toString()) || "";
return new Blob([ body.slice(body.indexOf("{") + 1, body.length - 1) ]);
}
function createWorker(fn) {
var blobURL = global.URL.createObjectURL(fnToBlob(fn)),
@matthewrobb
matthewrobb / exports.js
Created August 18, 2014 16:09
Universal Module Exports
function createUMEModule(values) {
function __ume__() {
return typeof values.default !== "function" ? values.default : values.default.apply(this, arguments);
}
Object.keys(values).forEach(function(name) {
Object.defineProperty(__ume__, name, {
enumerable: true,
configurable: false,
get: function() {
module.setters = {};
var __es6__import__ = function(name, setter) {
require(name);
var resolvedPath = require.resolve(name);
require.cache[resolvedPath].dependants.push(module);
module.setters[resolvedPath] = setter;
};
module.dependants = [];
const Shade = Shades;
const { Content, Slot } = Shades;
function PageFooter(props) {
return (
<footer>
{props.children}
</footer>
);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
'use strict';
export function free(fn) {
return function() {
return this === undefined ? fn.apply(undefined, arguments) : fn.call(undefined, this, ...arguments);
}
}
export function freeRight(fn) {
return function() {
@matthewrobb
matthewrobb / index.html
Created November 4, 2018 17:16
Mithril + Mobx Mithril + Mobx // source https://jsbin.com/jesebuv
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Mithril + Mobx">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Mithril + Mobx</title>
<script src="https://unpkg.com/mithril/mithril.js"></script>
</head>
<body>