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
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 sortOn<T>(array: T[], ...fields: (keyof T)[]) { | |
return array.sort((a, b) => { | |
for (const f of fields) { | |
if (a[f] > b[f]) return 1; | |
if (a[f] < b[f]) return -1; | |
} | |
return 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 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
// ---------- webpack.config.ts ---------- // | |
import * as path from "path"; | |
import * as webpack from "webpack"; | |
import * as loaders from "./webpack/loaders"; | |
import { plugins } from "./webpack/plugins"; | |
const config: webpack.Configuration = { | |
entry: { | |
app: './src/index.tsx', | |
styleguide: './styleguide/index.tsx' |
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' |
OlderNewer