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
@davestewart
davestewart / csp-example.js
Last active July 12, 2023 15:58
Content Security Policy builder
const CSP = require('./csp')
// ---------------------------------------------------------------------------------------------------------------------
// variables
// ---------------------------------------------------------------------------------------------------------------------
const csp = `script-src 'self' *; img-src data: *`
const isDev = true
@davestewart
davestewart / github.user.css
Last active April 18, 2023 18:06
Typora GitHub user theme
/*
* Typora GitHub user theme
*
* Makes markdown docs look *exactly* like they do on GitHub
*
* To install, drop in your Typora themes folder and open a new window
*/
body {
font-family: BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
font-size: 16px;
@davestewart
davestewart / content-indexer.ts
Last active March 20, 2023 19:27
Auto indexing for Nuxt 3 Content
// modules/content-indexer.ts
import Fs from 'fs'
import Path from 'path'
import { defineNuxtModule, extendPages, extendRouteRules } from '@nuxt/kit'
import { ModuleOptions, Nuxt } from '@nuxt/schema'
import { MountOptions } from '@nuxt/content'
const name = 'content-indexer'
export default defineNuxtModule({
@davestewart
davestewart / clean.ts
Created September 14, 2022 12:17
Clean object function in TypeScript
export function isObject (value?: unknown): boolean {
return !!value && typeof value === 'object'
}
export function isPlainObject (value?: unknown): boolean {
return isObject(value) && !Array.isArray(value)
}
export function isEmpty (value?: unknown): boolean {
if (value === null || value === undefined) {
@davestewart
davestewart / acceptable github html.html
Last active April 28, 2022 15:30
Acceptable GitHub HTML
<p>See: <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element">https://developer.mozilla.org/en-US/docs/Web/HTML/Element</a></p>
<section>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
</section>
@davestewart
davestewart / package-wiki.md
Last active January 22, 2026 12:12
Package Wiki experiment

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;
@davestewart
davestewart / estimation.md
Last active April 16, 2026 16:01
Things to think about when estimating frontend projects

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