Skip to content

Instantly share code, notes, and snippets.

View TheLarkInn's full-sized avatar
🦀
Getting Rusty

Sean Larkin TheLarkInn

🦀
Getting Rusty
View GitHub Profile
@TheLarkInn
TheLarkInn / gource.bash
Last active January 20, 2021 20:16 — forked from blake-newman/gource.bash
Create a gource.io of multiple repos
#!/bin/bash
ARRAY=(
"webpack:webpack"
"webpack:example-app"
"webpack:enhanced-require"
"webpack:webpack-dev-middleware"
"webpack:enhanced-resolve"
"webpack:template"
"webpack:webpack-dev-server"
@TheLarkInn
TheLarkInn / grouce-webpack-all-orgs-all-repos.bash
Last active January 4, 2020 06:57
This bash script creates a gource video. Requires gource and libav (can install with brew).
#!/bin/bash
ARRAY=(
"webpack:webpack"
"webpack:example-app"
"webpack:enhanced-require"
"webpack:webpack-dev-middleware"
"webpack:enhanced-resolve"
"webpack:template"
"webpack:webpack-dev-server"
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
@TheLarkInn
TheLarkInn / loadPresets.js
Created July 9, 2018 12:06
Load Preset
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 June 30, 2018 22:44
Get's coverage data from a url using puppetteer.
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 / captureWebRTCAudio.js
Last active January 31, 2019 15:29
Record that voice! Just learning MediaRecorder API's
const captureWebRTCAudio = (successHandler) => {
return navigator.mediaDevices.getUserMedia({audio: true, video: false}).then(successHandler);
};
export default captureWebRTCAudio;
@TheLarkInn
TheLarkInn / explanation.md
Last active June 7, 2018 13:33
Understanding some CommonsChunksPlugin teqniques

When you use the names property in the CommonsChunkPlugin({}) and pass an array as the value, webpack converts what is seen below:

      new webpack.optimize.CommonsChunkPlugin({
        names: ['app', 'vendor', 'manifest'],  // creating manifest.js 
        minChunks: Infinity
      })

Into:

@TheLarkInn
TheLarkInn / BomPlugin.js
Created May 24, 2018 19:32
Super primitive BomPrependingPlugin
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
@TheLarkInn
TheLarkInn / ProfilingPlugin.js
Last active May 12, 2018 05:27
Profiling Plugin
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 => {
@TheLarkInn
TheLarkInn / index.js
Created November 11, 2017 08:20
benchparse.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');