Skip to content

Instantly share code, notes, and snippets.

View coreylight's full-sized avatar
🚚
Up and up

Corey Light coreylight

🚚
Up and up
View GitHub Profile
function hrMillis(measure) {
return (measure[0] * 1000) + (measure[1] / 1e6);
}
const millis = hrMillis(endTime);
console.log(millis);
// 8210.181641
function hrMillis(measure) {
return (measure[0] * 1000) + (measure[1] / 1e6);
}
const databaseStartTime = process.hrtime();
await runTheDatabaseCall();
const databaseMeasure = process.hrtime(databaseStartTime);
const analyticsStartTime = process.hrtime();
await analyticsCall();
// for browsers, ya silly!
performance.mark('start-party');
runThePartyAnimation();
performance.mark('end-party');
performance.measure('party-measure', 'start-party', 'end-party');
const measure = performance.getEntriesByType('measure')[0];
const Perf = require('performance-node');
const timeline = new Perf();
timeline.mark('ai-start');
runMachineLearning();
timeline.mark('ai-end');
timeline.measure('ai-measure', 'ai-start', 'ai-end');
const myMeasure = timeline.getEntriesByName('ai-measure')[0];
// {name: 'ai-measure', startTime: 1.2, duration: 10.5, entryType: 'measure'}
const iopipeLib = require('iopipe');
const profiler = require('@iopipe/profiler');
const iopipe = iopipeLib({
token: 'TOKEN_HERE',
plugins: [profiler({ enabled: true })]
});
exports.handler = iopipe((event, context) => {
context.succeed('Whoomp there it is!')
});
@coreylight
coreylight / iopipeWrapper.js
Last active February 14, 2018 14:26
IOpipe with plugins for webpack
const iopipe = require('@iopipe/core');
const eventInfoPlugin = require('@iopipe/event-info');
const tracePlugin = require('@iopipe/trace');
module.exports = iopipe({
plugins: [
tracePlugin(),
eventInfoPlugin()
]
});
@coreylight
coreylight / app.js
Created February 20, 2018 16:44
Example for claudia.js
// app business logic code here
const {context} = require('./context');
module.exports = () => {
// I'm inside a single lambda invocation!
context.iopipe.log('wow');
}
@coreylight
coreylight / code.js
Created April 12, 2019 16:30
Hide Twitter sidebar
javascript:((() => {var main=document.querySelector("main");const getEl=()=>document.querySelector('[data-testid="sidebarColumn"]');var obsv=new MutationObserver(e=>{var t=getEl();main.contains(t)&&t.remove()});obsv.observe(main,{subtree:!0,childList:!0});var el=getEl();el&&el.remove()})());
@coreylight
coreylight / index.js
Last active April 14, 2020 16:11
Run cypress
#!/usr/bin/env node
const { execSync } = require("child_process");
const fs = require("fs");
const glob = require("glob");
const open = require("open");
const [, , filePath] = process.argv;
if (!filePath) {
console.error("File path must be present as first argument.");
process.exit(1);