command
+ option
+ j
control
+ shift
+ j
// **IMPORTANT** Not compatible with <= IE10 (which makes up about 20% of browsers) | |
// Here ya go! Just put this in your global scope: | |
// Works fine with all real browsers though | |
function inherit(inhObj,self) { | |
var selfProto = Object.getPrototypeOf(self) | |
var inheritance=Object.create(inhObj.prototype); | |
for (var i in selfProto) {inheritance[i] = selfProto[i]}; | |
if (Object.setPrototypeOf) | |
Object.setPrototypeOf(self,inheritance); |
'use strict' | |
const path = require('path') | |
const cp = require('child_process') | |
const gaze = require('gaze') | |
// edit to match the path of your server | |
const serverPath = __dirname+'/index' | |
let server; | |
let serverScript = 'require(\''+serverPath+'\')' |
function map(arr, op, thisArg) { | |
if (typeof op !== 'function') throw new Error('operation must be a function') | |
if (!Array.isArray(arr)) throw new Error('first argument must be an array') | |
if (typeof thisArg !== 'object' && thisArg !== undefined) throw new Error('`this` argument must be an object') | |
var newArr = arr.slice() | |
op = op.bind((thisArg || null)) | |
for (var i = 0, l = newArr.length; i < l; i++) { | |
newArr[i] = op(newArr) | |
} | |
return newArr |
let passThroughs = ['toString', 'toLocaleString', 'unshift'] | |
function FunArr(arr) { | |
let fun = { | |
i: arr | |
} | |
for (let proxy of Object.getOwnPropertyNames(Array.prototype)) { | |
Object.defineProperty(fun, proxy, { | |
get: () => typeof fun.i[proxy] === 'function' ? | |
passThroughs.includes(proxy) ? | |
(...args) => fun.i[proxy].apply(fun.i,args) : |
var ul = document.getElementsByClassName('thumbs')[0] | |
for (var i = ul.children.length; i >= 0; i--) { | |
ul.appendChild(ul.children[Math.random() * i | 0]); | |
} |
var ul = document.getElementsByClassName('thumbs')[0] | |
var toDelete = [] | |
for (var i = 0; i < ul.children.length; i++) { | |
var releaseDate = ul.children[i].getElementsByClassName('now-thumbnail')[0].getAttribute('data-releasedate') | |
if (+releaseDate < 2000) toDelete.push(ul.children[i]) | |
} | |
toDelete.forEach(function (el) {el.parentNode.removeChild(el)}) |
var noteMappings = { | |
c: 16.35, | |
'c#': 17.32, | |
d: 18.35, | |
'd#': 19.45, | |
e: 20.6, | |
f: 21.83, | |
'f#': 23.12, | |
g: 24.5, | |
'g#': 25.96, |
const sim = require('./simulation') | |
const humans = require('humans') | |
describe('#aiTest', function() { | |
beforeEach(function() { | |
humans.restore() | |
sim.restore() | |
}) | |
it('should not kill all humans', function() { |