Skip to content

Instantly share code, notes, and snippets.

View GitaiQAQ's full-sized avatar
🏠
Working for home

Gitai GitaiQAQ

🏠
Working for home
View GitHub Profile
function payload<D, E>() {
const arr: { data?: D, error?: E } & ((_: any) => void)[] = [(data) => { arr.data = data }, (error) => { arr.error = error }];
return arr;
}
const useForceUpdate = () => Object.assign.apply(null, useReducer(({ current }) => ({ current: current + 1 }), { current: 0 }).reverse());
function useFetch<D, E, R = { data?: D, error?: E }>(fetcher, deps = []) {
const forceUpdate = useForceUpdate();
const ref = useRef<R>(payload());
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
// Copyright (C) 2004 Sam Hocevar <[email protected]>
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long
// as the name is changed.
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@tailwind base;
@tailwind components;
@tailwind utilities;
#aside-controller:checked+aside {
transform: translateX(0);
}
export function createPendingValue<T, Ref = any, S = never>(ref: Ref, key: keyof Ref) {
let resolve!: (v: T) => void;
let reject!: (reason?: any) => void;
const p = new Promise<T>((_resolve, _reject) => {
resolve = value => {
ref[key] = value as Ref[keyof Ref];
_resolve(value);
};
// ==UserScript==
// @name urlbox-example
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://*/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=bing.com
// @grant none
// ==/UserScript==
nvm use
npm install --location=global pnpm@${$(cat package.json | jq -r '.engines.pnpm // "latest"'):-latest}
npm install --location=global yarn@${$(cat package.json | jq -r '.engines.yarn // "latest"'):-latest}
npm install --location=global npm@${$(cat package.json | jq -r '.engines.npm // "latest"'):-latest}