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
# Invalid! Used for testing 3.0 version-guarding in the UI rendering. | |
swagger: "2.0" | |
servers: [] | |
info: | |
version: 1.0.0 | |
title: minimal | |
description: News Articles ftw | |
paths: | |
/users: |
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 node >= 6 | |
let { dependencies, devDependencies } = require('./package') | |
let packages = [].concat(Object.keys(dependencies), Object.keys(devDependencies)) | |
let seen = [] | |
packages.forEach(pkg => { | |
if(seen.indexOf(pkg) > -1) { |
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
// matrixAdd only works on balanced matrices. | |
var a = | |
[[1,5], | |
[2,9]] | |
var b = | |
[[5,6], | |
[3,4]] |
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 query() { | |
var | |
total = 0, shown = 0, | |
job_list = Array.prototype.slice.call(document.querySelectorAll('.c00,.cdd')), | |
query_list = Array.prototype.slice.call(arguments); | |
// turn them all off | |
job_list.forEach(function(node) { | |
node.parentNode.parentNode.parentNode.style.display = 'none'; | |
total ++; |
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
// time: O(n) | |
// space: O(1) | |
var max = function(arr) { | |
var returnable = Number.MIN_VALUE; | |
arr.forEach(function(v){ | |
if(returnable < v) { | |
returnable = v; | |
} | |
}) | |
return returnable; |
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 has = function(arr,target) { | |
return arr.indexOf(target) > -1; | |
} | |
var balancedParens = function (str) { | |
var pairs = { | |
'{' : '}', | |
'[' : ']', | |
'(' : ')' | |
}, |
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 round = function (num) { | |
var decimalPart = num % 1, | |
intPart = num - ( num % 1 ); | |
return decimalPart >= .5 ? intPart + 1 : intPart; | |
} | |
// test equivalence of Math.round with commonly used numbers | |
var isEquivalent; | |
for(var i = 0; i < 1000000; i += 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
function rot13(str, n) { | |
n = typeof n === 'number' ? n : 13; | |
var ret = []; | |
for(var i=0;i<str.length;i++) { | |
var code = str.charCodeAt(i); | |
var newCode = genCode(code,code > 90 ? 97 : 63,n); | |
newCode += newCode < code ? 1 : 0; | |
ret.push(String.fromCharCode(newCode)); | |
} | |
function genCode(code,offset,n) { |
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 parse(obj){ | |
var str="heroku config:set --app YOURAPP"; | |
for(var key in obj) { | |
str += (" " + key + "=" + "\"" + obj[key] + "\""); | |
} | |
return str; | |
}; |
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
// transforms an object into a nested array | |
// passing "true" as the second argument attempts to use | |
// recursion to handle nested objects. otherwise, | |
// transform will not touch the nested object. | |
obj = { | |
a:"b", | |
c:"d", | |
e:"f", | |
g:{ |