Skip to content

Instantly share code, notes, and snippets.

View zh30's full-sized avatar
🐲

Henry Zhang zh30

🐲
View GitHub Profile
@zh30
zh30 / module1.js
Last active June 30, 2020 09:26
闭包
function JsModule() {
const someThing = 'zhanghe';
const anOther = 'cool';
function doSomeThing() {
console.log(someThing);
}
function doAnOther() {
console.log(anOther);
@zh30
zh30 / bindPolyfill.js
Last active July 2, 2020 06:35
关于 This
// Does not work with `new funcA.bind(thisArg, args)`
if (!Function.prototype.bind) (function(){
var slice = Array.prototype.slice;
Function.prototype.bind = function() {
var thatFunc = this, thatArg = arguments[0];
var args = slice.call(arguments, 1);
if (typeof thatFunc !== 'function') {
// closest thing possible to the ECMAScript 5
// internal IsCallable function
throw new TypeError('Function.prototype.bind - ' +
@zh30
zh30 / mixin.js
Last active July 20, 2020 03:22
function mixin(sourceObj, targetObj) {
for (var key in sourceObj) {
if (!(key in targetObj)) {
targetObj[key] = sourceObj[key];
}
}
return targetObj;
}
@zh30
zh30 / padNumber.js
Last active July 26, 2020 11:59
PadNumber
function padNumber(number, length) {
return (new Array(length).join('0')+number).slice(-length)
}
@zh30
zh30 / matrix.js
Created July 28, 2020 13:48
创建二维数组
Array.matrix = function(numrows, numcols, initial) {
var arr = [];
for (var i = 0; i < numrows; i++) {
var columns = [];
for (var j = 0; j < numcols; j++) {
columns[j] = initial;
}
arr[i] = columns;
}
@zh30
zh30 / emojis.json
Created July 29, 2020 07:00 — forked from oliveratgithub/emojis.json
Emoji-list with emojis, names, shortcodes, unicode and html entities [massive list]
{
"emojis": [
{"emoji": "👩‍👩‍👧‍👧", "name": "family: woman, woman, girl, girl", "shortname": ":woman_woman_girl_girl:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F467", "html": "&#128105;&zwj;&#128105;&zwj;&#128103;&zwj;&#128103;", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👧‍👦", "name": "family: woman, woman, girl, boy", "shortname": ":woman_woman_girl_boy:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F466", "html": "&#128105;&zwj;&#128105;&zwj;&#128103;&zwj;&#128102;", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👦‍👦", "name": "family: woman, woman, boy, boy", "shortname": ":woman_woman_boy_boy:", "unicode": "1F469 200D 1F469 200D 1F466 200D 1F466", "html": "&#128105;&zwj;&#128105;&zwj;&#128102;&zwj;&#128102;", "category": "People & Body (family)", "order": ""},
{"emoji": "👨‍👩‍👧‍👧", "name": "family: man, woman, girl, girl", "shortname": ":man_woman_girl_girl:", "unicode": "1F468 200D 1F469 200D 1F467 200D 1F467", "html": "&#128104;&zwj;&#128105;&z
@zh30
zh30 / manjaro-change-default-browser.md
Created November 19, 2020 13:08 — forked from boo1ean/manjaro-change-default-browser.md
manjaro-change-default-browser.md

Update $BROWSER env var

vim ~/.profile

export BROWSER=/usr/bin/google-chrome-stable

Remove mime bindings

@zh30
zh30 / html-tag-article.html
Last active April 23, 2021 03:09
HTML <article> 元素表示文档、页面、应用或网站中的独立结构,其意在成为可独立分配的或可复用的结构,如在发布中,它可能是论坛帖子、杂志或新闻文章、博客、用户提交的评论、交互式组件,或者其他独立的内容项目。
<article class="forecast">
<h1>Weather forecast for Seattle</h1>
<article class="day-forecast">
<h2>03 March 2018</h2>
<p>Rain.</p>
</article>
<article class="day-forecast">
<h2>04 March 2018</h2>
<p>Periods of rain.</p>
</article>
@zh30
zh30 / DebounceSelect.tsx
Created December 16, 2021 01:35
动态搜索 select react 组件
import { useState, ReactNode, useRef, useMemo } from 'react';
import { Select, Spin } from 'antd';
import { SelectProps } from 'antd/es/select';
import debounce from 'lodash/debounce';
export interface DebounceSelectProps<ValueType = any>
extends Omit<SelectProps<ValueType>, 'options' | 'children'> {
fetchOptions: (search: string) => Promise<ValueType[]>;
debounceTimeout?: number;
defaultOptions?: ValueType[];