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 / mongosh.d.ts
Created June 16, 2023 02:18
Typescript definition hack for writing mongosh scripts
import {
Collection,
Database,
ReplicaSet,
Shard,
ShellInstanceState,
} from '@mongosh/shell-api';
import { ShellApiClass } from '@mongosh/shell-api/lib/decorators';
type ShellApi = ShellInstanceState['shellApi'];
@forivall
forivall / README.md
Last active March 16, 2023 17:45
git-credential-manager reaper script

This is a simple background script to kill git-credential-manager when it hits the 100% cpu bug

#!/usr/bin/env node
/*
Example usage:
```
node markdown-it-with-pandoc.js ./README.md --enable-checkboxes --github-css -- -o README.html
```
*/
// Lint with xo --space --no-semicolon --no-esnext
@forivall
forivall / settings.jsonc
Last active December 28, 2022 21:42
vscode theme color customizations
{
"editor.semanticTokenColorCustomizations": {
"rules": {
"*.mutable": {
"fontStyle": "bold"
},
"*.typeHint": {
"fontStyle": "italic"
},
"interface": {
@forivall
forivall / settings.json
Created December 16, 2022 01:37
My extensive customizeui settings
{
"customizeUI.font.monospace": "FantasqueSansMono Nerd Font",
"customizeUI.font.regular": "SF Pro Display",
"customizeUI.fontSizeMap": {
"13px": "12px"
},
"customizeUI.stylesheet": {
".mac, .windows, .linux": "letter-spacing: -0.02rem",
".mac.trongthanh-theme-boxythemekit-themes-Boxy-Yesterday-json": "-webkit-text-stroke: 0.3px",
".minimap": "opacity: 0.5",
@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
),
[[], []]
)
type ValueOf<T> = T[keyof T];
export const literalToEnum = <Enum extends Record<string, string | number>>(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
enumButJustForTyping: Enum
) => <Candidate extends EnumLiteralType<Enum>>(v: Candidate) =>
(v as string) as LiteralToEnum<Enum, Candidate>;
export type LiteralToEnum<
Enum extends Record<string, string | number>,