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 / 1.by-category.md
Last active June 21, 2024 14:57
Coffee Shop Criteria

Environment

Business

  • location
  • likelihood of going bust

Ambience

  • quietness
@davestewart
davestewart / prepare_csv.vba
Last active March 31, 2024 15:43
Prepare Barclays CSV
Sub Prepare_CSV()
'
' Prepare Barclays bank CSV export
'
' - formats number, date and amount columns
' - splits memo column
' - trims resulting cells
' - consolidates amazon payees
' - copies data to clipboard
'
Type Region
src As Range
col As Long
End Type
Sub Copy_Columns()
'
' This Excel macro copies columns from a <source> sheet to a <target> sheet:
'
' - by default, sheets 1 and 2 will be used as <source> and <target>
@davestewart
davestewart / emojis.md
Last active December 5, 2023 13:37
An attempt to categorise emojis by emotional group
group name emojis
positive
winning 🥳😎🤩🤑🤓🤠😇🫡
cheeky 😏😉😋😛😝😜🤪
happy 🙂🙃😀😃😁😄😆😅😂🤣
content 😌☺️😊🤗🥰
amorous 😗😙😚😘😍
neutral
shy 🫢🤭
@davestewart
davestewart / test.js
Last active November 10, 2023 09:21
.filter().map() pedantry!
let values = []
let scores = []
function prepare (length = 10_000_000) {
values = (new Array(length)).fill(1).map((e, i) => i)
}
function forIn () {
const output = []
for (let i = 0; i < values.length; i++) {
@davestewart
davestewart / CAPSSUCK.js
Created November 9, 2023 13:45
Convert CAPS CASE to Sentence case
javascript: document.querySelectorAll('*').forEach(e => {
if (e.childNodes.length === 1 && e.childNodes[0].nodeType === Element.TEXT_NODE) {
if (e.innerText && e.innerText === e.innerText.toUpperCase()) {
e.innerText = e.innerText.toLowerCase()
.replace(/^\w|\.\s+\w/gm, t => t.toUpperCase())
.replace(/\si\s/, ' I ');
}
}
});
@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) {