Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Sean Larkin TheLarkInn

🎯
Focusing
View GitHub Profile
@TheLarkInn
TheLarkInn / captureWebRTCAudio.js
Last active Jan 31, 2019
Record that voice! Just learning MediaRecorder API's
View captureWebRTCAudio.js
const captureWebRTCAudio = (successHandler) => {
return navigator.mediaDevices.getUserMedia({audio: true, video: false}).then(successHandler);
};
export default captureWebRTCAudio;
View loadPresets.js
const webpackMerge = require("webpack-merge");
const applyPresets = (env = { presets: [] }) => {
const presets = env.presets || [];
/** @type {string[]} */
const mergedPresets = [].concat(...[presets]);
const mergedConfigs = mergedPresets.map(presetName => require(`./presets/webpack.${presetName}`)(env));
return webpackMerge({}, ...mergedConfigs);
};
@TheLarkInn
TheLarkInn / puppetteer-get-coverage.js
Created Jun 30, 2018
Get's coverage data from a url using puppetteer.
View puppetteer-get-coverage.js
const puppetteer = require("puppeteer");
/**
* @param {string} pageUrl The URL that you want to gather coverage data for
*/
const unusedCode = async pageUrl => {
const browser = await puppetteer.launch();
console.log("browser launched");
const page = await browser.newPage();
console.log("new page created");
@TheLarkInn
TheLarkInn / BomPlugin.js
Created May 24, 2018
Super primitive BomPrependingPlugin
View BomPlugin.js
const pluginMeta = { name: "BomPlugin" };
class BomPlugin {
constructor(encoding = "\ufeff") {
this.encoding = encoding;
}
apply(/** @type {import("webpack/lib/Compiler")}*/ compiler) {
compiler.hooks.compilation.tap(pluginMeta, (
/** @type {import("webpack/lib/Compilation")}*/ compilation,
params
View index.js
import PaintModule from "./somePaintModule.js";
/**
* if user wanted to code split they pass
* const PaintModule = () => import("./somePaintModule.js")
*/
CSS.paintWorklet.addModule(PaintModule)
// Therefore the surface api operates the same in the users eyes
View ProfilingPlugin.js
const chalk = require("chalk");
const { performance } = require("perf_hooks");
class ProfilingPlugin {
apply(compiler) {
// Compiler Hooks
Object.keys(compiler.hooks).forEach(hookName => {
compiler.hooks[hookName].intercept(makeInterceptorFor("Compiler")(hookName))
});
Object.keys(compiler.resolverFactory.hooks).forEach(hookName => {
View index.js
const fs = require('fs');
const path = require('path');
const Benchmark = require('benchmark');
const suite = new Benchmark.Suite;
const ts = require('typescript');
const acorn = require('acorn');
const babylon = require('babylon');
@TheLarkInn
TheLarkInn / stats.json
Created Sep 26, 2017
Sample webpack stats.json
View stats.json
This file has been truncated, but you can view the full file.
{
"errors": [],
"warnings": [],
"version": "3.6.0",
"hash": "87cd04b20883a998cc03",
"time": 283,
"publicPath": "",
"assetsByChunkName": {
"main": "main.chunk.js"
@TheLarkInn
TheLarkInn / stats.json
Created Sep 26, 2017
Sample webpack stats.json
View stats.json
This file has been truncated, but you can view the full file.
{
"errors": [],
"warnings": [],
"version": "3.6.0",
"hash": "87cd04b20883a998cc03",
"time": 283,
"publicPath": "",
"assetsByChunkName": {
"main": "main.chunk.js"
@TheLarkInn
TheLarkInn / grouce-webpack-all-orgs-all-repos.bash
Last active Jan 4, 2020
This bash script creates a gource video. Requires gource and libav (can install with brew).
View grouce-webpack-all-orgs-all-repos.bash
#!/bin/bash
ARRAY=(
"webpack:webpack"
"webpack:example-app"
"webpack:enhanced-require"
"webpack:webpack-dev-middleware"
"webpack:enhanced-resolve"
"webpack:template"
"webpack:webpack-dev-server"
You can’t perform that action at this time.