function count() {
var i = 0;
return function _next_() {
return i++;
};
}
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
/** | |
* @return string | |
**/ | |
export default function Hello() { | |
return "Hello"; | |
} |
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
import { promisify } from 'util'; | |
const sleep = promisify(setTimeout); | |
class WorkQueue { | |
#gen; | |
constructor() { | |
const gen = WorkQueue.#processor(); | |
gen.next(); // ignore first call | |
this.#gen = gen; |
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
find . -name '*.apk' -print0 | xargs -0 -i -n1 bash -c ' | |
aapt dump badging ${0} | tac | grep --label=${0} --max-count 1 -HoP "(?<=application-label-zh-CN:).+|(?<=application-label:).+" | |
' {} |
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
async function doRequest({ type }: { type: string }, { no }: { no: number }) { | |
} | |
type Unpacked<T> = T extends Promise<infer P> ? P : T; | |
function wrapper<T extends (...args: any[]) => any>(fn: T) { | |
return async function(...args: Parameters<T>): Promise<Unpacked<ReturnType<T>>> { | |
return await fn.apply(null, args); | |
}; | |
} |
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
class Scheduler { | |
add(promiseCreator) { | |
if (!Array.isArray(this._runnings)) { | |
this._runnings = []; | |
} | |
if (!Array.isArray(this._pendings)) { | |
this._pendings = []; | |
} | |
if (!this._tick) { | |
this._tick = function (idx) { |
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
const fs = require('fs').promises; | |
const path = require('path'); | |
async function main() { | |
const cache = {}; | |
await readdir('.', cache); | |
console.log(JSON.stringify(cache)); | |
} | |
async function readdir(dir, cache) { |
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
/** | |
* For Google Voice | |
* @Author zbinlin <[email protected]> | |
*/ | |
var sleep = delay => new Promise(resolve => setTimeout(resolve, delay)); | |
var composeClick = function x(btn) { | |
var rect = btn.getBoundingClientRect(); | |
var x = Math.floor(rect.clientX + rect.width * Math.random()); | |
var y = Math.floor(rect.clientY + rect.height * Math.random()); |
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
/* | |
* version: 0.0.4 | |
* | |
* infiniteScrolling(document.querySelector("ul"), function (el, done) { | |
* // 在此可通过 ajax 去获取分页的数据,然后可以把数据插入到 el 内(el 即是 document.querySelector("ul")) | |
* // 当插入数据完成后,如果不是最后一页,必须调用 done()。 | |
* }, 100); // 100 表示 ul 距离视口 100px 触发 callback 函数,此参数可以省略,如果省略,则距离 ul 的最后一个元素 | |
*/ | |
;(function (root, factory) { |
NewerOlder