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
| /** | |
| * Tier 1 – Dotted | |
| */ | |
| * { outline: 2px dotted purple; } | |
| * * { outline: 2px dotted blue; } | |
| * * * { outline: 2px dotted green; } | |
| * * * * { outline: 2px dotted yellow; } | |
| * * * * * { outline: 2px dotted orange; } | |
| * * * * * * { outline: 2px dotted red; } |
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://github.com/tpope/vim-surround/blob/master/doc/surround.txt | |
| // delete double quotes | |
| "Hello world!" | |
| // change [] brackets to () | |
| [123+456]/2 | |
| // change quotes to `p` tag | |
| "Look ma, I'm HTML!" |
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
| /** | |
| * @param {HTMLElement} element | |
| * @param {Keyframe[] | PropertyIndexedKeyframes} to | |
| * @param {KeyframeAnimationOptions} options | |
| */ | |
| export function animateTo(element, keyframes, options) { | |
| const anim = element.animate( | |
| keyframes, | |
| { ...options, fill: 'both' }, | |
| ); |
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
| 1. given 2 sorted number arrays, merge them in sorted order | |
| input: [2,4,8] and [1,3,5,7] | |
| output: [1, 2, 3, 4, 5, 7, 8] | |
| 2. given this data structure | |
| // input | |
| const bookings = [ | |
| { id: 1, userId: 456, status: 'confirmed' }, |
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
| details summary { | |
| cursor: pointer; | |
| outline: none !important; | |
| display: inline-block; | |
| padding: 8px 12px; | |
| padding-top: 10px; | |
| border-radius: 4px; | |
| overflow: hidden; | |
| background: #F09825; | |
| color: white; |
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
| let uniq = (arr) => { | |
| let map = {}; | |
| for (let i=0; i<arr.length; i++) { | |
| if (typeof map[arr[i]] === 'undefined') { | |
| map[arr[i]] = arr[i]; | |
| } else { | |
| arr.splice(i, 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
| let missing = (arr) => { | |
| let i = 1, max = arr.length, sum1 = 0, sum2 = 0; | |
| while (i <= max) { | |
| sum1 += i; | |
| sum2 += arr[i-1] || 0; | |
| if (arr[i-1] > max) max = arr[i-1]; | |
| i++; | |
| } | |
| return (sum1 - sum2) || undefined; | |
| } |