This file contains 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 ul = document.getElementsByClassName('thumbs')[0] | |
for (var i = ul.children.length; i >= 0; i--) { | |
ul.appendChild(ul.children[Math.random() * i | 0]); | |
} |
This file contains 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
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) : |
This file contains 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 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 |
This file contains 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
'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+'\')' |
This file contains 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
// **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); |
NewerOlder