# single test file only on chromium
yarn test:integration -- integration/vite-dev-express-test.ts --headed --project chromium
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
function wrapConsoleTimeAsync<F extends (...args: any[]) => any>(f: F) { | |
const wrapper = async function (this: any, ...args: any[]) { | |
const id = Math.random().toString(36).slice(2).padStart(12, "0"); | |
const label = `${f.name}:${id}`; | |
globalThis.console.time(label); | |
try { | |
return await f.apply(this, args); | |
} finally { | |
globalThis.console.timeEnd(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
/* eslint-disable no-console */ | |
import type { API, FileInfo } from "jscodeshift"; | |
import * as recast from "recast"; | |
export default function transformer(file: FileInfo, api: API): string | undefined { | |
const j = api.jscodeshift; | |
const $j = j(file.source); | |
const result: { |
- simple example
const code = `for (let i = 0; ;i++) { (i++ % 1000000 === 0) && console.log(i); }`
const worker = new Worker(new URL(`data:text/javascript,${encodeURIComponent(code)}`))
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
// | |
// generate type-safe react-query options wrapper from a record of async functions | |
// | |
type FnRecord = Record<string, (input: unknown) => unknown>; | |
type FnInput<F extends (input: unknown) => unknown> = Parameters<F>[0]; | |
type FnOutput<F extends (input: unknown) => unknown> = Awaited<ReturnType<F>>; | |
type ReactQueryOptionsProxy<T extends FnRecord> = { | |
[K in keyof T]: { |
Override prefers-color-scheme
via CDP
let Main = await import('./entrypoints/main/main.js')
await Main.MainImpl.sendOverProtocol("Emulation.setEmulatedMedia", { features: [{ name: "prefers-color-scheme", value: "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
type PropKey = string | number; | |
type PropValue = null | undefined | number | boolean | string | Date; | |
export function toPropPathMap(input: unknown) { | |
const output = new Map<PropKey[], PropValue>(); | |
function traverse(v: unknown, keys: PropKey[]) { | |
// prettier-ignore | |
if ( | |
typeof v === "undefined" || |
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
/* | |
$ node hangle-syllables.js | |
가 : ㄱ ㅏ | |
각 : ㄱ ㅏ ㄱ | |
갂 : ㄱ ㅏ ㄲ | |
갃 : ㄱ ㅏ ㄳ | |
간 : ㄱ ㅏ ㄴ | |
갅 : ㄱ ㅏ ㄵ | |
갆 : ㄱ ㅏ ㄶ |
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
#!/bin/bash | |
set -eu -o pipefail | |
# | |
# something similar to https://github.com/marcosnils/bin but for simple shell scripts on gist | |
# | |
# usage: | |
# bash bin-gist.sh https://gist.github.com/hi-ogawa/1e0b1a147e883aad41f97c68246f3c33 bin-gist.sh | |
# bash bin-gist.sh https://gist.github.com/hi-ogawa/bca49e90241f7808127a430f986d33ea passphrase.sh | |
# |
NewerOlder