This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div ref="wrapper"> | |
<div :key="tableKey"> | |
<slot></slot> | |
</div> | |
</div> | |
</template> | |
<script> | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async function parallelTask(task, shouldEnd, max) { | |
let i = 0; | |
let runningCnt = 0; | |
return new Promise((resolve, reject) => { | |
function check() { | |
if (shouldEnd(i)) { | |
return; | |
} | |
if (runningCnt > max) { | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function preloadImage(src) { | |
const $dom = $("<img />", { | |
src | |
}); | |
if ($dom[0].naturalWidth) { | |
return Promise.resolve($dom); | |
} | |
$dom.css({ | |
opacity: 0.01, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function compress(canvasDom, size){ | |
let ratio = 1; | |
let dataurl; | |
do { | |
dataurl = canvasDom.toDataURL("image/jpeg", ratio); | |
ratio -= 0.1; | |
if (ratio < 0.3) { | |
return null; | |
} | |
} while (dataurl.length > size/3*4); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date.prototype.format = function(format) { | |
const zeros = ["", "0", "00", "000"]; | |
const c = { | |
"M+": this.getMonth() + 1, | |
"d+": this.getDate(), | |
"h+": this.getHours(), | |
"m+": this.getMinutes(), | |
"s+": this.getSeconds(), | |
"q+": Math.floor((this.getMonth() + 3) / 3), | |
"S+": this.getMilliseconds() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function addParam(url, key, value) { | |
url = url.replace(new RegExp(`[?&]${key}=[^&]*&?`, 'g'), str => (str[str.length - 1] === "&" ? str[0] : "")); | |
const hashReg = /#[\w-]+$/; | |
let hash = url.match(hashReg) || []; | |
hash = hash[0] || ""; | |
url = url.replace(hashReg, ""); | |
let linkSymbol = "&"; | |
if (url.indexOf("?") === -1) { | |
linkSymbol = "?"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# Path to your oh-my-zsh installation. | |
export ZSH="/home/blackmiaool/.oh-my-zsh" | |
# Set name of the theme to load --- if set to "random", it will | |
# load a random theme each time oh-my-zsh is loaded, in which case, | |
# to know which specific one was loaded, run: echo $RANDOM_THEME | |
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# shorten up prompt | |
echo "PS1=\"\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@xiaomi:\[\033[01;34m\]\w\[\033[00m\]\$ \"" >> ~/.bashrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu | |
RUN apt-get update | |
RUN apt-get install -y man emacs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getCircularKeys(obj,opt={left:100}){ | |
if(!obj||typeof obj!=='object'){ | |
return ; | |
} | |
let keys=Object.keys(obj); | |
function appendKeys(keys){ | |
opt.left-=keys.length; | |
if(opt.left<=0){ | |
return true; | |
} |
NewerOlder