import React, { Component, useCallback, useRef, useState } from 'react'
import { View, Text, Button } from '@tarojs/components'
import VirtualList from '@tarojs/components/virtual-list'
function buildData(offset = 0) {
return Array(100)
.fill(0)
.map((_, i) => i + offset)
}
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
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} |
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
// ==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== |
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
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); | |
}; |
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
@tailwind base; | |
@tailwind components; | |
@tailwind utilities; | |
#aside-controller:checked+aside { | |
transform: translateX(0); | |
} |
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
// 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 |
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 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()); |
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
const useForceUpdate = () => Object.assign.apply(null, useReducer(({ current }) => ({ current: current + 1 }), { current: 0 }).reverse()); | |
functioin Test() { | |
const forceUpdate = useForceUpdate(); | |
const dataMap = useMemo(() => new WeakMap(), [forceUpdate.current]); | |
} |
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 InvertedPromise() { | |
let _ = undefined; | |
return Object.assign(new Promise((resolve, reject) => { _ = { 0: resolve, 1: reject, resolve, reject } }), _); | |
} | |
function InvertedPromise() { | |
let _ = undefined; | |
return _ = new Promise((resolve, reject) => | |
Promise.resolve() | |
.then(() => Object.assign(_, { resolve, reject }))); |
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
#!/usr/bin/env bash | |
# only-dev && only execute in dev env and throw an error in other | |
# only-dev || only execute in non-dev env and do nothing in other | |
if [[ $NODE_ENV =~ ^dev ]] | |
then | |
exit 0 | |
fi | |
exit -1 |
NewerOlder