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 printTable = data => { | |
const header = data[0] | |
const columnWidths = header.map((_, column) => | |
Math.max(...data.map(row => `${ row[column] }`.length)) | |
); | |
const pad = (text, length) => `${ text }${ new Array(length - text.length + 1).join(" ") }` | |
data.forEach(row => { | |
console.log(row.map((column, i) => pad(column, columnWidths[i])).join(" | ")) | |
}) | |
}; |
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
(Array.from(document.querySelectorAll("#time-status #text")).map(node => node.textContent).reduce((total, text) => { | |
const [sec, min, hr = 0] = text.split(":").reverse(); | |
return total + (parseInt(hr) * 60 * 60) + (parseInt(min) * 60) + parseInt(sec); | |
}, 0) / 60 / 60).toFixed(2); | |
// Example - https://www.youtube.com/playlist?list=PLvqxe4XbcSiErm2kHuldndImavib9wh8c | |
// Result: '55.51' |
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 numberToText(num: number, numStrings: string[]): string { | |
let str = ""; | |
do { | |
const r = num % numStrings.length; | |
num = Math.floor(num / numStrings.length); | |
str = `${numStrings[r]}${str}`; | |
} while (num > 0); | |
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
// ==UserScript== | |
// @name Bitbucket Diff Improvements | |
// @version 1.0 | |
// @description Adds features to Bitbucket Diff view: | |
// * Visual emphasis to more heavily changed files in the diff summary | |
// * Expand/collapse file diffs, auto-collapse package-lock.json | |
// * Back to top fixed link | |
// @author Aaron Beall | |
// @match https://bitbucket.org/* | |
// ==/UserScript== |
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
// ES6+TS port of mrdoob's stats.js | |
// Need this because lib.d.ts doesn't have Performance.memory | |
declare global { | |
interface Performance { | |
memory: any; | |
} | |
} | |
export class Stats { |
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
Array.from(document.querySelectorAll("*")).filter(elem => elem.scrollLeft > 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
function uniqueArray<T>(array: T[], toUniqueValue?: (current: T) => any): T[] { | |
const values = toUniqueValue ? array.map(toUniqueValue) : array; | |
return array.filter((current, index) => values.indexOf(values[index]) == index); | |
} | |
// Example | |
const array = [{ id: 0, k: "a" }, { id: 1, k: "b" }, { id: 2, k: "a" }, { id: 3, k: "c" }]; | |
const result = uniqueArray(array, item => item.k); | |
expect(result).toEqual([{ id: 0, k: "a" }, { id: 1, k: "b" }, { id: 3, k: "c" }]); |
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 flatten = array => ( | |
array.reduce((accumulated, current) => accumulated.concat( | |
Array.isArray(current) ? flatten(current) : current | |
), []) | |
); | |
// Test | |
const before = [[1,2,[3]],4]; | |
const after = flatten(before); | |
const expected = [1,2,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 arrayToMap<T, K extends keyof T>(array: T[], key: K): { [key: string]: T } { | |
return array.reduce((map, item) => ({ | |
...map, | |
[`${item[key]}`]: item | |
}), {}); | |
} | |
// Example | |
const array = [{ id: "a"}, { id: "b" }, { id: "c" }]; | |
const byId = arrayToMap(array, "id"); // { "a": { id: "a"}, "b": { id: "b"}, "c": { id: "c"} } |
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
Patching "plotOptions.series.dataLabels.filter.operator" with { doclet: { values: [Function: values] } } | |
Patching "plotOptions.tilemap.tileShape" with { doclet: { values: '["hexagon", "circle", "diamond", "square"]' } } | |
Patching "yAxis.tooltipValueFormat" with { doclet: { type: { names: [Array] } } } | |
Patching "chart.parallelAxes.title" with { doclet: { extends: 'xAxis.labels' } } | |
Type already exists for [plotOptions,ad,name] at [plotOptions.sma.name] of {String,}, removing own def with type {undefined} | |
Type already exists for [plotOptions,atr,name] at [plotOptions.sma.name] of {String,}, removing own def with type {undefined} | |
Type already exists for [plotOptions,atr,params,period] at [plotOptions.sma.params.period] of {Number,}, removing own def with type {undefined} | |
Removed all children of [plotOptions,atr,params] and no type information is left, removing def | |
Type already exists for [plotOptions,bb,name] at [plotOptions.sma.name] of {String,}, removing own def with type {undefined} | |
Type already exists for [p |
NewerOlder