Skip to content

Instantly share code, notes, and snippets.

View cometkim's full-sized avatar

Hyeseong Kim cometkim

View GitHub Profile
@cometkim
cometkim / node-pm-globals.md
Last active July 30, 2024 13:59
How package managers dealing with binaries from transitive dependencies
$pm add vite

# should be success
$pm run vite --version

# shoud be fail
$pm run esbuild --version
@cometkim
cometkim / convert.mjs
Last active July 21, 2023 12:36
Convert Wikipedia page-articles data (XML) into a text dataset (NDJSON)
// Convert Wikipedia page articles dump (XML) into a stream of JSON
// { id: 0, "title": "...", "text": "..." }
// The "text" field format will also be converted into plain text
import * as path from 'node:path';
import * as fs from 'node:fs';
import XMLParser from 'node-xml-stream';
import ndjson from 'ndjson';
import instaview from 'instaview';
import htmlEntities from 'html-entities';
@cometkim
cometkim / index.html
Created May 24, 2023 06:18
Is growable SAB GC-able?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>SharedArrayBuffer GC test</title>
</head>
<body>
<div id="root"></div>
<script type="module">
@cometkim
cometkim / index.html
Last active April 4, 2023 10:00
Injected setup to Facebook's playable ads runtime
<!-- The script is injected to the `<head>`, so prevent possible network access from the content script. -->
<script type="text/javascript">
if (
!Boolean(navigator.userAgent.match(/android/i)) &
Boolean(navigator.userAgent.match(/Chrome/) ||
navigator.userAgent.match(/Firefox/) ||
navigator.userAgent.match(/Safari/) ||
navigator.userAgent.match(/MSIE|Trident|Edge/))) {
window.FbPlayableAd = {
onCTAClick() {
@cometkim
cometkim / temp.html
Created November 9, 2022 09:40
7GUIs temperature converter example in ReScript
<div>
Celcius: <input id="ce" type="number">
Fahrenheit: <input id="fa" type="number">
</div>
<script type="importmap">
{
"imports": {
"rescript/": "/node_modules/rescript/"
}
@cometkim
cometkim / heap.ts
Last active May 9, 2022 02:21
Generic Heap Implementation for JS
export interface Comparable<T> {
compare(a: T, b: T): number;
}
export class Heap<T> {
#values: T[] = [];
#id: Comparable<T>;
constructor(id: Comparable<T>) {
this.#id = id;
@cometkim
cometkim / gatsby-typed-query.md
Last active May 4, 2022 11:35
GatsbyJS typed query generation RFC

RFC: Gatsby Typed Query

Motivation

As a maintainer of graphql-plugin-typegen, I have been thinking about an ergonomic way to provide GraphQL types in the Gatsby project for a long time.

In the first version of the plugin, users always had to directly import the type definitions from the generated files.

import * as React from 'react';
@cometkim
cometkim / index.mjs
Created March 25, 2022 16:55
Search all packages that doesn't support ESM from node_modules directory
import * as path from 'node:path';
import * as fs from 'node:fs/promises';
const nodeModules = path.resolve('node_modules');
let moduleNames = await fs.readdir(nodeModules);
moduleNames = (await Promise.all(
moduleNames.map(async name => {
if (name.startsWith('.')) {
return [];

In this tutorial we're going to build a set of parser combinators.

What is a parser combinator?

We'll answer the above question in 2 steps

  1. what is a parser?
  2. and.. what is a parser combinator?

So first question: What is parser?

In this tutorial we're going to build a set of parser combinators.

What is a parser combinator?

We'll answer the above question in 2 steps

  1. what is a parser?
  2. and.. what is a parser combinator?

So first question: What is parser?