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 { execSync } from 'child_process'; | |
import pt from 'path'; | |
import os from 'os'; | |
import { createRequire } from 'module'; | |
const require = createRequire(import.meta.url); | |
const rawCommand = process.argv[2]; | |
const argv = process.argv.slice(3); |
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 crypto = require('crypto') | |
const fs = require('fs') | |
const fsPromises = fs.promises | |
const pt = require('path') | |
const fetch = require('node-fetch') | |
/** |
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 request = require('request') | |
const appId = 'xxxxxx' | |
const appSecret = 'xxxxxxxx' | |
exports.main = ({userInfo}, context) => { | |
return new Promise((resolve, reject) => { | |
request({ | |
url: `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appId}&secret=${appSecret}` |
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
//通用 promise 合并 | |
var duplicatePromiseCombine = function () { | |
var pendings = { } | |
/** | |
* @param {Function} promiseFn 原始的 promise 方法 | |
* @param {Function} keyGenFn 相同的 promise 通过该方法应该返回相同的 key | |
* @return {Function} 可合并相同 key promise 的方法 | |
*/ | |
return function (promiseFn, keyGenFn) { |
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
// ==UserScript== | |
// @name favorite item | |
// @namespace http://gmscrobber.whosemind.net | |
// @include https://www.google.com/reader/view/* | |
// @version 0.0.1 | |
// ==/UserScript== | |
document.body.addEventListener('click', function(e) { | |
var target = e.target | |
, container |
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
//give a background color, convert rgba to hex | |
var rgbaToHex = function(rgba, bgRgb){ | |
var a = rgba[3] / 255 | |
, r = Math.round((1 - a) * bgRgb[0] + a * rgba[0]).toString(16) | |
, g = Math.round((1 - a) * bgRgb[1] + a * rgba[1]).toString(16) | |
, b = Math.round((1 - a) * bgRgb[2] + a * rgba[2]).toString(16) | |
; | |
return '#' + | |
(r.length === 1 ? ('0' + r) : r) + |
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
//做滚动条的时候可能用得上 | |
window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty(); |
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
server { | |
listen 80; | |
server_name img.whosemind.net; | |
location / { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_pass http://dl.dropbox.com/u/6877098/; | |
proxy_redirect off; | |
} |
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
//a qrcode bookmarklet(二维码小书签) | |
//javascript:(function(d){var b=d.createElement("textarea"),c,f=!!d.all,a,e="http://qrcode.kaywa.com/img.php?s=5&d=%s";(c=d.getElementById("_qrcode__"))?(b=c,a=b.style,a.display=""):(a=b.style,b.id="_qrcode__",d.body[f?"attachEvent":"addEventListener"]((f?"on":"")+"click",function(){a.display="none"},!0),a.zIndex=9999,a.position="fixed",a.top=0,a.left=0,a.width="100%",a.height="100%",d.body.appendChild(b));c=function(){var a,b=d.selection,c=d.activeElement,e=top.getSelection,f=c&&c.selectionEnd;f?a=c.value.substring(c.selectionStart, f):e&&(a=e()+"");b&&(a=b.createRange().text);return a=a||location.href}();b.title=c;e=e.replace("%s",encodeURIComponent(c));a.color='#fff';a.background="rgba(0, 0, 0, 0.3) url("+e+") no-repeat center";b.select()})(document); | |
//original code | |
(function(doc){ | |
var qrcode = doc.createElement('textarea'), tmp, | |
ie = !!doc.all, style, txt, | |
qrimage = 'http://qrcode.kaywa.com/img.php?s=5&d=%s', | |
id = '_qrcode__'; |
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
//bookmarklet | |
//javascript:(function(a){var b,c=a.selection,a=a.activeElement,d=top.getSelection,e=a&&a.selectionEnd;e?b=a.value.substring(a.selectionStart,e):d&&(b=d()+"");c&&(b=c.createRange().text);b&&(location="ed2k://|search|%s|/".replace(/%s/,b))})(document); | |
//origin code | |
(function(doc){ | |
var text, | |
IEselection = doc.selection, | |
activeEle = doc.activeElement, | |
getSelection = top.getSelection, | |
selectionEnd = activeEle && activeEle.selectionEnd; |