This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
... | |
<script> | |
(function(d){ | |
if (!('querySelector' in d && 'addEventListener' in window)) return; | |
d.documentElement.className += ' has-js'; | |
d.addEventListener('DOMContentLoaded', function() { | |
var s = d.createElement('script'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function() { | |
var cssomPrefixes = 'Moz O ms Webkit'.split(' '); | |
var modElem = { | |
elem: document.createElement('modernizr') | |
}; | |
var mStyle = { | |
style: modElem.elem.style | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
require('./tasks-css'); | |
require('./tasks-js'); | |
// etc. | |
gulp.task('dev', ['browsersync', 'html-watch', 'img-watch', 'css-watch', 'js-watch']); | |
gulp.task('dist', ['clean', 'html-compile', 'img-optimize', 'css-compile', 'js-transpile']); | |
// etc. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var R = require('ramda'); | |
var IO = require('ramda-fantasy').IO; | |
var Either = require('ramda-fantasy').Either; | |
var glob = require('glob'); | |
var exec = cmd => require('child_process').execSync(cmd, { encoding: 'utf8' }); | |
// getFiles :: IO [String] | |
var getFiles = () => new IO(() => glob.sync('src/*.js')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// hasPosition trait | |
// | |
const hasPosition = state => ({ | |
setPosition: function(x, y) { | |
this.x = x; | |
this.y = y; | |
}.bind(state) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var asyncParallel = function(tasks, callback) { | |
var results = []; | |
var count = tasks.length; | |
tasks.forEach(function(task, index) { | |
task(function(err, data) { | |
results[index] = data; | |
if (err) { | |
callback && callback(err); | |
callback = null; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add :: Number -> Number -> Number | |
var add = function(left) { return function(right) { return left + right } }; | |
// multiply :: Number -> Number -> Number | |
var multiply = function(left) { return function(right) { return left * right } }; | |
// map :: (a -> b) -> Functor a -> Functor b | |
var map = function(fn, val) { return val.map(fn) }; | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Parent | |
*/ | |
function Shape(x, y) { | |
this.x = x; | |
this.y = y; | |
} | |
Shape.prototype.constructor = Shape; | |
Shape.prototype.pos = function() { | |
return [this.x, this.y]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Map a value in a domain to a value in a range | |
*/ | |
function scale(domainMin, domainMax, value, rangeMin, rangeMax) { | |
var perc = (value - domainMin) / (domainMax - domainMin) | |
return ((rangeMax - rangeMin) * perc) + rangeMin | |
} | |
scale(50, 100, 75, 100, 200) //=> 150 | |
scale(10, 110, 50, 200, 300) //=> 240 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Factory | |
var encrypterFactory = function(config) { | |
var encrypter = eval('new Encrypt' + config.algorithm.toUpperCase()); | |
if (typeof encrypter.encrypt !== 'function') { | |
throw new Error(encrypter.constructor.name + ' must implement the `encrypt` method!'); | |
} | |
return encrypter; | |
}; | |
// Implementations |