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
const replacer = function( depth = Number.MAX_SAFE_INTEGER ) { | |
let objects, stack, keys; | |
return function(key, value) { | |
// very first iteration | |
if (key === '') { | |
keys = ['root']; | |
objects = [{keys: 'root', value: value}]; | |
stack = []; | |
return value; | |
} |
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
/** | |
* Convenient shortcut | |
*/ | |
Object.defineProperty(window, 'define', { | |
value: (property, ...meta) => meta.length == 2 ? Object.defineProperty(meta[0], property, meta[1]) : Object.defineProperty(window, property, meta[0]), | |
writable: false, | |
enumerable: true | |
}) |
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
// String utils | |
// | |
// resources: | |
// -- mout, https://github.com/mout/mout/tree/master/src/string | |
/** | |
* "Safer" String.toLowerCase() | |
*/ | |
function lowerCase(str){ | |
return str.toLowerCase(); |
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
/** | |
* Turns someCrazyName into Some Crazy Name | |
* Decent job of acroynyms: | |
* ABCAcryonym => ABC Acryoynm | |
* xmlHTTPRequest => Xml HTTP Request | |
*/ | |
String.prototype.unCamelCase = function(){ | |
return this | |
// insert a space between lower & upper | |
.replace(/([a-z])([A-Z])/g, '$1 $2') |
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
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4 |
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
[ | |
{ | |
"code": "ab", | |
"name": "Abkhaz" | |
}, | |
{ | |
"code": "aa", | |
"name": "Afar" | |
}, | |
{ |
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
// Loads js files | |
function loadScripts(urlArray,cb) { | |
var scriptLoadCount = scriptLoadedCount = 0; | |
loadScript(); | |
function loadScript() { | |
var head= document.getElementsByTagName('head')[0]; | |
var script= document.createElement('script'); | |
script.type= 'text/javascript'; | |
var url = (urlArray[scriptLoadCount].indexOf('?') == -1) ? urlArray[scriptLoadCount] + '?d=' + Math.random() : urlArray[scriptLoadCount] + '&d=' + Math.random() |
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
// Takes string of Note + Octave | |
// Example: | |
// var frequency = getFrequency('C3'); | |
var getFrequency = function (note) { | |
var notes = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#'], | |
octave, | |
keyNumber; | |
if (note.length === 3) { |
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 fs = require("fs"), | |
path = require("path"); | |
function walk(dir, callback) { | |
fs.readdir(dir, function(err, files) { | |
if (err) throw err; | |
files.forEach(function(file) { | |
var filepath = path.join(dir, file); | |
fs.stat(filepath, function(err,stats) { | |
if (stats.isDirectory()) { |
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
syntax unless = function (ctx) { | |
let test = ctx.next().value; | |
let body = ctx.next().value; | |
return #`if (!${test}) ${body}`; | |
} | |
var answer = 0; | |
unless (answer === 42) { |