把连续的字符替换掉, 比如把连续的 '/' 替换为 '/', 来自 这里
const prettyPath = urlObj.pathname.replace(/\/{2,}/g, "/");
<html> | |
<head> | |
<style> | |
html, | |
body { | |
/* set height of html and body both to 100% to fill the page */ | |
height: 100%; | |
width: 100%; | |
margin: 0px; |
把连续的字符替换掉, 比如把连续的 '/' 替换为 '/', 来自 这里
const prettyPath = urlObj.pathname.replace(/\/{2,}/g, "/");
function jsonStr(obj, indent) { | |
return JSON.stringify( | |
obj, | |
// default result of JSON.stringify() for RegExp object is {} | |
(key, value)=> { | |
if (value instanceof RegExp) { | |
return value.toString(); // RegExp.toString() returns string like '/\\.(t|j)sx?$/' | |
} | |
return value; | |
}, |
// reference: https://zh.wikipedia.org/wiki/%E9%A2%9C%E8%89%B2%E5%B7%AE%E5%BC%82 | |
// 1. CIEDE2000 uses Lab which is a color format that better to tell the difference by human vision. | |
// 2. There is no directly conversion from RGB to Lab, but RGB to XYZ to Lab. | |
// https://github.com/gfiumara/CIEDE2000/blob/master/CIEDE2000.cpp | |
constexpr double | |
CIEDE2000::deg2Rad( | |
const double deg) | |
{ | |
return (deg * (M_PI / 180.0)); |
// https://github.com/pksunkara/octonode | |
const github = require('octonode') | |
// get one page of starred repos | |
// starred() is a Pagination API: https://github.com/pksunkara/octonode#pagination | |
function _getPageStarred (ghme, page) { | |
return new Promise(function (resolve, reject) { | |
ghme.starred(page, (err, repoList) => { | |
err ? reject(err) : resolve(repoList) | |
}) |
/* usage: | |
* const iStream = fs.createReadStream('./oceans.mp4'); | |
* | |
* const mStream = new ChecksumStream('md5'); | |
* mStream.on('done', function(sum) { | |
* console.log(sum); | |
* }) | |
* | |
* const oStream = fs.createWriteStream('o/oceans.mp4'); | |
* |
# switch sources of Homebrew | |
_brewsrc() { | |
# save current working dir | |
pwd=$(PWD) | |
if [ "$1" = "0" ]; then | |
echo "restore brew source to default" | |
cd "$(brew --repo)" | |
git remote set-url origin https://github.com/Homebrew/brew.git | |
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" |