Skip to content

Instantly share code, notes, and snippets.

View cometkim's full-sized avatar
🛌
sleeping

Hyeseong Kim cometkim

🛌
sleeping
View GitHub Profile
@jamiebuilds
jamiebuilds / tradeoffs-in-value-derived-types-in-typescript.md
Last active December 16, 2022 17:21
Value-derived types in TypeScript are super powerful, but you should be thoughtful in how/when you use them

Tradeoffs in value-derived types in TypeScript

Many of the more "advanced" typescript features can be used for creating "value-derived" types.

At its simplest form:

let vehicle = { name: "Van", wheels: 4 }
@steveruizok
steveruizok / point-to-line.ts
Last active March 23, 2021 06:08
Get the minimum distance between a point and a line. Get the nearest point on a line to a second point.
/**
* Get the minimum distance from a point P to a line with a segment AB.
* @param A The start of the line.
* @param B The end of the line.
* @param P A point.
* @returns
*/
export function distanceToLine(A: number[], B: number[], P: number[]) {
const delta = sub(B, A)
const angle = Math.atan2(delta[1], delta[0])
@ggoodman
ggoodman / README.md
Created February 25, 2021 15:14
Using the concept of defer from golang to simplify resource cleanup in Javascript

The withCleanup helper

Example

const result = await withCleanup(async (defer) => {
  const fileHandle = await getFileHandle();
  defer(() => fileHandle.close());
   
 // Carry on
@storycraft
storycraft / dmca-takedown-kakao.txt
Last active March 7, 2023 05:28
DMCA Takedown Notice [ref:00DA0000000K0A8.5004w000026Fag0:ref]
DMCA Takedown Notice
== Copyright owner: Kakao Corp.
== Name: An Chisu
== Company: Kakao Corp.
== Job title: IP Manager
== Email address: trademark@kakaocorp.com
== Address: 7F N, H-Square, 235
== City: Pangyoyeok-ro, Bundang-gu, Seongnam-si

⚠️ Warning: this document is out of date.

For the most recent webpack5 instructions see MIGRATION.md.

Storybook experimental Webpack 5 support

Storybook 6.2 includes experimental Webpack 5 support. Webpack 5 brings a variety of performance improvements, as well as exciting new features like module federation. Here's a quick guide to get you going.

Intro

@sciyoshi
sciyoshi / esbuild-relay.js
Created February 19, 2021 16:34
Esbuild plugin for compiling relay queries
import { promises } from "fs";
import crypto from "crypto";
import path from "path";
import { print, parse } from "graphql";
const plugin = {
name: "relay",
setup: build => {
build.onLoad({ filter: /\.tsx$/, namespace: "" }, async args => {
let contents = await promises.readFile(args.path, "utf8");
declare interface CSS {
layoutWorklet: Worklet // eslint-disable-line no-undef
paintWorklet: Worklet // eslint-disable-line no-undef
animationWorklet: Worklet // eslint-disable-line no-undef
}
declare type ChildDisplay = "block" | "normal"
declare type LayoutSizingMode = "block-like" | "manual"
declare interface LayoutOptions {
@azlen
azlen / bulletpaths.js
Last active September 11, 2025 03:00
All Paths Lead to Roam
/*
* credit to Dhrumil Shah (@wandcrafting) and Robert Haisfield (@RobertHaisfield)
* for the original concept which was part of their RoamGames submission
* and can be found at: https://www.figma.com/file/5shwLdUCHxSaPNEO7pazbe/
*
*/
/* ======= OPTIONS ======== */
/* note: if you change these, reload the page to see the effect */
@kitten
kitten / README.md
Last active February 10, 2021 18:07
urql update: February 2021

urql update: February 2021

Note: This announcement is related to today's batch of released urql packages. You can see the release process and the changelogs here: urql-graphql/urql#1340

We have an entirely new release batch that we've just worked on. This batch includes some breaking changes and major releases, so we'd like to take a moment to talk about what has changed. It will luckily be surprisingly unsurprising and builds on the work that's already been ongoing for a while. Lastly we'll include a note on our upcoming roadmap, which we'll be kicking off soon.

@kiding
kiding / NoScrollOnInputFocusiOSSafari.html
Last active August 14, 2026 12:37
Preventing iOS Safari scrolling when focusing on input elements
<!--
When an input element gets focused, iOS Safari tries to put it in the center by scrolling (and zooming.)
Zooming can be easily disabled using a meta tag, but the scrolling hasn't been quite easy.
The main quirk (I think) is that iOS Safari changes viewport when scrolling; i.e., toolbars shrink.
Since the viewport _should_ change, it thinks the input _will_ move, so it _should_ scroll, always.
Even times when it doesn't need to scroll—the input is fixed, all we need is the keyboard—
the window always scrolls _up and down_ resulting in some janky animation.
However, iOS Safari doesn't scroll when the input **has opacity of 0 or is completely clipped.**