Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael "Z" Goddard mzgoddard

View GitHub Profile
View All files.
copy: {
inplace: {
files: [{
expand: true,
cwd: 'src',
src: '**/*.js',
dest: 'src'
}],
options: {
process: function(content, filepath) {
View jsbin.viro.js
/**
* Paste your Gruntfile (or important parts of it) here
*
*/
module.exports = function(grunt) {
grunt.initConfig({
watch: {
options: {
livereload: true
@mzgoddard
mzgoddard / index.jade
Created Jun 29, 2014
A Pen by Michael "Z" Goddard.
@mzgoddard
mzgoddard / 01_reduce.js
Last active Aug 29, 2015
Dummy source node map, with reduction over non-word tokens.
View 01_reduce.js
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 Jan 31, 2015
Add a number of workdays to a starting date.
View workdays.js
// 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 Aug 29, 2015
Style bindings ember mixin
View 01-style-bindings.js
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 Aug 29, 2015
Welder API Brainstorm 1
View 01-abstract.md

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 Apr 23, 2015
Example ember-loader configuration to add handlebar helper loading.
View helper-initializer.js
// 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]);
});
};
View abacus-api-notes.js
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 )
You can’t perform that action at this time.