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 parseStackTrace(stack){ | |
return stack.split('\n').map(parseStackLine).filter(Boolean); | |
} | |
const V8_OUTER1 = /^\s*(eval )?at (.*) \((.*)\)$/; | |
const V8_OUTER2 = /^\s*at()() (\S+)$/; | |
const V8_INNER = /^\(?([^\(]+):(\d+):(\d+)\)?$/; | |
function parseStackLine(line){ |
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 sleep1 = (time = 1) => { | |
return fn => { | |
setTimeout(() => fn(null, time), time * 1000); | |
}; | |
} | |
const sleep2 = (time = 1) => new Promise(resolve => { | |
setTimeout(() => resolve(time), time * 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
#!/usr/bin/env node | |
const [ name, fn ] = process.argv.slice(2); | |
const d = []; | |
process.stdin | |
.on('data', d.push.bind(d)) | |
.on('end', () => { | |
let data = JSON.parse(d.join('')); | |
if(name){ |
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/sh | |
export PATH="/opt/bin:$PATH" | |
export LD_LIBRARY_PATH=/lib:/opt/lib | |
killall frpc frps | |
mkdir -p /tmp/frp | |
cat > "/tmp/frp/frpc.ini" <<-\EOF | |
[common] |
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 clone = obj => { | |
const typeOf = o => | |
({}).toString.call(o).match(/\[object (\w+)\]/)[1]; | |
if(typeOf(obj) !== 'Object') | |
throw new TypeError('must be an object'); | |
var out = {}; | |
for(let attr in obj){ | |
const item = obj[attr]; | |
switch(typeOf(item)){ |
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
// Powered by proxy.lsong.org | |
var proxy = [ | |
{ type: 'SOCKS5', proxy: 'gateway.lsong.org:1080' }, | |
{ type: 'SOCKS' , proxy: 'gateway.lsong.org:1080' }, | |
'DIRECT' | |
].map(function(p){ | |
if(typeof p === 'string') return p; | |
return [ p.type, p.proxy ].join(' '); | |
}).join('; '); |
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
var c = 0; | |
var n = 50; | |
while(n) n = (c++, n&(n-1)); | |
while(n) (n >>= 1 & 1) && c++; | |
console.log(c); |
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 fs = require('fs'); | |
const headers = [ | |
'TEMP', 'HUMI', | |
'PM1.0','PM2.5','PM10','PM1.0_US','PM2.5_US','PM10_US', | |
'>0.3um', '>0.5um', '>1.0um', '>2.5um', '>5.0um', '>10um', | |
'HCHO', 'TVOC' | |
]; | |
const readWCLH = (fd, done) => { |
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 get = (obj, path) => path.split('.').reduce((o, p) => o && o[p], obj); |
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 fs = require('fs'); | |
const path = require('path'); | |
const resolve = require('resolve'); | |
const rImport = /import\s+(.+)\s+from\s+['"]([^'"]+)['"]/; | |
const rRequire = /require\s*\(['"]([^'")]+)['"]\)/; | |
const parseDeps = name => { | |
return fs.readFileSync(name, 'utf8') | |
.replace(/\/\*[\s\S]*?\*\//g, '') // block-comment |