Skip to content

Instantly share code, notes, and snippets.

@riskers
riskers / tsconfig.json
Created August 7, 2024 17:58 — forked from MrFunctor/tsconfig.json
tsconfig.json with common fp-ts namespace imports configured with @unsplash/ts-namespace-import-plugin
{
"compilerOptions": {
"plugins": [
{
"name": "@unsplash/ts-namespace-import-plugin",
"namespaces": {
"A": {
"importPath": "fp-ts/Array"
},
"B": {
@riskers
riskers / BinanceWallet.ts
Created May 5, 2023 14:51 — forked from jeftarmascarenhas/BinanceWallet.ts
Connector to Binance on Wagmi
import {
ConnectorNotFoundError,
UserRejectedRequestError,
RpcError,
ResourceUnavailableError,
SwitchChainNotSupportedError,
} from "wagmi";
import { InjectedConnector } from "wagmi/connectors/injected";
import { Chain, Ethereum } from "@wagmi/core";
@riskers
riskers / fridaUtils.js
Created March 3, 2023 09:52 — forked from rodnt/fridaUtils.js
Bytes to hex, string to bytes, bytes to string
/**
*
* Author: __rodx00__
*
* Usefull functions while reversing frida scripts.
*/
function bin2ascii(array) {
var result = [];
@riskers
riskers / README.md
Last active May 7, 2024 12:48
Nodejs 环境管理 - nvm

nvm

添加镜像

export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node

config

@riskers
riskers / README.md
Last active October 15, 2023 06:12
Python 环境管理 - conda
@riskers
riskers / App.tsx
Last active January 6, 2022 14:45
自定义 React Hook - useDevice (判断设备尺寸)
const App = () => {
const device = useDevice();
return <div className={getClassName(device)}>
Test
</div>
}
@riskers
riskers / App.tsx
Last active January 5, 2022 09:23
自定义 React Hook - react-intl-universal 国际化
import { useCookies } from "react-cookie";
import { Tab, TabList, TabPanel, Tabs } from "react-tabs";
import styles from "./style.module.css";
import { useLocale } from "@/locales/i18n";
const App = () => {
// 这里获取 intl
const __ = useLocale();
return <div>
@riskers
riskers / ClickHouse.md
Last active August 22, 2024 07:28
Installing development software by Docker and brew
docker run -d --name clickhouse-server --ulimit nofile=262144:262144 -p 8123:8123 -p 9000:9000 -p 9009:9009 --privileged=true -v ~/db/clickhouse/log:/var/log/clickhouse-server -v ~/db/clickhouse/data:/var/lib/clickhouse clickhouse/clickhouse-server:22.1.4.30

然后 http://localhost:8123 验证.

使用客户端:

> docker exec -it clickhouse-server /bin/bash
@riskers
riskers / app.tsx
Last active August 12, 2023 20:27
make material-ui dialog component imperative by react context hook
import { useDialog } from "@/components/dialog/index";
import DialogTitle from "@material-ui/core/DialogTitle";
const App = () => {
const [openDialog, closeDialog] = useDialog();
return <button
href="#!"
onClick={() => {
openDialog({
@riskers
riskers / HOC.md
Last active September 24, 2020 07:49
react HOC / render props / hook

高阶组件:接收函数作为输入,或者输出另一个函数的一类函数,被称作高阶函数。对于高阶组件,它描述的便是接受React组件作为输入,输出一个新的React组件的组件。即高阶组件通过包裹(wrapped)被传入的React组件,经过一系列处理,最终返回一个相对增强(enhanced)的React组件,供其他组件调用。

什么时候使用高阶组件:在React开发过程中,发现有很多情况下,组件需要被"增强",比如说给组件添加或者修改一些特定的props,一些权限的管理,或者一些其他的优化之类的。而如果这个功能是针对多个组件的,同时每一个组件都写一套相同的代码,明显显得不是很明智,所以就可以考虑使用HOC。

react-redux 的 connect 方法就是一个 HOC ,他获取 wrappedComponent ,在 connect 中给 wrappedComponent 添加需要的 props。

最基本的一个 HOC

// define