Skip to content

Instantly share code, notes, and snippets.

View szhu's full-sized avatar

Sean Zhu szhu

  • NYC / SF
  • 22:45 (UTC -04:00)
  • X @sfzhu
View GitHub Profile
@szhu
szhu / selfcompile.m
Last active May 14, 2018 18:27 — forked from n-b/selfcompile.m
A simple self-compiling objective-c file
/* 2>/dev/null
COMPILED=${0%.*}
[[ -e "$COMPILED" ]] || clang $0 -o "$COMPILED" -framework Foundation
exec "$COMPILED" $@
*/
#import <Foundation/Foundation.h>
int main(int argc, char *argv[])
# Read more about gapps-config file here:
https://github.com/opengapps/opengapps/wiki/Advanced-Features-and-Options
# Prevent automatic removal
# +Browser # Stock Browser
# +CameraStock # Stock Camera
# +Email # Stock Email
# +Gallery # Stock Gallery
# +Launcher # Stock Launcher(s)
#!/bin/bash
set -euo pipefail
mkdir -p tmp/overrides/webpack%3a/%2e
while true; do
while IFS= read -r -d '' override_file
do
file=$(echo "$override_file" | python -c 'import re, sys; print re.split("^tmp/overrides/webpack%3a/%2e/|%3f.*$", sys.stdin.read().strip())[1]')
cp -f "$override_file" "$file"
{
let clientAppState = JSON.parse($("#client-app-state").text.replace(/&q;/g, '"'))
let { HttpState } = clientAppState
let route = Object.keys(HttpState)[0]
HttpState[route].data.properties.identifier.uuid
}
#!/bin/bash
# Set your desktop background to your screen saver.
# Install and activate with:
# curl -fsSL https://git.io/vMgM9 | bash
#
# The screen saver is visible only on desktops created before the screen saver
# was started. If you create a desktop and wish to see the screen saver on it
# immediately, just do:
# open -a ScreenSaverEngine
# to bring it in front of the default desktop background. You can also add
// pbpaste | deno run --reload https://gist.githubusercontent.com/szhu/54a314fa055b4e6d07e1446ca9f3ea8a/raw/convertPropTypesToTs.ts | pbcopy
interface ToStringAble {
toString(): string;
}
type TypeSpecToString = (this: TypeSpec) => string;
interface TypeSpec {
name: string;
@szhu
szhu / git-autosave
Last active January 14, 2022 17:24
Creates a backup of your uncommitted changes.
#!/bin/bash
set -e
old_stash_count=$(git stash list | wc -l)
git stash push --keep-index --include-untracked --quiet
if test "$old_stash_count" == "$(git stash list | wc -l)"; then
echo "All changes have been committed."
exit 0
fi
for (let image of document.querySelectorAll("image")) {
let url = (image.getAttribute("xlink:href"));
fetch(url).then(res => res.blob()).then(blob => open(URL.createObjectURL(blob)));
}
@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 / 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.
//