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
import hash from 'object-hash'; | |
export type ObjectCacheFunction<A extends unknown[], V> = (...args: A) => V; | |
const objectMap = cache(() => new Map<string, any[]>()); | |
export const objectCache = <A extends unknown[], V>(fn: ObjectCacheFunction<A, V>): ObjectCacheFunction<A, V> => { | |
const map = objectMap(); | |
return new Proxy( | |
cache((s: string) => fn(...(map.get(s) as A))), | |
{ |
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 @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment */ | |
'use client'; | |
import type { ElementType, RefCallback } from 'react'; | |
import { createElement, useCallback, useEffect, useMemo, useRef, useState } from 'react'; | |
import { twMerge } from 'tailwind-merge'; | |
import type { PolymorphicComponentProps } from './polymorphic'; | |
export type InViewProps = { | |
/** | |
* The CSS Class that active when inside browser's sight |
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
// other allowed node types | |
const allowNodes: number[] = [Node.TEXT_NODE, Node.DOCUMENT_FRAGMENT_NODE] | |
// allowed tags | |
const allowTags = ['div', 'span', 'p', 'img', 'strong', 'i', 'b', 's', 'br', 'a', 'blockquote', 'code', 'del', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'kbd', 'ol', 'ul', 'li', 'sub', 'sup'] | |
// allowed tag's attributes | |
const allowAttrs = ['src', 'width', 'height', 'alt', 'title', 'href', 'style'] | |
// generate almost unique hash that avoid key warning | |
const unsafeHash = () => Math.random().toString(36).substring(2) |
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
import { | |
type ComponentProps, | |
createElement, | |
type ElementType, | |
type ForwardedRef, | |
forwardRef, | |
type MutableRefObject, | |
type ReactDOM, | |
type ReactElement, | |
type Ref, |
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
<script setup> | |
import useEventBus from './lib/event-bus' | |
const bus = useEventBus() | |
bus | |
.on('session-change', (...args) => { | |
// TODO Session Change | |
console.log('session change event fired', args) | |
}) |
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
<template> | |
<div ref="container"></div> | |
</template> | |
<script setup lang="ts"> | |
import {defineEmits, onBeforeUnmount, onMounted, ref, toRefs, watch} from 'vue'; | |
import {editor as editorType, IDisposable} from 'monaco-editor'; | |
import ICodeEditor = editorType.ICodeEditor; | |
export interface CodeEditorProps { | |
modelValue: string; |
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
/** | |
* Array Cartesian Product | |
*/ | |
const cartesian = <T,>(...arr: (T extends unknown[] ? never : T)[][]) => | |
arr.reduce((a, b) => a.flatMap((x) => b.map((y) => [...x, y])), [ | |
[] as T[], | |
] as T[][]); |
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
# WSL2 network port forwarding script v1 | |
# for enable script, 'Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser' in Powershell, | |
# for delete exist rules and ports use 'delete' as parameter, for show ports use 'list' as parameter. | |
# written by Daehyuk Ahn, Aug-1-2020 | |
# edited by Ukjin Yang, Jun-7-2022 (Windows Server 2022 also works!) | |
# Improved features: more detailed logs for Task Scheduler, saved IP check, etc. | |
If ($Args[0] -eq "list") { | |
netsh interface portproxy show v4tov4; | |
exit; |
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
import type React from 'react'; | |
import { createContext, useContext, useEffect, useMemo, useState } from 'react'; | |
/** | |
* 레이아웃 키값 Map | |
* @date 2022. 4. 20. - 오후 3:51:50 | |
* | |
* @export | |
* @interface LayoutMap | |
* @typedef {LayoutMap} |
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 GetRecentFolder(path) | |
On Error Resume Next | |
Dim fso, folder, version | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
Set GetRecentFolder = Nothing | |
For Each folder in fso.GetFolder(path).SubFolders | |
version = CInt(Left(folder.Name, Instr(folder.Name, ".") - 1)) | |
If Err.Number = 0 And version > 0 Then | |
Set GetRecentFolder = folder | |
Else |