Skip to content

Instantly share code, notes, and snippets.

View seia-soto's full-sized avatar
💭
Working from home

HoJeong Go seia-soto

💭
Working from home
View GitHub Profile
@seia-soto
seia-soto / preprocessor.ts
Created February 9, 2024 07:55
Preprocessor design 2
import { StaticDataView, sizeOfUTF8 } from './data-view';
import { fastStartsWith } from './utils';
export type EnvKeys =
| 'ext_ghostery'
| 'ext_abp'
| 'ext_ublock'
| 'ext_ubol'
| 'ext_devbuild'
| 'env_chromium'
@seia-soto
seia-soto / howto.md
Last active February 6, 2024 22:05
How to compile lxc/incus on AlpineLinux
@seia-soto
seia-soto / App.tsx
Created July 17, 2023 07:24
Check tagName after render
import { FC, PropsWithChildren, ReactElement, useEffect, useRef, useState } from "react"
const GetTagName: FC<PropsWithChildren<{ el?: ReactElement }>> = ({el, children}) => {
const [tagName, setTagName] = useState('')
const wrapper = useRef(null);
useEffect(() => {
const inner = wrapper?.current as HTMLElement | null
if (!inner) {
@seia-soto
seia-soto / snowflake.ts
Last active June 28, 2023 19:17
Snowflake ID generator in JavaScript using BigInt
/* eslint-disable no-bitwise */
export enum SnowflakeErrors {
EXCEEDED_MAXIMUM_SEQUENCE = 'Exceeded Maximum Sequence',
INVALID_MACHINE_ID = 'Invalid Machine Id',
INVALID_MACHINE_RANGE = 'Invalid Machine Range',
INVALID_PARAMETER_RANGES = 'Invalid Parameter Ranges',
INVALID_SEQUENCE_RANGE = 'Invalid Sequence Range',
INVALID_TIMESTAMP_EPOCH = 'Invalid Timestamp Epoch',
INVALID_TIMESTAMP_RANGE = 'Invalid Timestamp Range',
}
@seia-soto
seia-soto / App.tsx
Created June 22, 2023 07:50
mousemove event without child elements
import { styled } from "@stitches/react"
import { FC, useEffect, useRef } from "react"
const Outer = styled('div', {
display: 'flex',
flexDirection: 'row',
flexGrow: 1,
flexWrap: 'nowrap',
height: '100vh',
width: '100%',
@seia-soto
seia-soto / lxd.d.ts
Created May 31, 2023 23:20
TypeScript definition set for LXD API (Server and Instance)
export type LxdInstanceArchitectureType = 'x86_64' | 'arm64';
export type LxdInstanceType = 'container' | 'virtual-machine';
export type LxdInstanceEntity = {
id: string;
project: string;
};
export type LxdInstanceCpuUsage = {
import {type Static, type TSchema} from '@sinclair/typebox';
import {TypeCompiler} from '@sinclair/typebox/compiler';
import {rename, writeFile} from 'fs/promises';
import path from 'path';
import {isFile, readFileSafe} from '../fs/safe.js';
import {debounce} from '../utils/debounce.js';
export class ConfigProvider<T extends TSchema> {
absFilename: string;
local: Static<T>;
@seia-soto
seia-soto / fastify.d.ts
Last active April 26, 2023 07:37
Fastify WebSocket (with Early-termination of WebSocket before upgrade in process of request handler)
// (typeRoot) types/fastify.d.ts
/* eslint-disable @typescript-eslint/consistent-type-definitions */
import 'fastify';
import {type WebSocketServer} from 'ws';
import {type WebSocketWithConnection} from '../src/modules/ws.js';
declare module 'fastify' {
interface FastifyInstance {
wss: WebSocketServer;
}
neovim libssl-dev build-essential cmake clang git curl wget unzip tar triehash
@seia-soto
seia-soto / inspect.js
Last active December 4, 2022 05:15
Inspector
// ==UserScript==
// @name New script
// @namespace Violentmonkey Scripts
// @match *://*/*
// @grant unsafeWindow
// @version 1.0
// @author -
// @description 12/2/2022, 12:42:04 PM
// ==/UserScript==