Skip to content

Instantly share code, notes, and snippets.

View davestewart's full-sized avatar
⚙️
Workin' on Chrome extensions!

Dave Stewart davestewart

⚙️
Workin' on Chrome extensions!
View GitHub Profile

Package Wiki

This file documents Metalink Frontend's package.json in a human-readable manner designed to make it easy for contributors to see how related units work together.

Units are ordered by Dependency Type > Category > Group, then listed with Titles, Descriptions, Links and Notes.

Please edit or improve the sections and descriptions as required, then keep this document up to date.

Dependencies

@davestewart
davestewart / vue-auto-routes.js
Created April 18, 2022 17:05
Automatically build Vue routes from all *.vue files in src/views/
import Vue from 'vue'
import VueRouter from 'vue-router'
// route helper
function route (path, component) {
if (typeof component === 'string') {
component = require(`../views/${component.replace('.vue', '')}.vue`).default
}
return { path, component }
}
@davestewart
davestewart / observe-mutations.js
Created January 20, 2022 23:13
Visibly render DOM node mutations
const s = document.createElement('style')
s.setAttribute('type', 'text/css')
s.innerHTML = `
@keyframes fade {
0% { background: #FF000022; outline: 2px solid #000000; }
100% { background: #FF000000; outline: 2px solid #00000000; }
}
.updated {
animation: fade 1s linear;

Estimation

This document is an attempt to pin down all the things you don't think about when quoting for a project, and hopefully provide a starting point for some kind of framework to make quoting, working and delivering small-medium jobs more predictable and less stressful.

Contents

@davestewart
davestewart / README.md
Last active May 23, 2023 15:38
YouTube transcript bookmarklet

YouTube Transcript Bookmarklet

For any YouTube video with captions, you can access the captions via a linked URL.

This bookmarklet grabs that URL, loads the captions, and converts the XML to text.

That text is then:

  • copied to the clipboard (if supported)
  • dumped in the console (Opt+Cmd+I / F12) where you can click the copy button to grab it
@davestewart
davestewart / README.md
Last active April 8, 2024 11:00
Decompile JavaScript from source maps

Decompile JavaScript from source maps

Overview

Modern JavaScript build tools compile entire folder structures of JavaScript code into single, minified files that are near-impossible to read, but can also include source maps which can be used to display the original code in tools such as the Chrome DevTools Sources panel.

These source maps can be processed to extract mainly meaningful code and file structures, by installing a package calling Shuji and running a simple bash command.

Generally, production builds shouldn't include source maps, but if you do manage to lose your source files, or for some (obviously, ethical!) reason need to view the original files, and you happen to have / find the source maps, you're good to go.

@davestewart
davestewart / babel.config.js
Created December 1, 2020 20:10
Target modern browsers only
module.exports = {
presets: [
[
'@vue/cli-plugin-babel/preset', // or any other preset, I guess
{
targets: {
chrome: '73',
node: '11'
}
}
@davestewart
davestewart / nuxt.config.js
Last active December 22, 2020 14:34
Nuxt build config to provide sane source maps and reliable HMR
// @see https://twitter.com/dave_stewart/status/1332340558069690371
// Special thanks to https://github.com/nicholasoxford
// YMMV!
module.exports = {
build: {
extend (config, { isDev, isClient }) {
if (isDev) {
// provides proper source and properly-named source map for pages and components
config.devtool = 'source-map'
@davestewart
davestewart / last-demo.js
Last active October 20, 2020 15:54
Modify a function so it only resolves the last call
// decorated search function
const search = last(function (query) {
return new Promise(function (resolve, reject) {
setTimeout(() => {
// randomly fail
Math.random() < .25
? reject(new Error('failed for query ' + query))
: resolve(String(query).toUpperCase())
}, Math.random() * 2000)
})
/**
* INSTRUCTIONS
*
* Video at: https://youtube.com/watch?v=AzSDmfDDijQ
*
* 1. copy the code below into a bookmark
* 2. go to https://www.facebook.com/stories/
* 3. click on a story
* 4. hit pause on one you like
* 5. find and run your bookmark