Skip to content

Instantly share code, notes, and snippets.

View unscriptable's full-sized avatar
🏔️

John Hann unscriptable

🏔️
View GitHub Profile
@unscriptable
unscriptable / curl-config.js
Created September 4, 2014 15:22
Backbone+curl.js work-around for prawnsalad
curl.config({
paths: {
"backbone": "temp-backbone",
"real-backbone": "path/to/the/real/deal"
}
// the rest of your config goes here :)
});
@unscriptable
unscriptable / curry.js
Last active August 29, 2015 14:04
One way to create a curry function. Currying: http://en.wikipedia.org/wiki/Currying
module.exports = curry;
function curry (f) {
var arity = f.length;
var params = [];
var end = createEnd(f, arity);
return createCurried(params, arity, end);
}
function createEnd (f, arity) {
@unscriptable
unscriptable / developing.md
Last active February 12, 2024 00:35
Early attempt at describing rave development process

Developing apps with rave

The primary goal of RaveJS is to make it amazingly simple to create sophisticated, modern web apps. To help you achieve this, we ask only three things of you:

  1. Use bower and npm to manage your application and all of its third-party libraries and frameworks.
  2. Save all bower and npm metadata by specifying the --save command line flag.
@unscriptable
unscriptable / goals.md
Created May 7, 2014 03:45
Draft of my goals for rave

RaveJS goals

Step 1: Tame module loaders

The first thing that rave must do is simplify module loading: AMD, node, and ES6 modules. There's almost enough metadata in package.json and bower.json files to eliminate loader configuration. We can provide heuristics and conventions to fill-in the missing data.

If a developer wants to add a new capability to an application's loader, she

@unscriptable
unscriptable / wire-cram.js
Created March 14, 2014 03:09
wire-cram plugin
/** @license MIT License (c) copyright B Cavalier & J Hann */
/**
* wire/cram/builder plugin
* Builder plugin for cram
* https://github.com/cujojs/cram
*
* wire is part of the cujo.js family of libraries (http://cujojs.com/)
*
* Licensed under the MIT License at:
@unscriptable
unscriptable / config.js
Last active December 21, 2015 13:09
possible way to specify legacy exports and dependencies
paths: {
curl: '../src/curl',
// you can use a path
test1: {
location: 'stuff/plain_old.js',
config: {
loader: 'curl/loader/legacy',
exports: 'testDomain.foo.bar' // required!
}
}
@unscriptable
unscriptable / Array.from.js
Last active February 12, 2024 00:35
ES6 WTF Array.from(). We can't do some seemingly simple things with the generic Array.from() as it is specified today.
// IIUC, the proposed spec for Array.from at http://people.mozilla.org/~jorendorff/es6-draft.html#sec-15.4.2.4
// is generic, which means the function can be applied to other constructors. Like this, for instance:
//
// var myString = Array.from.call(String, arrayOfChars);
//
// It does this by calling the constructor of `this` and passing the length of the argument (arg.length).
// I tried shimming it here: https://github.com/cujojs/poly/blob/dev/array-es6.js#L44-L54
// Unfortunately, this yields some interesting results...
// Convert an array of bytes or characters to a string:
@unscriptable
unscriptable / after_using_aop.js
Last active February 12, 2024 00:35
How AOP simplified some code when writing a prototype module loader. Promises would make this code even cleaner and saner. FWIW, a Promises/A+ implementation is the second thing that gets loaded by this code! If promises were native to Javascript, I'd definitely be using them instead of callbacks.
// The following two functions are composed from simpler functions using AOP.
// getShim(callback) is the entry point. The composed functions still
// require lots of work to test, but since they're composed of simpler,
// testable functions, we can be more confident in our test coverage
// and test validity.
/**
* Gets the shim and calls back. Uses before advice to modify the getShim
* function to instruct any further calls to just queue callbacks.
* @function
// `myAwesomeNamespace.declare` is mapped from the outside world to `define` inside this iife
(function (define) {
// modules go here
define('foo' function (require) {
return 'foo';
});
define('bar' function (require) {
@unscriptable
unscriptable / 000-title.md
Last active February 12, 2024 00:36
"slides" for Boston Javascript Meetup Group, "The future of JS modules", April 4, 2013