Skip to content

Instantly share code, notes, and snippets.

View JerryC8080's full-sized avatar
🇨🇳
Hi~!

JerryC JerryC8080

🇨🇳
Hi~!
View GitHub Profile
@JerryC8080
JerryC8080 / RexChainesPhone.js
Created March 21, 2016 08:08
匹配中国电话号码的正则表达式
/**
电信
中国电信手机号码开头数字
2G/3G号段(CDMA2000网络)133、153、180、181、189
4G号段 177
联通
中国联通手机号码开头数字
@JerryC8080
JerryC8080 / index.ts
Created January 6, 2021 09:18
simple store use 'useRedux' and 'useContext'
/**
* 简易 Store
*
* 使用:
*
* 1. 使用 Provider HOC
*
* ```jsx
* <Provider>
* <Child />
@JerryC8080
JerryC8080 / setter.js
Last active January 1, 2021 06:44
简易 _.set & _.get
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 September 22, 2020 10:08
深度构造类型 DeepRecord
/**
* 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 10:06 — forked from cnwhy/package.json
处理 termtosvg 录制的SVG 对中文显示不友好的问题
{
"name": "termtosvg-CN-fix",
"version": "0.0.1",
"bin": "./termtosvg-fix.js",
"dependencies": {
"commander": "^2.19.0"
}
}
@JerryC8080
JerryC8080 / example
Last active October 28, 2017 05:53
paginate helper
var paginate = require('handlebars-paginate');
Handlebars.registerHelper('paginate', paginate);
/* ... */
var html = template({pagination: {
page: 3,
pageCount: 10
}});
@JerryC8080
JerryC8080 / proxy.js
Created November 30, 2016 04:41 — forked from ruanyf/proxy.js
使用 Proxy 实现观察者模式
// 实现
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 October 30, 2016 14:45
内存泄漏脚本
/**
* 泄露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 02:21 — forked from guweigang/git_toturial
git命令大全
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远程仓库