Skip to content

Instantly share code, notes, and snippets.

View HuangXiZhou's full-sized avatar
:shipit:
摸鱼中(working)...

Amigooo HuangXiZhou

:shipit:
摸鱼中(working)...
View GitHub Profile
@HuangXiZhou
HuangXiZhou / QuickSort.js
Last active April 19, 2018 00:04
JavaScript QuickSort
function quickSort(arr) {
if (arr.length < 2) return arr;
const pivot = arr[~~(0 + Math.random() * arr.length)];
return [
...quickSort(arr.filter(v => v < pivot)),
...arr.filter(v => v === pivot),
...quickSort(arr.filter(v => v > pivot)),
];
@HuangXiZhou
HuangXiZhou / Lazyman.js
Created April 18, 2018 20:07
Javascript Lazyman
// Class create
class Lazyman {
constructor(name) {
this.task = [];
const fn = () => {
console.log(`Hi! This is ${name}`);
this.next();
}
this.task.push(fn);
setTimeout(() => {
@HuangXiZhou
HuangXiZhou / DataCopy.js
Created April 18, 2018 23:44
JavaScript DataCopy
// Extend copy
function extendCopy(o) {
let c = {};
for (let i in o) {
c[i] = o[i];
}
c.uber = o;
return c;
@HuangXiZhou
HuangXiZhou / Flatten.js
Created April 22, 2018 04:05
JavaScript Arrary flat functions
// Use recursion
function flatten(arr) {
let result = [];
arr.forEach(el => {
if (el instanceof Array) {
result = result.concat(flatten(el));
} else {
result.push(el);
}
});
@HuangXiZhou
HuangXiZhou / LruCache.js
Created April 27, 2018 00:17
JavaScript LruCache
class LruCache {
constructor(maxsize) {
this._cache = {}; // 缓存
this._queue = []; // 队列
this._maxsize = maxsize; // 最大值
// 如果最大值输入非法 默认无限大
if (!this._maxsize || !(typeof this._maxsize === 'number') || this._maxsize <= 0) {
this._maxsize = Infinity;
}
@HuangXiZhou
HuangXiZhou / FBI.sh
Created February 1, 2019 07:20
FBI WARNING
# _/_/_/_/ _/_/_/ _/_/_/
# _/ _/ _/ _/
# _/_/_/ _/_/_/ _/
# _/ _/ _/ _/
# _/ _/_/_/ _/_/_/
_COLUMNS=$(tput cols)
_MESSAGE=" FBI Warining "
y=$((($_COLUMNS - ${#_MESSAGE}) / 2))
spaces=$(printf "%-${y}s" " ")
@HuangXiZhou
HuangXiZhou / former-doc.css
Created February 8, 2019 05:13
former doc style
.vuepress-plugin-demo-block__wrapper .vuepress-plugin-demo-block__footer:hover .vuepress-plugin-demo-block__expand::before,
.vuepress-plugin-demo-block__wrapper .vuepress-plugin-demo-block__footer:focus .vuepress-plugin-demo-block__expand::before,
.vuepress-plugin-demo-block__wrapper .vuepress-plugin-demo-block__footer:visited .vuepress-plugin-demo-block__expand::before {
border-top-color: #2B66C4 !important;
border-bottom-color: #2B66C4 !important;
}
.vuepress-plugin-demo-block__wrapper .vuepress-plugin-demo-block__footer .vuepress-plugin-demo-block__expand::before,
.vuepress-plugin-demo-block__wrapper .vuepress-plugin-demo-block__footer svg {
transition: all .2s ease;
@HuangXiZhou
HuangXiZhou / toUnderscore.js
Created February 20, 2019 15:22
toUnderscore
function toUnderscore(string) {
return string.toString().split(/(?=[A-Z])/).join('_').toLowerCase();
};
@HuangXiZhou
HuangXiZhou / AM.gif
Last active April 11, 2019 14:18
AM
AM.gif