This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2023 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/b1d6650475c0b30dc57eebe13d20ae37 | |
/** | |
* Type guard helper for checking if a value is truthy. mostly for use with | |
* {@link Array.prototype.filter} to clean up array types | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2023 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/63e56cd69e55a659120ec1e95a380a1e | |
/** | |
* Extracts keys of `TObj` that correspond to values that some type in the union | |
* `TTypes` can be assigned to | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2022 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/81679a314603786b1ec9106ac82c3444 | |
// DEBUGGING HELP | |
// https://blog.andrewbran.ch/debugging-the-type-script-codebase/ | |
// https://www.typescriptlang.org/docs/handbook/compiler-options.html | |
// https://medium.com/jspoint/typescript-compilation-the-typescript-compiler-4cb15f7244bc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run like this: | |
// node ./parse-vscode-profile.js "$HOME"/Downloads/profile.code-profile | |
const fs = require("fs") | |
const file = fs.openSync(process.argv[2], "r") | |
for (const line of fs.readFileSync(file, "utf8").split("\n")) { | |
const extensions = JSON.parse(JSON.parse(line).extensions) | |
const enabledExtensions = extensions.filter((extension) => !extension.disabled) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2022 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/737d914974c9ae26935a5c3fcfdc0289 | |
// TODO: write functions that mimic React for better example | |
// see the comment toward the bottom for the issue | |
type SetStateAction<S> = S | ((prevState: S) => S) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2024 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/1b5b6f6de328f1bb7c78cbe96ba5c720 | |
/** | |
* Passes thru successful test input, errors with inputs that are not equal. nice when | |
* you have a bunch of `never`s. can handle checking if things are `any` or `unknown` too. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2022 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/4b88be5dbc4ce1d00c37df0d1811c48b | |
// experiments that have thus far been unsuccessful | |
// https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f | |
// https://github.com/fightingcat/sits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2022 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/2bc7327353adb13e7b443f8c85113ba0 | |
// eventually a solution to day 16 of Advent of Code 2021 using only the compile-time | |
// type system of TypeScript. | |
// https://adventofcode.com/2021/day/16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2022 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/65ff817661487a3bfb02a5c698825df9 | |
/** test type of obj w nesting */ | |
type T000 = { | |
a1: { | |
b1: boolean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Library | onElementReady ES6 | |
// @namespace de.sidneys.userscripts | |
// @homepage https://gist.githubusercontent.com/zachhardesty7/b19c33e4b2cec8861d55df10be0ce162/raw/ | |
// @version 0.6.0 | |
// @description Detect any new DOM Element by its CSS Selector, then trigger a function. Includes Promise- & Callback interface. Based on ES6 MutationObserver. Ships legacy waitForKeyElements interface, too. | |
// @author sidneys | |
// @icon https://i.imgur.com/nmbtzlX.png | |
// @include *://*/* | |
// ==/UserScript== |
NewerOlder