Skip to content

Instantly share code, notes, and snippets.

View forivall's full-sized avatar
🕴️
levitating

Emily Marigold Klassen forivall

🕴️
levitating
View GitHub Profile
@forivall
forivall / .envrc
Created November 15, 2022 03:01
python envrc
## brew install pyenv pyenv-virtualenv
## pyenv install 3.8.13
layout pyenv 3.8.13
interface AdvisoryReport {
id: number;
url: string;
title: string;
severity: string;
vulnerable_versions: string;
cwd: string[];
cvss: {
score: number;
javascript:(()=>{"function"==typeof window.__themeListenerUnsubscribe&&(window.__themeListenerUnsubscribe(),window.__themeListenerUnsubscribe=void 0);const e=window.matchMedia("(prefers-color-scheme: dark)"),t=async e=>{/255/.test(getComputedStyle(document.querySelector("#gbwa path")).getPropertyValue("color"))!==e.matches&&(async e=>{const t=e=>new Promise((t=>setTimeout(t,e)));var c=`[bgid="basic${e}"]:not(.a7J)`,o='[aria-label="Theme"] + button',n=document.querySelector(c),r=!n;if(!n){var i=document.querySelector(o);i||(document.querySelector('[data-tooltip="Settings"]').click(),await t(10),i=document.querySelector(o)),i.click(),await t(250),n=document.querySelector(c)}n.click(),r&&(await t(50),document.querySelector('[data-tooltip="Save & close"]').click())})(e.matches?"black":"white")};e.addEventListener("change",t),window.__themeListenerUnsubscribe=()=>{e.removeEventListener("change",t)}})()
@forivall
forivall / reduce-partition.ts
Created July 18, 2022 19:24
reduce based partition function
export const partition = <T>(
arr: T[],
iteratee: (value: T, index: number, array: T[]) => any
) =>
arr.reduce(
(result: [T[], T[]], value, index, array) => (
result[+!iteratee(value, index, array)].push(value), result
),
[[], []]
)
@forivall
forivall / github-review-keyboard-shortcuts.bookmarklet.js
Last active June 3, 2022 19:26
github-review-keyboard-shortcuts
// https://github.com/forivall/dotfiles/blob/osx/userscripts/github-review-keyboard-shortcuts.js
/* global document */
;(() => {
/**
* @param {{[key: string]: (ev: KeyboardEvent) => any}} handlers
* @returns {(event: KeyboardEvent) => any}
*/
const reviewKeyboardHandler = (handlers) => (event) => {
if (!document.location.pathname.endsWith('/files')) return
const ae = document.activeElement
/**
* For vscode globs that can't just do `!`, but do have negative char classes
*
* turn `test` into `{[^t]*,?[^e]*,??[^s]*,???[^t]*}`
* `{[^t]*,?{,[^r]*,?{,[^a]*,?[^p]*}}}`
*
* two directories need to be excluded, the following would be needed:
* (ex. for negating 'test' or 'glob')
*
* `{[^tg]*,?[^el]*,??[^so]*,???[^tb]*,te{sb,ob,ot},t{ls,lo,eo}t,{tl,ge,gl}st,gl{ot,sb,st},g{es,ls,eo}b,{ge,tl,te}ob`
@forivall
forivall / MakeHidden.json
Last active November 2, 2021 00:05
Visual Studio Code Settings Sync Gist
{}
@forivall
forivall / yarn-exec-generator-template.ts
Created October 9, 2021 02:03
typescript template for yarn-exec plugin generator scripts
// the .js version must be checked in, as it is needed before anything is installed.
// this file can _not_ use any non-core modules or access any external files.
export {};
// https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-fslib/sources/path.ts#L10
type NativePath = string & { __pathType?: 0 | 2 };
// https://github.com/yarnpkg/berry/blob/master/packages/plugin-exec/sources/ExecFetcher.ts#L9
/**
* Contains various useful details about the execution context.
@forivall
forivall / headerOrphanControl.js
Created September 30, 2021 05:57
bookmarklet for improved printing
document.querySelectorAll('h1,h2,h3,h4,h5,h6').forEach((h) => {
var e = h.nextElementSibling, a = [h], d
e && a.push(e)
while (e && /H[0-6]/.test(e.tagName)) (e = e.nextElementSibling) && a.push(e)
if (a.length === 1) return
d = document.createElement('div')
d.style.display = 'inline-block'
h.replaceWith(d)
d.append(...a)
})
@forivall
forivall / fix-rr-subroutes.tsx
Created August 19, 2021 05:55
React Router v6 subroute fixer
import React from 'react';
export function fixSubRoutes(
routeElement: React.ReactElement<React.PropsWithChildren<{ path?: string }>>,
props?: { path?: string }
) {
const parentRoute = routeElement.props.path;
return React.cloneElement(
routeElement,
props,
...React.Children.toArray(routeElement.props.children).map(