This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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; | |
} |
This file contains hidden or 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 solution(line) { | |
const [ll, lr] = line.split(" "); | |
const arr = ll.split(",").map(a => a * 1); | |
const target = lr * 1; | |
return ret; | |
} |
This file contains hidden or 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 checkOpen() { | |
const clickTime = Date.now(); | |
let timeout; | |
let count = 0; | |
return new Promise((resolve, reject) => { | |
const interval = setInterval(() => { | |
count++; | |
timeout = Date.now() - clickTime > 3000; | |
if (count >= 10 || timeout) { | |
clearInterval(interval); |
This file contains hidden or 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; |
NewerOlder