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
type ItemInfo = | |
| { | |
type: "element"; | |
key: string | undefined; | |
} | |
| { type: "other" }; | |
function getItemInfo(item: unknown): ItemInfo { | |
if (typeof item === "object" && item != null) { | |
if ("key" in item) { |
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
# Tell Spotlight to ignore all node_modules directories. | |
# Run this from the home directory. | |
# Pieced together from: | |
# - https://github.com/yarnpkg/yarn/issues/6453#issuecomment-498110933 | |
# - https://stackoverflow.com/a/4210072/782045 | |
# - https://superuser.com/a/151427/110699 | |
# - https://apple.stackexchange.com/a/258791/31413 | |
# - https://unix.stackexchange.com/a/24563/64762 | |
# This does a dry run; remove `echo` to do actually do it. |
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
#!/bin/sh | |
# File formatted with shell-format. | |
# | |
# This tool creates a disk image to put node_modules in. This makes it so that | |
# when the disk image is not mounted, it is treated as a single file by | |
# Spotlight and other tools to do expensive tasks on a per-file basis. | |
set -e | |
# Utils |
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
#!/opt/homebrew/bin/bun run | |
// <xbar.title>CPU Usage, Kill process</xbar.title> | |
// <xbar.version>v1.0</xbar.version> | |
// <xbar.author>Sean Zhu</xbar.author> | |
// <xbar.author.github>szhu</xbar.author.github> | |
// <xbar.desc>Shows the top 5 highest-CPU processes. Select a process to kill it.</xbar.desc> | |
// <xbar.image>https://raw.githubusercontent.com/Aleksandern/devman/master/images/BitBarCpuUsageKill.png</xbar.image> | |
// <xbar.dependencies>deno</xbar.dependencies> | |
// Based on: https://xbarapp.com/docs/plugins/System/cpu-usage-kill.5s.sh.html |
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
type PickByNullableType<D, T> = { | |
[K in keyof D]: NonNullable<D[K]> extends T ? K : never; | |
}; | |
type PickKeysWithNullableValueTypes<D, T> = keyof D & | |
PickByNullableType<D, T>[keyof D]; | |
function setLevel1Value<D extends object, K1 extends keyof D>( | |
data: D, | |
key1: K1, |
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
# This does a dry run; it prints out what should be run. You can then run it yourself. | |
for branch in (git branch --format "%(refname:short)") | |
set sha (git rev-parse $branch) | |
if git log -1 $branch --pretty=format:'%cr' | grep -q -E 'weeks|months' | |
set date (git log -1 $branch --pretty=format:'%cs') | |
echo | |
echo '#' $branch | |
echo git tag $date-$branch $sha | |
echo git branch -D $branch | |
end |
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 Gmail Sender Utils | |
// @namespace https://github.com/szhu | |
// @match https://mail.google.com/mail/u/* | |
// @version 1.3 | |
// @author Sean Zhu | |
// @description Quickly drill down by sender or label in Gmail. | |
// @homepageURL https://gist.github.com/szhu/1d816086307c5de02bc9a2bb1cf01fe0 | |
// @updateURL https://gist.github.com/szhu/1d816086307c5de02bc9a2bb1cf01fe0/raw/gmail-sender-utils.user.js | |
// @downloadURL https://gist.github.com/szhu/1d816086307c5de02bc9a2bb1cf01fe0/raw/gmail-sender-utils.user.js |
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
set -e | |
verbose() { | |
echo $ "$@" >&2 | |
"$@" | |
} | |
COMPARISON="${1:-origin/prod...origin/main}" | |
OUT=".git/changelog.out.html" |
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
import { useRef } from "react"; | |
/** | |
* Use this hook to quickly answer the question: Why did my useEffect or useMemo | |
* callback run again? | |
* | |
* Usage: | |
* | |
* // If you have this code... | |
* useEffect(() => { |
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
// domToTsv - Convert rows in a webpage into TSV-formatted table. | |
// Example usage: | |
// This converts instacart.com order receipts to TSV. | |
domToTsv( | |
// Select a single table: | |
[`#store-wrapper main`], | |
// For each table, select every row: | |
`:scope > ul > li`, |
NewerOlder