Skip to content

Instantly share code, notes, and snippets.

View jinwoo's full-sized avatar

Jinwoo Lee jinwoo

  • Google
  • SF Bay Area, CA
View GitHub Profile
@jinwoo
jinwoo / index.js
Last active May 26, 2018 00:03
trace event
const CDP = require('chrome-remote-interface');
const minimist = require('minimist');
const args = minimist(process.argv.slice(2), {
alias: {port: 'p'},
default: {port: 9222},
});
async function main() {
const client = await CDP({port: args.port});
0 info it worked if it ends with ok
1 verbose cli [ '/Users/jinwoo/.nvm/versions/node/v10.1.0/bin/node',
1 verbose cli '/Users/jinwoo/.nvm/versions/node/v10.1.0/bin/npm',
1 verbose cli 'up',
1 verbose cli 'cosmiconfig' ]
2 info using npm@6.1.0
3 info using node@v10.1.0
4 verbose npm-session 5a012709bdb9e331
5 verbose update computing outdated modules to update
6 silly mapToRegistry name cosmiconfig
@jinwoo
jinwoo / console.txt
Created May 8, 2018 20:06
Node trace events testing
$ npm start
> trace-events@1.0.0 start /Users/jinwoo/src/trace-events
> node index.js
supported categories:
node
node.async
node.bootstrap
node.perf
const fastify = require('fastify');
const fastifyAutoPush = require('fastify-auto-push');
const fs = require('fs');
const path = require('path');
const {promisify} = require('util');
const fsReadFile = promisify(fs.readFile);
const STATIC_DIR = path.join(__dirname, 'static');
const CERTS_DIR = path.join(__dirname, 'certs');
for (const asset of ['/static/awesome.css', '/static/unicorn.png']) {
// stream is a ServerHttp2Stream.
stream.pushStream({':path': asset}, (err, pushStream) => {
if (err) throw err;
pushStream.respondWithFile(asset);
});
}
<!DOCTYPE html>
<html>
<head>
<title>Awesome Unicorn!</title>
<link rel="stylesheet" type="text/css" href="/static/awesome.css">
</head>
<body>
This is an awesome Unicorn! <img src="/static/unicorn.png">
</body>
</html>