yarn add --dev jest enzyme enzyme-adapter-react-16
# to transform react code in the test environment (skip if using `create-react-app`)
This file contains hidden or 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 GOOD_OVERALL_EFFORT_DAYS = 30; | |
const MAX_DAYS_PER_TASK = 4 | |
const doGoodEstimate = (tasks) => { | |
let estimated = tasks.map((task) => { | |
task.effort = Math.floor((Math.random() * MAX_DAYS_PER_TASK) + 1); | |
return task; | |
}); | |
const totalEffort = estimated.reduce((sum, task) => { |
This file contains hidden or 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 useDebounced = (func, dependencies, ms) => { | |
const timer = useRef(null); | |
useEffect(() => { | |
if (timer.current) { | |
clearTimeout(timer.current); | |
} | |
timer.current = setTimeout(() => { | |
func(); |
This file contains hidden or 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
toCamelCase = (value) => value.toLowerCase().replace(/\s\w/, (match) => match.slice(1).toUpperCase()); | |
// 'Blue Grey' -> 'blueGrey' |
This file contains hidden or 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
// https://material.io/resources/color/#!/?view.left=0&view.right=0 | |
toCamelCase = (value) => value.toLowerCase().replace(/\s\w/, (match) => match.slice(1).toUpperCase()); | |
names = Array.from(document.querySelectorAll('.color-labels .color-label')).map((element => { | |
return toCamelCase(element.innerText) | |
})) | |
shades = Array.from(document.querySelectorAll('.align-bottom.ng-binding.ng-scope')).map((element => element.innerText)) | |
palette = Array.from(document.querySelectorAll('.palette-container')).reduce((obj, palette, index) => { |
This file contains hidden or 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 Remove-GitBranch { | |
# Example: | |
# Remove-GitBranch -regex feature # remove local branches matching regex pattern | |
# Remove-GitBranch -regex feature -origin # remove local & origin branches | |
param ( | |
[string] $regex, | |
[switch] $origin # remove the origin branch? | |
) |
This file contains hidden or 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 keyboardEventFromText(text) { | |
return [...text].flatMap((letter) => { | |
return [ | |
new KeyboardEvent('keydown', {key: letter}), | |
new KeyboardEvent('keypress', {key: letter}), | |
new InputEvent('input', {data: letter, inputType: 'insertText'}), | |
new KeyboardEvent('keyup', {key: letter}), | |
] | |
}) | |
} |
This file contains hidden or 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 chunk(array, size) { | |
function partition(array, start, result=[]) { | |
if (array.length === 0) { | |
return result; | |
} | |
return partition(array.slice(start+size, array.length), start+size, [...result, array.slice(0, size)]) | |
} | |
return partition(array, 0); |
This file contains hidden or 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
# javascript | |
root = true | |
[*] | |
charset = utf-8 | |
end_of_line = lf | |
indent_size = 2 | |
indent_style = space | |
insert_final_newline = true | |
trim_trailing_whitespace = true |
This file contains hidden or 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
<html> | |
<head> | |
<title>SVG Charts</title> | |
</head> | |
<body> | |
<div id="svg-bar"></div> | |
<div id="svg-area"></div> | |
<div id="svg-line"></div> | |
<script src="svg-charts.js"></script> |