Skip to content

Instantly share code, notes, and snippets.

View mzgoddard's full-sized avatar

Z Goddard mzgoddard

  • Bocoup
  • Boston, MA
View GitHub Profile
copy: {
inplace: {
files: [{
expand: true,
cwd: 'src',
src: '**/*.js',
dest: 'src'
}],
options: {
process: function(content, filepath) {
/**
* Paste your Gruntfile (or important parts of it) here
*
*/
module.exports = function(grunt) {
grunt.initConfig({
watch: {
options: {
livereload: true
@mzgoddard
mzgoddard / index.jade
Created June 29, 2014 08:37
A Pen by Michael "Z" Goddard.
canvas
@mzgoddard
mzgoddard / 01_reduce.js
Last active August 29, 2015 14:10
Dummy source node map, with reduction over non-word tokens.
SourceMapConcatHelper.prototype._dummyNode = function(src, name) {
var node = new SourceNode();
var lineIndex = 1;
var charIndex = 0;
// Tokenize on words, new lines, and white space.
var tokens = src.split(/(\n|\b)/g);
// Filter out empty strings.
tokens = tokens.filter(function(t) { return !!t; });
// Reduce whitespace tokens together.
tokens = tokens.reduce(function(dest, t, index, src) {
@mzgoddard
mzgoddard / workdays.js
Created January 31, 2015 06:56
Add a number of workdays to a starting date.
// Solution to https://gist.github.com/jmeas/0a713e0b9901a25a32f1.
module.exports = function(start, increment) {
// Parse the date.
var d = new Date(start);
// Determine day of week.
var day = d.getUTCDay();
// Determine sign.
var sign = Math.sign(increment);
var absIncrement = Math.abs(increment);
@mzgoddard
mzgoddard / 01-style-bindings.js
Last active August 29, 2015 14:14
Style bindings ember mixin
export default Ember.Mixin.create({
attributeBindings: ['style'],
concatenatedProperties: ['styleBindings'],
styleBindings: [],
_styleBoundValues: function() {
var values = Ember.ArrayProxy.create({content: []});
this.get('styleBindings').map(function(key, index) {
var observer = function() {
@mzgoddard
mzgoddard / 01-abstract.md
Last active August 29, 2015 14:14
Welder API Brainstorm 1

Welder exposes 3 major hooks and 1 minor one. Commands create a promise chain with the other 2 major hooks settle and reduce. Settle creates a hash of immutable data. Reduce operates in series on the same data. Settle and reduce are called with a name which expands by the command running it into a series of name sets to match against settle and reduce handles registered. If there are multiple handles registeredto the same matching name set, the minor hook, order, determines the sorting order of these handels.

  • command: performs a set of settle and reduce hooks
  • settle: returns immutable data optionally cached, errors are ok
  • reduce: operate on last value, error at the end is not ok, handlers can fix errors
  • order: used in settle and reduce to order multiple handles

'sync:graph' - matches in the high level order, handles on the same match rely on a 'order' handle to sort them. default 'order' is to warn and sort by generated name, causing registration order to determine order.

  • 'sync:graph:f
@mzgoddard
mzgoddard / helper-initializer.js
Created April 23, 2015 03:35
Example ember-loader configuration to add handlebar helper loading.
// src/initializers/helper.js
exports.name = 'helper';
exports.initialize = function(container, app) {
Object.keys(app.HELPERS).forEach(function(key) {
Ember.Handlerbars.helper(key.replace(/\//g, '-'), app.HELPERS[key]);
});
};
@mzgoddard
mzgoddard / abacus-api-notes.js
Created October 16, 2011 17:30 — forked from boazsender/abacus-api-notes.js
Abacus API Notes
var mainLoop = Abacus.timer({
callback: function( data ) {
data.delta // time since the last tick
data.ticks // zero indexed number of ticks
}
});
// Start the timer with an optional kill time in miliseconds
// if no miliseconds are passed in, it wil run FOR EV AR, until you pause it
mainLoop.start( 10000 )