Skip to content

Instantly share code, notes, and snippets.

@hi-ogawa
hi-ogawa / README.md
Created May 11, 2023 13:18
prefers-color-scheme override cdp

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" }] })

references

@hi-ogawa
hi-ogawa / prop-path-map.ts
Created April 30, 2023 10:23
prop-path-map.ts
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" ||
@hi-ogawa
hi-ogawa / hangle-syllables.js
Last active February 28, 2023 10:39
List hangul syllables
/*
$ node hangle-syllables.js
가 : ㄱ ㅏ
각 : ㄱ ㅏ ㄱ
갂 : ㄱ ㅏ ㄲ
갃 : ㄱ ㅏ ㄳ
간 : ㄱ ㅏ ㄴ
갅 : ㄱ ㅏ ㄵ
갆 : ㄱ ㅏ ㄶ
@hi-ogawa
hi-ogawa / bin-gist.sh
Last active December 26, 2022 07:46
download shell script from gist and install it locally
#!/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
#
@hi-ogawa
hi-ogawa / passphrase.sh
Last active September 12, 2023 23:39
passphrase generator
#!/bin/bash
set -eu
#
# usage:
# $ bash passphrase.sh
# amusement-twelve-pusher-gilled-excuse
#
# references
@hi-ogawa
hi-ogawa / playwirhgt-for-scraping.ts
Last active December 14, 2022 06:31
playwright for scraping
import { chromium, Page } from "playwright-chromium";
import process from "node:process";
// this specific example is made to extract the list of spot trade coins on ByBit
// usage:
// node -r esbuild-register playwirhgt-for-scraping.ts --headed
// note:
// "page.pause" with "--headed" allows the same debugging experience as playwright testing.
@hi-ogawa
hi-ogawa / PKGBUILD
Created November 21, 2022 00:14
PKGBUILD aws-cli-v2-bin
# it seems aws-cli-v2-bin is deleted from aur. I extracted PKGBUILD from yay cache just in case.
# Maintainer: Steve Engledow <[email protected]>
pkgname=aws-cli-v2-bin
pkgver=2.8.3
pkgrel=1
pkgdesc='Universal Command Line Interface for Amazon Web Services version 2'
arch=('aarch64' 'x86_64')
url='https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html'
license=('Apache')
@hi-ogawa
hi-ogawa / patch-transaction-editable.ts
Last active November 15, 2022 04:28
jscodeshift script for converting number values to string values within specified forms of variable declarations
/* eslint-disable no-console */
//
// usage:
// npm i -D jscodeshift @types/jscodeshift recast
// npx jscodeshift --parser tsx --transform patch-transaction-editable.ts (...files)
//
/*
//// example input ////
@hi-ogawa
hi-ogawa / use-debounced-function.ts
Last active November 14, 2022 07:10
use-debounced-function.ts
//
// example:
// <button onClick={useDebouncedFunction(() => console.log("debounced?"), 500)} />
//
export function useDebouncedFunction<T extends (...args: any[]) => void>(
original: T,
ms: number
): (...args: Parameters<T>) => void {
const [call, setCall] = React.useState<() => void>();
@hi-ogawa
hi-ogawa / README.md
Last active December 11, 2022 07:50
Extract css variables from less variables