Skip to content

Instantly share code, notes, and snippets.

View thomaswilburn's full-sized avatar
🦝

Thomas Wilburn thomaswilburn

🦝
View GitHub Profile
@thomaswilburn
thomaswilburn / keymap.c
Last active March 31, 2022 18:28
Personalized QMK for CTRL
#include QMK_KEYBOARD_H
enum ctrl_keycodes {
L_BRI = SAFE_RANGE, //LED Brightness Increase //Working
L_BRD, //LED Brightness Decrease //Working
L_EDG_I, //LED Edge Brightness Increase
L_EDG_D, //LED Edge Brightness Decrease
L_EDG_M, //LED Edge lighting mode
L_PTN, //LED Pattern Select Next //Working
L_PTP, //LED Pattern Select Previous //Working
@thomaswilburn
thomaswilburn / zip-it.md
Last active April 18, 2024 11:56
Exploring generators and iteration through zip()

Win zip()

I don't often use zip(), but by coincidence this week I ran into it a few times, using both Python and JavaScript. In the former, it's a built-in, but in the latter it's typically provided by a library like D3. And it struck me as kind of a fun warm-up challenge. How would you write this function in modern JavaScript?

Well, let's see how D3 does it. Oh, it's a wrapper around transpose(), here we go...

import min from "./min.js";

function length(d) {
@thomaswilburn
thomaswilburn / lit-html.md
Last active January 5, 2022 18:19
Things I learned reading the lit-html source

Reading lit-html

I've been interested in lit-html for a while now: it's an HTML templating solution that doesn't require a build step like JSX, uses standard JavaScript tagged literals for its syntax, and claims to selectively update the DOM without a V-DOM. At 8KB minified, it's also reasonably-sized--not quite as tiny as my go-to dot.js micromodule, but the functionality is much higher.

In the past, reading through library code has been one of the ways that I got better at development. I remember Paul Irish's classic "10 things I learned from reading the jQuery source" video, which had inspired me to do my own spelunking back in the day. Figuring out how jQuery, D3, and Backbone translated high-level function calls into the low-level browser API taught me a lot, and I figured lit-html would be a similar chance to learn something new.

I was right! It turns out, there's a lot going on under the hood of lit-html. Even better, much of it is built on top of platform features, as opposed to pure JS abstracti

@thomaswilburn
thomaswilburn / oneliner.sh
Last active December 22, 2021 21:54
Remove redaction blobs from PDF before OCR
set -x
set -e
mkdir -p output
cd original
for f in *.jpg; do
# first image in the stack is the base image
convert $f \
# second image is the same thing, but with dilate/erode applied to remove thin lines (i.e., text)
@thomaswilburn
thomaswilburn / _shader-box.html
Last active February 26, 2021 16:15
Shader box custom element
<style>
:host {
width: 300px;
height: 150px;
display: block;
position: relative;
}
canvas {
position: absolute;
@thomaswilburn
thomaswilburn / graphic.js
Created February 22, 2021 17:12
SIMVID code
var presets = {
starting: {
r: 55,
efficacy: 95,
immunity: 0
},
baseline: {
immunity: 0
},
lowImmunity: {
/*
Register functions to be notified if a specific selector matches (or stops matching)
*/
var watchList = new Map();
var glance = function(watch) {
var result = document.querySelector(watch.selector);
@thomaswilburn
thomaswilburn / component.js
Last active April 15, 2020 01:52
So you want to make a primary results component
var ElementBase = require("../elementBase.js");
var Retriever = require("../retriever.js");
/*
Let's make a web component the elections20-primaries way! We're going to start by
subclassing our base element, since it makes the setup a little more declarative.
You'll see how that works in a minute.
*/
class DemoElement extends ElementBase {
@thomaswilburn
thomaswilburn / unpinner.vbs
Created January 29, 2020 16:50
Unpin taskbar icons
Set ShellApp = CreateObject("Shell.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")
homeFolder = ShellApp.NameSpace(&H28).Self.Path
PinnedPath = homeFolder & "\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
Set PinnedNS = ShellApp.NameSpace(PinnedPath)
Set PinnedFolder = FSO.GetFolder(PinnedPath)
Set PinnedFiles = PinnedFolder.Files
@thomaswilburn
thomaswilburn / loadDocs.js
Created December 12, 2019 20:56
annotatedDocs.js
var { google } = require("googleapis");
var async = require("async");
var os = require("os");
var path = require("path");
var { authenticate } = require("./googleauth");
module.exports = function(grunt) {
grunt.registerTask("docs", "Load Google Docs into the data folder", function() {