Skip to content

Instantly share code, notes, and snippets.

View zakkhoyt's full-sized avatar

Zakk Hoyt zakkhoyt

  • Hatch
  • Boise, ID
  • 04:10 (UTC -07:00)
View GitHub Profile

ZSH CheatSheet

This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.

Strings

Description Syntax
Get the length of a string ${#VARNAME}
Get a single character ${VARNAME[index]}
@zakkhoyt
zakkhoyt / launch_xcode_15.sh
Created November 12, 2024 16:29
Open Xcode15 on macOS 15
# Despite macOS'd grayed out icons, you can still launch Xcode 15
/Applications/Xcode-15.4.0.app/Contents/MacOS/Xcode &> /dev/null &
@zakkhoyt
zakkhoyt / offer_brew_install.sh
Last active June 30, 2024 02:25
Offer brew install
#!/bin/bash
# Available as a gist: https://gist.github.com/zakkhoyt/426cc6a5c2855d1b2feb4169df83bc9b
BINARY_TOOL="jq"
ANSI_BINARY_TOOL="\033[1m${BINARY_TOOL}\033[0m"
offer_brew_install() {
input=""
repeat=false
@zakkhoyt
zakkhoyt / gist:9e4fe6a411ed7b5ed0618a162bd73cd6
Created August 1, 2017 19:16
A demo to show different blending modes using CGBlendMod
//
// A demo to show different blending modes using CGBlendMod
//
import UIKit
extension CGBlendMode {
static func count() -> Int {
return 16
}
@zakkhoyt
zakkhoyt / gist:0b2543bb5a5995b41e73bef83391c378
Created July 15, 2017 04:02
How can I distunguish which's object's generic delegate is calling the generic delegate function? thing1 or thing2?
// MyClass is generic, and has a generic delegate.
// AClass creates two instances of MyClass and implements MyClassDelegate
//
// In the implementation of MyClassDelegate, how can I distinguish which object's delegate is calling
// func myClass<T>(_ myClass: MyClass<T>, valueDidChange value: T)
//
// See comments at end of file
protocol MyClassDelegate: class {
func myClass<T>(_ myClass: MyClass<T>, valueDidChange value: T)