Skip to content

Instantly share code, notes, and snippets.

@guybedford
guybedford / server.js
Last active December 26, 2015 21:09
SPDY asset server API
var spdy = require('spdy'); // node-spdy
var spdyAssetServer = require('spdy-asset-server'); // the proposed spdy-asset-server library
// given a url, provide the asset response stream
// custom serving function allows dynamic + static assets
var assetServer = new spdyAssetServer(function(url, stream) {
if (url == 'style/style.css')
stream.pipe(fs.createReadStream('/local/file/system/style.css'));
else if (url == 'style/style.less')
stream.pipe(less.createEncodingStream(fs.createReadStream('/local/file/system/style.less')));
(function() {
window.Loader = function(parent, options) {
this.global = options.global || {};
this.baseURL = options.baseURL || parent.baseUrl;
this._parent = parent || null;
this._strict = options.strict || false;
this.normalize = options.normalize || parent.normalize;
this.resolve = options.resolve || parent.resolve;
@guybedford
guybedford / gist:4604409
Last active December 11, 2015 12:58 — forked from lightjs/gist:4604334
var GETSET = {
_extend: {
properties: 'IGNORE'
},
addProperty: function(p, startVal) {
var curVal = startVal;
this[p] = function(val) {
if (arguments.length)
curVal = val;
else
// meta, packages deep
function getSharedProperties(configA, configB) {
var bKeys = Object.keys(configB);
return Object.keys(configA).filter(function(p) {
return bKeys.indexOf(p) != -1;
});
}
function detectMetaConflict(metaA, metaB) {
@guybedford
guybedford / extension-register.js
Last active September 27, 2015 15:17
System.register ES6 form loader hooks implementation for https://github.com/google/traceur-compiler/issues/953#issuecomment-40969512
// our side table
// registry = { deps, declare ; normalizedDeps, depMap ; execute, exports }
// Lifecycle:
// 1. before instantiate, just deps, declare
// 2. after instantiate, normalizedDeps and depMap
// 3. after linking, execute, exports
// 4. after partial tree execution just exports
// 5. after full tree execution, removed from registry
var registry = {};
#!/bin/bash
# Download Drush v3 from D.O and make it work on `drush` (OS X / Linux / *nix)
# Written by stemount, adapted by KarenS
# Last updated by Drupalise IT (http://drupalise.it) on 13 Sep 2010
# Update user
echo "Drush is now downloading via HTTP"
# move to home dir
@guybedford
guybedford / gist:a1155602a0ff41b22359
Last active August 29, 2015 14:10
Interpreting CommonJS modules in ES6 environments

Question - should import {fs} from 'fs' be supported for CommonJS module loading from ES6?

If it is to be supported, we would effectively define the fs module object in the ES6 registry to look something like the following:

var fs = require('fs');
var _fs = {};
Object.keys(fs).forEach((p) => _fs[p] = fs[p]);
_fs.default = fs;
@guybedford
guybedford / build-exclusions.js
Created July 11, 2014 18:54
System build exclusions
var firstTree, secondTree;
builder.trace('app/first', config)
.then(function(trace) {
firstTree = trace.tree;
return builder.trace('app/second');
})
.then(function(trace) {
secondTree = trace.tree;
return builder.subtractTrees(firstTree, secondTree);
@guybedford
guybedford / build-tool-concept.md
Last active August 29, 2015 13:58
Build Tool

Goals

  1. Support source maps
  2. Plugin-based compilation
  3. Perform compilation in memory, not file system.

Key Innovation: Use source map information to determine which changed files result in which files having to be rebuilt.

Source Maps and this innovation concept is why I'm even considering polluting this noisy space even further!