Skip to content

Instantly share code, notes, and snippets.

View enpitsuLin's full-sized avatar
🐣
keep young, keep naive

enpitsulin enpitsuLin

🐣
keep young, keep naive
View GitHub Profile
{
"url": "http://localhost:5173/",
"name": "TON Crowdfunding",
"iconUrl": "http://localhost:5173/vite.svg"
}
@enpitsuLin
enpitsuLin / use-query.ts
Created June 18, 2024 05:57
simple react-query
const __internalStore = new Map<string, any>()
const __listeners = new Set<() => void>()
const cache = {
set(key: string, value: any) {
__internalStore.set(key, value);
__listeners.forEach(listener => listener());
},
delete(key: string) {
__internalStore.delete(key);
import type { ObjectDirective } from 'vue'
/**
* @reference https://developer.mozilla.org/en-US/docs/Web/API/ScrollTimeline
*/
declare const ScrollTimeline: any
function shouldAnimationBeStopped(animation: CSSAnimation, animationName: string | null = null) {
if (!ScrollTimeline || !(animation.timeline instanceof ScrollTimeline))
return false
const waitForElement = (/** @type {string}*/selector) => {
return new Promise((resolve) => {
const observer = new MutationObserver(() => {
const target = document.querySelector(selector)
if (target) {
observer.disconnect()
resolve()
}
})
observer.observe(document, { childList: true, subtree: true, attributes: false })
@enpitsuLin
enpitsuLin / get-async.ts
Created February 20, 2024 06:25
get an async value with useSyncExternalStore
import { useCallback, useRef, useState, useSyncExternalStore } from 'react'
type Listener = () => void
interface UseAsyncReturn<T> {
data: T | undefined
error: any
isLoading: boolean
refresh: () => void
}
@enpitsuLin
enpitsuLin / paper-plane-fold.css
Created August 7, 2023 03:20
Paper plane fold animation button
.button {
--primary: #275EFE;
--primary-dark: #2055EE;
--primary-darkest: #133FC0;
--text: #FFFFFF;
--text-opacity: 1;
--success: #2B3044;
--success-scale: .2;
--success-opacity: 0;
--border-radius: 7;
@enpitsuLin
enpitsuLin / index.md
Created August 2, 2023 02:23
export wsl images
# check name
wsl --list -v
wsl --export ${NAME_FROM_LIST} "D:\\Whereever"
# unregister it which will totally remove your file
wsl --unregister ${NAME_FROM_LIST}
🥇 六等星の夜 - Aimer
🥈 你不是真正的快樂 - Mayday
🥉 Lemon - Kenshi Yonezu
aLIEz - SawanoHiroyuki[nZ
ピースサイン - Kenshi Yonezu
打上花火 - Daoko & Kenshi Yo
/**
* expend version of van-js v0.11.10
* just for study
* @copyright Tao xin
* @link https://github.com/jorgebucaran/hyperapp
*/
import { BindFunc, ChildDom, DerivedProp, Primitive, Props, State, StateView, TagFunc, default as Van } from "./van"
// This file consistently uses `let` keyword instead of `const` for reducing the bundle size.
import { colors } from 'unocss/preset-mini'
const excludedColor = ['inherit', 'current', 'transparent', 'lightblue', 'lightBlue', 'warmgray', 'warmGray', 'truegray', 'trueGray', 'coolgray', 'coolGray', 'bluegray', 'blueGray']
const colorsRegexp = new RegExp(`theme\:(\\w+-)(${Object.keys(colors).filter(c => !excludedColor.includes(c)).join('|')})[-]?(\w+)?`, 'g')
const colorValueList = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950']
function transformerThemeColor(): SourceCodeTransformer {
return {
name: "transformer-theme-color",