Skip to content

Instantly share code, notes, and snippets.

Avatar

Zev Eisenberg ZevEisenberg

View GitHub Profile
@ZevEisenberg
ZevEisenberg / Dismiss Disk Not Ejected Properly Dialogs.scpt
Created March 6, 2023 05:38
Dismiss Disk Not Ejected Properly Dialogs
View Dismiss Disk Not Ejected Properly Dialogs.scpt
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
View ContentView.swift
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
View TypedMutableCopying.swift
import Foundation
protocol TypedMutableCopying {
associatedtype ConstantVersion
associatedtype MutableVersion
var typedCopy: ConstantVersion { get }
var typedMutableCopy: MutableVersion { get }
}
@ZevEisenberg
ZevEisenberg / XCTestCase+Extensions.swift
Last active October 4, 2019 09:50
Useful additions for common problems with XCTest
View XCTestCase+Extensions.swift
//
// XCTestCase+Unwrapping.swift
// Created by Zev Eisenberg on 6/2/19.
// Feel free to use, share, etc. No need to credit, but a link back to this page would be nice.
//
import XCTest
extension XCTestCase {
@ZevEisenberg
ZevEisenberg / File_1.json
Created September 5, 2019 13:58
JSON hosting example
View File_1.json
{
"some key": "some value"
}
@ZevEisenberg
ZevEisenberg / RxSignpost.swift
Last active March 16, 2022 01:54
Use os_signpost for performance logging of transformations in RxSwift
View RxSignpost.swift
// 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 / README.md
Last active March 25, 2023 19:24
Test lots of values without lots of boilerplate
View README.md

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

@ZevEisenberg
ZevEisenberg / .lldbinit
Created September 12, 2018 01:59 — forked from woolsweater/.lldbinit
Break on unsatisfiable constraints and send to wtfautolayout
View .lldbinit
command script import ~/.lldbscripts/break_unsatisfiable.py
@ZevEisenberg
ZevEisenberg / guard.swift
Created July 31, 2018 22:12
Example Guard indentation
View guard.swift
let foo: Int? = nil
let bar: Int? = nil
let baz: Int? = nil
func x() {
guard
let foo = foo,
let bar = bar,
let baz = baz
else { return }