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
| hello gist |
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
| git branch | egrep -v 'master|feat/something-neat' | xargs git branch -D |
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 outerWrapperStyle = { | |
| overflow: 'hidden' // Avoid breaking UI | |
| } | |
| const innerWrapperStyle = { | |
| whiteSpace: 'nowrap', // Render text in one line | |
| display: 'block', | |
| overflow: 'auto', // Scroll overflow if needed | |
| } |
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
| Array.from(document.querySelectorAll(".file-info")) | |
| .filter(node => node.textContent.includes('.svg')) | |
| .forEach(el => { | |
| const btn = el.querySelector('.js-details-target'); | |
| if (btn.getAttribute('aria-expanded') === "true") btn.click(); | |
| }) |
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 capitalize(s) { | |
| if (typeof s !== 'string') return ''; | |
| return s.charAt(0).toUpperCase() + s.slice(1) | |
| } |
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 a = { | |
| ...(someCondition && {b: 5}) | |
| } |
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 stringVariable = getComputedStyle(document.documentElement) | |
| .getPropertyValue('--height'); // '60px' | |
| const heightInPx = Number(stringVariable.match(/[0-9]*/)[0]); // 60 |
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 testPerformance(fn, iterations) { | |
| console.time() | |
| for (let i = 0; i < iterations; i++) { | |
| fn() | |
| }; | |
| console.timeEnd() | |
| } |
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 range = (b, e = (b + (b = 0)), s = 1) => | |
| Array.from({ length: (e - b) / s + 1 }, (v, i) => i * s + b); | |
| // range(beggining, end, step) | |
| // range(10) === [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
| // range(-5, 5) === [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5] | |
| // range(-10, 10, 5) === [-10, -5, 0, 5, 10] | |
| // range(10, 5) === [] | |
| // range(10, 5, -1) === [10, 9, 8, 7, 6, 5] |
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
| // E.G. await sleep(1000) | |
| function sleep(ms) { | |
| if (ms < 0) ms = 0 | |
| return new Promise(resolve => setTimeout(resolve, ms)); | |
| } |
NewerOlder