Skip to content

Instantly share code, notes, and snippets.

@JeffCave
JeffCave / .block
Last active August 8, 2018 21:58 — forked from mbostock/.block
TELE 1070 - Assig3 - graph
license: gpl-3.0
height: 600
@JeffCave
JeffCave / Geometry.js
Last active December 26, 2017 18:13
Psychedelic Checkers II
'use strict';
class Point extends Array{
constructor(x,y,ord){
super();
if(Array.isArray(x)){
ord = x[2];
y = x[1];
x = x[0];
}
@JeffCave
JeffCave / PsycheCheckers.js
Last active December 24, 2017 00:29
Psychedelic Checkerboard
'use strict';
JSON.clone = JSON.clone || function(o){
let obj = JSON.stringify(o);
if(typeof obj === 'undefined'){
return undefined;
}
obj = JSON.parse(obj);
return obj;
};
/**
* Flatten nested arrays.
*
* @param {array} arr - The nested array to be flattened
* @param {number} failsafe - (Optional) In case of extreme depth, simply stops the recursion
*/
function FlattenArray(arr, failsafe){
if(typeof failsafe === 'undefined'){
failsafe = Number.MAX_SAFE_INTEGER;
//failsafe = 1
@JeffCave
JeffCave / CryptoJS_byteArrayConversions.js
Last active May 9, 2017 07:50 — forked from artjomb/CryptoJS_byteArrayWordArrayConversions.js
Convert a byte array to a word array and back in CryptoJS-compatible fashion
/**
* EXAMPLE
* var myhash = CryptoJS.HmacSHA1(mine[2], secret);
* myhash = byteArrayConversion(myhash);
*/
function wordArrayToByteArray(hash){
return hash.words
//map each word to an array of bytes
.map(function(v){
// create an array of 4 bytes (less if sigBytes says we have run out)