Skip to content

Instantly share code, notes, and snippets.

interface Time {
hour: string,
minute: string,
dayPeriod: string
}
someFunction(dateParts: Intl.DateTimeFormatPart[]): Time {
const {hour, minute, dayPeriod} =
dateParts.reduce(
(time, part) => (time[part.type] = part.value, time),
import Component from '@glimmer/component';
import { action } from '@ember/object';
export default class extends Component {
@action
changeParam(number, event) {
const params = this.args.param.slice(0);
if (event.target.checked) {
params.pushObject(number);
.mtk3, .mtk6 {
color: #36f9f6;
text-shadow: 0 0 2px #001716, 0 0 5px #03edf933, 0 0 10px #ffff6633;
}
.mtk3.mtki {
font-style: italic;
color: #9963ff99;
}
{
"window.zoomLevel": 0,
"diffEditor.ignoreTrimWhitespace": false,
"editor.fontFamily": "Victor Mono",
"editor.fontLigatures": true,
"workbench.colorTheme": "SynthWave '84",
"synthwave84.brightness": "1.5",
"editor.tokenColorCustomizations": {
"textMateRules": [
{
@cherscarlett
cherscarlett / disable.js
Created October 5, 2019 20:39
Disabling pointer events outside of your popup in React
useLayoutEffect(
() => {
const {current: menuDOM} = menuRef;
const body = window.document.querySelector('body');
if (menuDOM && isOpen) {
body.style['pointer-events'] = 'none';
menuDOM.style['pointer-events'] = 'initial';
} else if (menuDOM && !isOpen) {
body.style['pointer-events'] = null;
menuDOM.style['pointer-events'] = null;
// Consider all numbers on a number line from x to y.
// Compare each number in sequence to every other number: inclusive, once.
// For x = 5, and y = 8
// d = 3
// d^2 + d = 12
// 5, 6 6, 7 7, 8 8, 5
// 5, 7 6, 8 7, 5 8, 6
// 5, 8 6, 5 7, 6 8, 7
// Consider all numbers on a number line from x to y.
// Compare each number in sequence to every other number: inclusive, once.
// For x = 10, and y = 15
// 10, 11
// 10, 12
// 10, 13
// 10, 15
// ...
// pseudocode
// create a new hash map for holding each language and a running sum of its size
// loop through each repository
////// loop through each language
///////// add it to its matching entry and add the size to the running sum
///////// add the size to the running sum of all languages
// return languages and total sum
// pseudocode
// create a new array for holding each language and a running sum of its size
^^^^ is this the best way to hold this data for what we are going to use it for? ^^^^
// loop through each repository
^^^^ we definitely cannot avoid this ^^^^
// loop through each language, within each repository
^^^^ can we avoid this? ^^^^ <--- we MIGHT be able to reduce complexity here
// for each language, add it to its matching entry and add the size to the running sum
^^^^ can we do this differently, avoiding a loop? ^^^^ <--- we CAN reduce complexity here
// pseudocode
// create a new array for holding each language and a running sum of its size
// loop through each repository
// loop through each language, within each repository
// for each language, add it to its matching entry and add the size to the running sum
// get the sum of all of the sums of languages
// return the array and the total sum