Skip to content

Instantly share code, notes, and snippets.

Avatar
🇨🇳
Hi~!

JerryC JerryC8080

🇨🇳
Hi~!
View GitHub Profile
@JerryC8080
JerryC8080 / index.ts
Created Jan 6, 2021
simple store use 'useRedux' and 'useContext'
View index.ts
/**
* 简易 Store
*
* 使用:
*
* 1. 使用 Provider HOC
*
* ```jsx
* <Provider>
* <Child />
@JerryC8080
JerryC8080 / setter.js
Last active Jan 1, 2021
简易 _.set & _.get
View setter.js
const setter = (obj, key, value) => {
const keys = key.split(".");
const pres = keys.slice(0, -1);
const last = keys[keys.length - 1];
const deepObj =
keys.length === 1
? obj
: pres.reduce((curObj, curKey) => {
// eslint-disable-next-line no-param-reassign
if (!curObj[curKey]) curObj[curKey] = {};
@JerryC8080
JerryC8080 / typescript
Created Sep 22, 2020
深度构造类型 DeepRecord
View typescript
/**
* MAP: 需要遍历的类型
* MATCH: 断言类型
* TYPE: 需要改变的类型
*/
export type DeepRecord<MAP, MATCH, TO> = {
[P in keyof MAP]: MAP[P] extends MATCH ? TO : DeepRecord<MAP[P], MATCH, TO>;
};
@JerryC8080
JerryC8080 / package.json
Created May 25, 2019 — forked from cnwhy/package.json
处理 termtosvg 录制的SVG 对中文显示不友好的问题
View package.json
{
"name": "termtosvg-CN-fix",
"version": "0.0.1",
"bin": "./termtosvg-fix.js",
"dependencies": {
"commander": "^2.19.0"
}
}
@JerryC8080
JerryC8080 / proxy.js
Created Nov 30, 2016 — forked from ruanyf/proxy.js
使用 Proxy 实现观察者模式
View proxy.js
// 实现
const queuedObservers = new Set();
const observe = fn => queuedObservers.add(fn);
const observable = obj => new Proxy(obj, {set});
function set(target, key, value, receiver) {
const result = Reflect.set(target, key, value, receiver);
queuedObservers.forEach(observer => observer());
return result;
@JerryC8080
JerryC8080 / outOfHeap.js
Last active Oct 30, 2016
内存泄漏脚本
View outOfHeap.js
/**
* 泄露V8 Heap内存
*/
let total = [];
function useMem() {
let size = 1024 * 1024 * 20; // Per 20MB
let arr = new Array(size);
for (let i = 0; i < size; i++) {
@JerryC8080
JerryC8080 / git_toturial
Created May 26, 2016 — forked from guweigang/git_toturial
git命令大全
View git_toturial
git init # 初始化本地git仓库(创建新仓库)
git config --global user.name "xxx" # 配置用户名
git config --global user.email "xxx@xxx.com" # 配置邮件
git config --global color.ui true # git status等命令自动着色
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global --unset http.proxy # remove proxy configuration on git
git clone git+ssh://git@192.168.53.168/VT.git # clone远程仓库
@JerryC8080
JerryC8080 / gist:cbeb6011e33445ac2d5d
Created Mar 27, 2016 — forked from AliMD/gist:3344523
All github Emoji (Smiles)
View gist:cbeb6011e33445ac2d5d

All github Emoji (Smiles)

ali.md/emoji

:bowtie: | 😄 | 😆 | 😊 | 😃 | ☺️ | 😏 | 😍 | 😘 | :kissing_face: | 😳 | 😌 | 😆 | 😁 | 😉 | :wink2: | 👅 | 😒 | 😅 | 😓

😩 | 😔 | 😞 | 😖 | 😨 | 😰 | 😣 | 😢 | 😭 | 😂 | 😲 | 😱 | :neckbeard: | 😫 | 😠 | 😡 | 😤 | 😪 | 😋 | 😷

😎 | 😵 | 👿 | 😈 | 😐 | 😶 | 😇 | 👽 | 💛 | 💙 | 💜 | ❤️ | 💚 | 💔 | 💓 | 💗 | 💕 | 💞 | 💘 |

@JerryC8080
JerryC8080 / RexChainesPhone.js
Created Mar 21, 2016
匹配中国电话号码的正则表达式
View RexChainesPhone.js
/**
电信
中国电信手机号码开头数字
2G/3G号段(CDMA2000网络)133、153、180、181、189
4G号段 177
联通
中国联通手机号码开头数字