Skip to content

Instantly share code, notes, and snippets.

View GrantCuster's full-sized avatar

grant GrantCuster

View GitHub Profile
@GrantCuster
GrantCuster / userChrome.css
Last active April 3, 2022 08:42
My minimal, gruvbox inspired Firefox customization
/* Check out https://www.reddit.com/r/FirefoxCSS/ for an explanation on how to customize */
/* This hides a ton of buttons because I use Vimium for most navigation */
/* Screenshot at https://feed.grantcuster.com/post/1596224341/ */
:root {
--base00: #282828;
--base01: #3c3836;
--base02: #504945;
--base04: #bdae93;
--base05: #d5c4a1;
@GrantCuster
GrantCuster / userChrome.css
Created May 4, 2020 16:03
Minimal gruvbox skin for firefox.
#navigator-toolbox { font-family: 'JetBrains Mono' !important; border-bottom: none !important; } #navigator-toolbox #back-button { display: none; } #navigator-toolbox #forward-button { display: none; } #navigator-toolbox toolbarspring { display: none; } #navigator-toolbox .tab-line { display: none; } #navigator-toolbox #urlbar-container {
padding: 0 !important;
margin: 0 !important;
}
#navigator-toolbox #urlbar {
border: none !important;
border-radius: 0 !important;
box-shadow: none !important;
}
#navigator-toolbox #PanelUI-button {
@GrantCuster
GrantCuster / toc-active.js
Created October 25, 2019 13:47
Add an active class to the table of contents link when the heading is visible. For me, this was on top of html generated through markdown-it and markdown-it-table-of-contents, but similar things could work in lots of other situations.
window.addEventListener(
"load",
() => {
let headings = document.querySelectorAll("h2, h3, h4");
let links = document.querySelectorAll(".table-of-contents ul li a");
observer = new IntersectionObserver(
(entry, observer) => {
if (entry[0].intersectionRatio === 1) {
for (let link of links) {
This file has been truncated, but you can view the full file.
[[[1927, 1933], [2545, 2542], [2672, 2670], [3312, 3304]], [[2251, 2249], [3090, 3095], [2477, 2473], [2978, 2984], [2980, 2986]], [[2642, 2643], [2823, 2829], [2208, 2206], [3030, 3032], [2825, 2829], [2574, 2575]], [[2592, 2602], [2815, 2819], [2269, 2266], [2762, 2766], [2481, 2480], [2215, 2219], [3095, 3100]], [[2359, 2347], [2941, 2946], [2732, 2731], [2670, 2669], [2571, 2561], [2427, 2415], [2754, 2752], [1890, 1893]], [[2307, 2306], [2550, 2553], [2549, 2552], [2521, 2526], [2258, 2256], [2454, 2452], [2516, 2520], [1766, 1765], [2903, 2903]], [[2209, 2213], [2501, 2506], [2501, 2504], [2476, 2476], [2145, 2147], [2425, 2427], [2502, 2503], [1706, 1710], [2813, 2815], [2408, 2411]], [[1993, 1999], [2228, 2233], [2323, 2330], [2462, 2460], [2039, 2044], [2217, 2220], [2322, 2329], [1670, 1673], [2584, 2584], [2216, 2220], [2350, 2355]], [[1989, 1984], [2352, 2346], [2370, 2369], [2301, 2292], [2070, 2064], [2302, 2292], [2302, 2290], [1564, 1561], [2464, 2465], [2155, 2151], [2277, 2268], [2300, 2291]
@GrantCuster
GrantCuster / inline-gatsby-footnotes.js
Created August 15, 2018 18:24
Create inline footnotes in markdown files in Gatsby.js
// Put in gatsby-browser.js
exports.onRouteUpdate = ({ location }) => {
setTimeout(function() {
let og_footnotes = document.querySelector('.footnotes')
if (og_footnotes) {
let footnotes = document.querySelectorAll('.footnotes ol li')
for (let i = 0; i < footnotes.length; i++) {
let f_content = footnotes[i]
let link = f_content.querySelector('a')
let href = link.getAttribute('href')
.bg-white { background: #FFFFFF; }
.white { color: #FFFFFF; }
.bg-silver { background: #C0C0C0; }
.silver { color: #C0C0C0; }
.bg-hray { background: #808080; }
.hray { color: #808080; }
.bg-black { background: #000000; }
.black { color: #000000; }
.bg-red { background: #FF0000; }
.red { color: #FF0000; }
@GrantCuster
GrantCuster / .block
Last active October 3, 2017 15:33 — forked from mbostock/.block
Pan & Zoom I
license: gpl-3.0
@GrantCuster
GrantCuster / .block
Last active October 3, 2017 15:25 — forked from mbostock/.block
Pan & Zoom II
license: gpl-3.0
@GrantCuster
GrantCuster / .block
Created October 3, 2017 15:23 — forked from mbostock/.block
Pan & Zoom II
license: gpl-3.0
@GrantCuster
GrantCuster / README.md
Last active January 10, 2023 08:55
Three.js with D3-style Pan and Zoom

This example recreates the zoom and pan behavior from the Pan and Zoom II D3 example. I'm using Three.js in a 2D data-visualization project because I'm hoping its WebGL render can handle more points than canvas. I had a hard time finding an example that zoomed and panned like I'm used to, so I made this.

This stack overflow answer by WesleyJones and the getCurrentScale function from anvaka's three.map.controls code was essential to me actually getting this working.

The scroll zoom is currently inverted compared to the D3 example, I'd like to match it but apparently there's some easing happening in the D3 scroll behavior that slows things down as you zoom in. That makes it feel weird if I just invert the zoom.

If you have suggestions on how to make this better, message me on [Twitter](htt