Skip to content

Instantly share code, notes, and snippets.

@Misaka-0x447f
Misaka-0x447f / ESP32-2432-CYD-Download.md
Last active April 4, 2024 15:31
ESP32-1732/2432/3248/4827/4848/8048/2424 Cheap Yellow Display Demo/Spec/Manual Download Link

Manufactor provided infomations

Download: http://pan.jczn1688.com/1/ESP32%20module Manufactor: 深圳市晶彩智能有限公司 Shenzhen Jingcai Intelligent Co., Ltd

About ending alphabet of model

N: Without touch; R: Resistive touch; C: Capacitive touch;

Overview

The following information was manually extracted from documents above. Contribution is welcomed.

// TL/DR ⬇️ source: https://fettblog.eu/typescript-react-generic-forward-refs/
const ClickableList = React.forwardRef(ClickableListInner) as <T>(
props: ClickableListProps<T> & { ref?: React.ForwardedRef<HTMLUListElement> }
) => ReturnType<typeof ClickableListInner>;
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@Misaka-0x447f
Misaka-0x447f / extended-get.js
Created May 18, 2023 09:27
面试记录>Extended get method
const getx = (input, expression) => {
if (!expression.length) return input
expression = expression.split('.')
const arrayMatch = expression[0].match(/(?<propName>\w+)\[(?<number>\d+)]/)
const functionMatch = expression[0].match(/(?<propName>\w+)\((?<arguments>.*)\)/)
if (arrayMatch) {
return getx(input[arrayMatch.groups.propName][arrayMatch.groups.number], expression.slice(1).join('.'))
}
if (functionMatch) {
const argString = functionMatch.groups.arguments.split(',')
@Misaka-0x447f
Misaka-0x447f / 面试记录>链表大整数加法.ts
Created April 6, 2023 05:02
面试记录>链表大整数加法.ts
interface BigIntLinkList {
next: BigIntLinkList | null;
value: number
}
const reverseLinkListInPlace = (origin: BigIntLinkList) => {
if (!origin.next) return origin
let newOrigin = {
next: null,
value: origin.value
import { first, last, uniqueId } from 'lodash';
import { useEffect, useState } from 'react';
import { useMixedState } from './hooks';
let startAt = 1000;
const inUseList: { index: number; key: string; comment?: string }[] = [];
export const setStartingZIndex = (index: number) => (startAt = index);
/**
* @author 447f.misaka@outlook.com
@Misaka-0x447f
Misaka-0x447f / useHybridState.ts
Last active May 25, 2024 12:30
useHybridState.ts
import { isFunction } from 'lodash-es'
import {
useCallback,
useRef,
useState,
useMemo,
Dispatch,
SetStateAction,
DependencyList,
useEffect
// recursive magic
export type Tail<T extends any[]> = T['length'] extends 0
? never
: ((...b: T) => void) extends (a: any, ...b: infer I) => void
? I
: [];
// Type of { ...L, ...R }
// Properties in L that don't exist in R plus R
type _TypeAssignWorker<L, R> = Pick<L, Exclude<keyof L, keyof R>> & R;
const musicNotify = () => {
const m = '/storage/emulated/0/Download/WeiXin/平凡之路.mp3'
media.playMusic(m);
sleep(media.getMusicDuration());
}
const to_mall_cart = () => {
shopping_cart_btn=id('img_shopping_cart').findOne()
@Misaka-0x447f
Misaka-0x447f / React 组件设计范式:调用子组件的方法.md
Last active February 17, 2022 08:12
React 组件设计范式:调用子组件的方法

本文不考虑各种写法的 CPU 时间开销,只考虑各种写法的开发人员时间开销。

可能是最糟糕的方法:使用 ref 保存指向组件实例的指针

ref 以及其衍生的 forwardRef 是 React 直接提供给组件设计人员的工具,但我个人并不推荐用 ref,也不是很推荐用 forwardRef。 不推荐 ref 的原因:

  • 函数式组件没有实例,不能通过 ref 访问其实例。
  • 需要新建一个变量,且其初始类型一定为 null,在使用时需要判断。 不太推荐在跨组件场景下用 forwardRef 的原因:
  • 函数式组件没有实例。
  • 虽然无论如何都要保留一个联系子组件的"指针",但可能有更好的方法,从而不需要将该"指针"存储于单独的位置(而不是组件内部),造成更多的多实例场景下的麻烦。当然,对于子组件联系亲代组件,仍需将该指针保存于单独的位置。

替代方案