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
@coreylight
coreylight / index.ts
Created April 12, 2022 17:14
JS client download data on the fly
export const downloadData = async (
fileName: string,
data: object | string
): Promise<void> => {
const stringData = typeof data === 'string' ? data : JSON.stringify(data);
try {
const dataBlob = new Blob([stringData], { type: 'text/json' });
const url = URL.createObjectURL(dataBlob);
const link = document.createElement('a');
link.href = url;
@coreylight
coreylight / test.yml
Created January 3, 2022 20:18
Cypress test.yml snippet
name: Test
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
cypress:
needs: [build, check_labels]
runs-on: ubuntu-latest
continue-on-error: ${{ needs.check_labels.outputs.is_cd == 'true' }}
@coreylight
coreylight / index.js
Last active July 26, 2021 17:10
Mastery auth network test
#!/usr/bin/env node
const { exec } = require('child_process')
console.log('Starting Test. Total approx test time: 1 minute');
exec('npm run test', { cwd: __dirname }, (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`)
return
}
@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);
@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 / 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 / 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()
]
});
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!')
});
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'}