Skip to content

Instantly share code, notes, and snippets.

View szhu's full-sized avatar

Sean Zhu szhu

  • NYC / SF
  • 21:18 (UTC -04:00)
  • X @sfzhu
View GitHub Profile
// ==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
#!/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
@szhu
szhu / stickes-hole-window.swift
Created November 3, 2022 16:10
Open 4 Stickies windows and drag them around to create a "hole".
import AppKit
import ApplicationServices
import CoreFoundation
import Foundation
// Helpers
// https://github.com/keith/ModMove/blob/main/ModMove/AXValue%2BHelper.swift
extension AXValue {
func toValue<T>() -> T? {
@szhu
szhu / page-summary-overlay.user.js
Last active February 3, 2023 22:15
Use OpenAI GPT-3 to summarize the text on the page into 3 key points.
// ==UserScript==
// @name Summarize Page Text
// @namespace https://github.com/szhu
// @description Use OpenAI GPT-3 to summarize the text on the page into 3 key points.
// @match *://*/*
// ==/UserScript==
// @ts-strict
const API_KEY = "API_KEY";
@szhu
szhu / flatten-image-masks-in-svg.js
Last active November 30, 2022 21:43
Makes it so that I can import Keynote/Pages/Numbers drawings into Figma.
// 1. Export the file to PDF.
//
// 2. Convert it to SVG:
//
// inkscape $file.pdf -o $file.svg --export-text-to-path
//
// Note: Don't use pdftocairo or pdf2svg; they don't work properly with the next steps.
//
// 3. Open the SVG file in your browser.
//
#!/bin/bash
# Add thumbnails to images. This works well for document images (like PDFs),
# where the top of the image is the most important.
for file in "$@"; do
# `--cropOffset 0 0` doesn't do anything, so we use a small offset.
sips \
-s format png \
--resampleWidth 512 \
--cropOffset 0 0.001 \
@szhu
szhu / figmaScrollToZoom.hs.lua
Created December 20, 2022 18:49
HammerSpoon script for scroll to zoom with no modifiers
-- https://forum.kicad.info/t/zoom-with-scroll-wheel-but-pan-with-trackpad-on-macos/11974
figmaScrollToZoom = hs.eventtap.new({hs.eventtap.event.types.scrollWheel}, function(e)
-- Trackpad scroll events are continuous, mouse scroll events are not.
if 0 == e:getProperty(hs.eventtap.event.properties.scrollWheelEventIsContinuous) then
local front = hs.application.frontmostApplication()
if "Figma" == front:name() then
-- local title = front:focusedWindow():title()
-- if "Eeschema" == title:sub(0, 8) or "Pcbnew" == title:sub(0, 6) then
local flags = e:getFlags()
@szhu
szhu / object-object.md
Last active February 10, 2023 20:34
[object Object]

This code:

1  formResults = { ... };
2  console.log("first name: " + formResults.firstName);
3  console.log("last name: " + formResults.lastName);
4  console.log("email: " + formResults);

has the following output:

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(() => {
set -e
verbose() {
echo $ "$@" >&2
"$@"
}
COMPARISON="${1:-origin/prod...origin/main}"
OUT=".git/changelog.out.html"