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
<template> | |
<div> | |
<div | |
v-for="field of fields" | |
:key="field.id" | |
> | |
<input | |
v-if="field.value === 'input'" | |
:value="field.value" | |
:aria-label="field.label" |
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
<script> | |
// Base.js | |
class OurBaseComponent extends HTMLElement { | |
connectedCallback() { | |
this.doRender(); | |
} | |
createState(obj) { | |
return Object.keys(obj).reduce((prev, key) => { | |
// This introduces bugs |
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
test("Should fail", async (t) => { | |
const { cleanup, getByText, fireEvent } = await render([""], { | |
cwd: resolve(__dirname, "../example"), | |
}); | |
let outputStr; | |
outputStr = await waitFor(() => getByText("Please choose a generator")); | |
t.regex(outputStr, /Please choose a generator/); | |
cleanup(); |
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
// This basic premise is being used here: | |
// https://github.com/plopjs/plop/pull/287/files#diff-dc20b7684034e757bccdcb13b82e52fa46e618997d3fcc3e9fddd88bde362607R29-R73 | |
let dataWaitPromises = []; | |
function waitForData() { | |
const promise = new Promise((resolve) => (localDataResolve = resolve)); | |
dataWaitPromises.push({ promise, resolve: localDataResolve }); | |
} |
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
from math import inf | |
def find_closest_x_y(val, arr): | |
ret = { | |
"val": None, | |
"diffX": inf, | |
"diffY": inf | |
} | |
(val_x, val_y) = val |
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
// Setup | |
const setLogout = () => { | |
const router = useRouter(); | |
return () => { | |
// Do logout action here, including `router.push` | |
return 0; | |
} | |
} | |
Usage in `setup()` |
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
// Source: https://gist.github.com/avneesh0612/d4221f520688c7c4ff45153441011b4c | |
import { useEffect, useState } from 'react'; | |
function useDarkMode() { | |
const [theme, setTheme] = useState('dark'); | |
const colorTheme = theme === 'dark' ? 'light' : 'dark'; | |
useEffect(() => { | |
setTheme(localStorage.getItem('theme') || 'dark'); | |
}, []) |
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 t = readline(); | |
keyCodeMap = {} | |
addRangeToKeyCodeMap = (start, len) => { | |
for (i = 0; i < len; i++) { | |
keyCodeMap[start + i] = start + len - 1 - i | |
} | |
} | |
addLatinToKeyCodeMap = start => addRangeToKeyCodeMap(start, 26) |
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
interface W { | |
test?: 0; | |
he: 0; | |
} | |
type OnlyOptional<T> = { | |
[key in keyof T as Extract<T[key], undefined> extends never ? never : key]: T[key]; | |
} | |