Skip to content

Instantly share code, notes, and snippets.

View ZevEisenberg's full-sized avatar

Zev Eisenberg ZevEisenberg

View GitHub Profile
import CoreGraphics.CGBase
import RealityKit
import UIKit
/// The ratio of the resource’s width to its height.
/// - `...1` is portrait
/// - `1` is square
/// - `1...` is landscape
public enum AspectRatio: Equatable, Comparable, Codable, Sendable {
case portrait(Double)
@ZevEisenberg
ZevEisenberg / resetAllSimulators.sh
Last active September 15, 2024 02:52
Reset all iOS simulators with this one weird trick
osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl erase all
@ZevEisenberg
ZevEisenberg / fixXcode.sh
Last active January 6, 2024 07:31
Function to fix Xcode’s code snippets library by replacing it with the one from the ZevEisenberg/ios-convenience git repo
function fixXcode
{
pushd > /dev/null
cd
xcodepath=`xcode-select --print-path`/..
destination=$xcodepath/Frameworks/IDEKit.framework/Versions/A/Resources/SystemCodeSnippets.codesnippets
shouldRelaunchXcode=false
if [[ `osascript -e 'tell app "System Events" to count processes whose name is "Xcode"'` == 1 ]]; then
@ZevEisenberg
ZevEisenberg / .lldbinit
Created September 12, 2018 01:59 — forked from woolsweater/.lldbinit
Break on unsatisfiable constraints and send to wtfautolayout
command script import ~/.lldbscripts/break_unsatisfiable.py
@ZevEisenberg
ZevEisenberg / README.md
Last active March 25, 2023 19:24
Test lots of values without lots of boilerplate

This snippet has been released as a full open-source library. Check it out at TestCleaner!

@ZevEisenberg
ZevEisenberg / Dismiss Disk Not Ejected Properly Dialogs.scpt
Created March 6, 2023 05:38
Dismiss Disk Not Ejected Properly Dialogs
tell application "System Events" to tell process "Notification Center"
repeat with notificationWindow in windows
tell notificationWindow
set entireContents to entire contents
repeat with content in reverse of entireContents -- iterate backwards so we close bottom notifications first, if that matters
if class of content is group then
set groupStaticTexts to static texts of content
repeat with staticText in groupStaticTexts
set foundText to false
if value of staticText is equal to "Disk Not Ejected Properly" then
@ZevEisenberg
ZevEisenberg / RxSignpost.swift
Last active March 16, 2022 01:54
Use os_signpost for performance logging of transformations in RxSwift
// RxSwift signposts
import os.signpost
import RxSwift
func signpost<T>(log: OSLog, name: StaticString, value: String, _ thing: () throws -> T) rethrows -> T {
let signpostID = OSSignpostID(log: log)
os_signpost(
.begin,
@ZevEisenberg
ZevEisenberg / LICENSE
Last active February 19, 2022 02:04
Smoothly deselect table and collection view cells on dismissal, including interactive dismiss and interactively-partially-dismiss-then-cancel-then-dismiss-again
The MIT License (MIT)
Copyright (c) 2016 Zev Eisenberg
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
import SwiftUI
struct ContentView: View {
var body: some View {
NicerButton(action: {}, label: { isPressed in
Text("Rabbit Season")
.foregroundColor(Color.white)
.frame(width: 200)
.padding()
.background(Color.blue.brightness(isPressed ? -0.3 : 0))
@ZevEisenberg
ZevEisenberg / TypedMutableCopying.swift
Last active August 18, 2021 20:37
Adds typed mutable copying to NSMutableCopying conformers
import Foundation
protocol TypedMutableCopying {
associatedtype ConstantVersion
associatedtype MutableVersion
var typedCopy: ConstantVersion { get }
var typedMutableCopy: MutableVersion { get }
}