Skip to content

Instantly share code, notes, and snippets.

View zerosrat's full-sized avatar

Jerry Yu zerosrat

  • Meituan
  • Chengdu
  • 09:42 (UTC +08:00)
View GitHub Profile
# for clash
git config --global http.proxy http://127.0.0.1:7890
# reset
git config --global --unset http.proxy
@zerosrat
zerosrat / index.js
Last active March 13, 2024 08:06
node ts debug config
require('./lib/bin/index.js')
function debounce(fn, ms, immediate) {
let id = null
return function(...args) {
id && clearTimeout(id)
if (immediate) {
const callNow = id === null
id = setTimeout(() => id = null, ms)
callNow && fn.apply(this, args)
} else {
id = setTimeout(() => {
const PENDING = 'pending'
const RESOLVED = 'resolved'
const REJECTED = 'rejected'
class MyPromise {
static resolve(value) {
return new Promise(resolve) {
resolve(value)
}
}
@zerosrat
zerosrat / array.js
Created March 4, 2019 12:17
array methods polyfill
Array.prototype.forEach1 = function(fn) {
const arr = this
for (let i = 0; i < arr.length; i++) {
fn.call(this, arr[i], i, arr)
}
}
Array.prototype.map1 = function(fn) {
const arr = [...this]
for (let i = 0; i < arr.length; i++) {
arr[i] = fn.call(this, arr[i], i, arr)
const curry = fn =>
judge = (...args) =>
args.length === fn.length
? fn(...args)
: (arg) => judge(...args, arg)
var arr = [3, 1, 2, 10, 4, 6, 5, 9, 8]
// quick sort
function quickSort(arr) {
if (arr.length <= 1) {
return arr
}
var midIdx = Math.floor(arr.length/2)
var midVal = arr[midIdx]
var left = []
@zerosrat
zerosrat / 大学.json
Created January 28, 2018 05:34 — forked from keysona/大学.json
中国大学名单
{
"湖南省": [
"湘潭大学",
"吉首大学",
"湖南大学",
"中南大学",
"湖南科技大学",
"长沙理工大学",
"湖南农业大学",
"中南林业科技大学",
@zerosrat
zerosrat / .npmrc
Last active November 24, 2017 09:28
registry=https://registry.npm.taobao.org
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
@zerosrat
zerosrat / .eslintrc
Last active March 27, 2019 12:52
eslint config for react app or tinny eslint config
{
"extends": "standard",
"rules": {
"space-before-function-paren": ["error", {
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}]
}
}