Skip to content

Instantly share code, notes, and snippets.

@kevinleedrum
kevinleedrum / vite-plugin-icon-sprite.js
Last active October 24, 2024 13:52
vite-plugin-icon-sprite
import { promises as fs } from 'fs';
import path from 'path';
/** Monitors /static/icons and builds both a type definition file and a spritesheet from the SVG files **/
export default function IconSpritePlugin() {
async function generateIconSprite() {
const iconsDir = path.join(process.cwd(), 'static', 'icons');
const files = await fs.readdir(iconsDir);
let symbols = '';
let iconNameType = 'export type IconName =\n';
@kevinleedrum
kevinleedrum / settings.json
Last active October 7, 2024 14:30
Some of my vscode settings
{
// All of the apc.* settings require the Apc Customize UI extension:
// https://marketplace.visualstudio.com/items?itemName=drcika.apc-extension
// Theme, etc.
"workbench.iconTheme": "eq-material-theme-icons-ocean",
"workbench.colorTheme": "Moonlight II",
"editor.fontFamily": "'MesloLGS NF', Menlo, Monaco, 'Courier New', monospace",
// Tweaks / Declutter
@kevinleedrum
kevinleedrum / google-to-duckduckgo.js
Last active July 6, 2023 15:24
Replace Google Links with DuckDuckGo Links
// ==UserScript==
// @name Replace Google links with DuckDuckGo links
// @namespace https://gist.github.com/kevinleedrum/4d286da27e63a0eb7e17a36ed2ddd4e8
// @version 0.1
// @description Replace Google links on the page with DuckDuckGo links
// @author You
// @match https://*/*
// @exclude https://*google.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=duckduckgo.com
// @grant none
@kevinleedrum
kevinleedrum / proton-favicon.js
Last active June 15, 2023 14:40
Proton Mail Unread Favicon
// ==UserScript==
// @name Proton Mail Unread Favicon
// @namespace https://gist.github.com/kevinleedrum/d7e261c9d9b0b3281dcc75c16d69f143
// @version 0.1
// @description Updates the Proton Mail favicon to include a single-digit unread count
// @author Kevin Lee Drum
// @match https://mail.proton.me/u/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=proton.me
// @grant none
// ==/UserScript==
@kevinleedrum
kevinleedrum / advent-of-code-2022-13.js
Created December 13, 2022 19:41
Advent of Code 2022 - Day 13
const INPUT = `...`;
(function doPart1() {
const pairs = INPUT.split(/\n\n/).map((p) =>
p.split(/\n/).map((l) => eval(l))
);
const correctIndices = pairs
.filter((p) => comparePackets(...p) < 0)
.map((p) => pairs.indexOf(p) + 1);
console.log(correctIndices.reduce((a, b) => a + b, 0));
@kevinleedrum
kevinleedrum / advent-of-code-2022-12.js
Last active December 12, 2022 16:52
Advent of Code Day 2022 - Day 12
const INPUT = `...`;
console.log(findPathDistance("S", "E")); // Part 1
console.log(findPathDistance("E", "a", true)); // Part 2
function findPathDistance(startChar, endChar, isReverse = false) {
const { grid, start } = parseInput(startChar);
const q = [[...start, 0]];
const visited = new Set();
return findPath();
@kevinleedrum
kevinleedrum / advent-of-code-2022-09.js
Created December 9, 2022 15:20
Advent of Code 2022 - Day 9
const KNOT_COUNT = 10;
const knots = new Array(KNOT_COUNT).fill().map((_) => ({ x: 0, y: 0 }));
const tailPositions = new Set();
tailPositions.add("0,0");
const moves = INPUT.split(/\n/).map((move) => {
let [direction, distance] = move.split(" ");
distance = +distance;
return { direction, distance };
});
@kevinleedrum
kevinleedrum / config.json
Created January 30, 2017 21:53 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "@gray-dark",
"@brand-success": "#5cb85c",
@kevinleedrum
kevinleedrum / config.json
Created December 16, 2016 18:54 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",