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
| 'use strict'; | |
| /** | |
| * Created by zyf on 17-4-19. | |
| */ | |
| let i; | |
| let times = 10, | |
| delay = 100; | |
| let startTime, lastTime, now, durations; | |
| const workNum = 100000; |
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
| const wrapGenerator = function (Generator) { | |
| const promise = new Promise(function (resolve, reject) { | |
| const g = Generator() | |
| let r = g.next() | |
| const nextYield = function (r) { | |
| if (r.done == true) { | |
| resolve(r.value) | |
| return | |
| } | |
| r.value.then(function (x) { |
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
| const numsNum = 10 | |
| const nums = '0'.repeat(numsNum).split('').map(() => parseInt(Math.random() * 100) + 1) | |
| console.log('before sort', nums) | |
| const arrs = [] | |
| let push = 0 | |
| // 这里的循环说明了空间使用是 O(n2) | |
| for (const num of nums) { |
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
| let id = 1 | |
| function Promise(executor) { | |
| this.id = id++ | |
| this.status = 'pending' | |
| this.value = null | |
| this._next = null | |
| const response = (status, v) => { | |
| if (this.status != 'pending') { | |
| return | |
| } |
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
| #!/bin/env bash | |
| set -euo pipefail | |
| function _d() { | |
| echo `date +%Y%m%d-`$1 | |
| } | |
| cd /var/log/nginx | |
| h=$((`date +%H`-1)) | |
| if [ $h = -1 ]; then | |
| h=23 |
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
| class TaskList { | |
| constructor(tasks) { | |
| this.tasks = tasks | |
| this.promise = null | |
| this.index = 0 | |
| this.fowarding = false | |
| } | |
| async start() { | |
| this.fowarding = 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
| javascript:var multiEle=document.getElementsByClassName('MreMs')[0];var i=(multiEle!=null)?multiEle.style.transform.slice(12, -3)/480:0; var img=document.getElementsByClassName('ZyFrc')[0].getElementsByClassName('FFVAD')[i];window.open(img.src) |
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
| /** | |
| * dic.txt 内每行类似 'a'ba 阿巴 | |
| * 先组合声母韵母,然后再完整替换 | |
| * 对于零声母音节,声母当作空字符 | |
| **/ | |
| const fs = require('fs') | |
| // 声母 | |
| const shengmu = { |
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
| 'use strict' | |
| function resolver(o) { | |
| return new Promise((res) => { | |
| setTimeout(() => { | |
| console.log(Date.now(), 'prepare end', o.service) | |
| res() | |
| }, 1000) | |
| }) | |
| } |
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
| const cp = require("child_process") | |
| const fs = require("fs/promises") | |
| const path = require("path") | |
| try { | |
| cp.execSync("npx tsc --noEmit") | |
| } catch (e) { | |
| const output = e.stdout.toString() | |
| const regexp = /^(.+\.ts)\((\d+?),(\d+?)\): error TS411(4|6):.+/ | |
| const overrideFiles = output.split("\n").reduce((m, line) => { | |
| const result = line.match(regexp) |
OlderNewer