[ Launch: An inlet to Tributary ] 4567112 by sym3tri
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
angular.module('myServices') | |
.factory('visibilityBroadcaster', function($rootScope, $document, _) { | |
var document = $document[0], | |
features, | |
detectedFeature; | |
features = { | |
standard: { | |
eventName: 'visibilitychange', |
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 svg = d3.select('#container').append('svg') | |
.attr({ | |
viewBox: '0 0 1000 1000', | |
}); | |
svg.append('rect') | |
.attr({ | |
width: '1000', | |
height: '1000' | |
}); |
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
// tweak these options | |
var lineTotal = 16, | |
lineLength = 30, | |
speed = 1.28, | |
width = 1.96, | |
radius = 16, | |
color = '#333', | |
// dont touch these | |
posX = 100, |
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
// as discussed by Crockford here: http://www.youtube.com/watch?v=dkZFtimgAcM | |
// more detailed example here: https://github.com/douglascrockford/monad/blob/master/monad.js | |
function MONAD() { | |
return function unit(value) { | |
var monad = Object.create(null); | |
monad.bind = function (func) { | |
return func(value); | |
}; | |
return monad; |
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
function mixin(receiver, supplier) { | |
Object.keys(supplier).forEach(function(property) { | |
Object.defineProperty(receiver, property, Object.getOwnPropertyDescriptor(supplier, property)); | |
}); | |
} | |
var name = 'Ed', | |
supplier = { | |
get name() { | |
return name; |
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
// Every time you define a function it's as if all this happens behind the scenes... | |
function foo() { | |
// var arguments = new array-like object corresponding to the function arguments | |
// foo.length = number of parameters in function definition (different from arguments.length); | |
// foo.name = 'foo'; | |
// foo.prototype = {}; | |
// foo.constructor = Function; | |
//// (only if no explicit return statement exists and is not invoked with 'new' operator) |
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
// http://dailyjs.com/2012/11/26/js101-proto/ | |
var assert = require('assert'); | |
function User() { | |
} | |
var user = new User(); | |
assert.equal(user.__proto__, User.prototype); |
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
- Trailing commas are ok | |
- No reserved words for property names | |
- NaN, Infinity, undefined : are all constants | |
- parseInt() defaults to radix 10 | |
- /regexp/ produces new reg ex object every time | |
- JSON.parse(), JSON.stringify() | |
- Function.prototype.bind | |
- String.prototype.trim | |
- Array.prototype.every, filter, forEach, indexOf, lastIndexOf, map, reduce, reduceRight, some, | |
- Date.now() |