Skip to content

Instantly share code, notes, and snippets.

Avatar

Zev Eisenberg ZevEisenberg

View GitHub Profile
@ZevEisenberg
ZevEisenberg / resetAllSimulators.sh
Last active Aug 11, 2020
Reset all iOS simulators with this one weird trick
View resetAllSimulators.sh
osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl erase all
@ZevEisenberg
ZevEisenberg / map float range.swift
Last active Jul 13, 2020
Mapping floating point numbers between two ranges in Swift
View map float range.swift
import QuartzCore
extension CGFloat {
func map(from from: ClosedInterval<CGFloat>, to: ClosedInterval<CGFloat>) -> CGFloat {
let result = ((self - from.start) / (from.end - from.start)) * (to.end - to.start) + to.start
return result
}
}
extension Double {
@ZevEisenberg
ZevEisenberg / LICENSE
Last active Jun 25, 2020
Smoothly deselect table and collection view cells on dismissal, including interactive dismiss and interactively-partially-dismiss-then-cancel-then-dismiss-again
View LICENSE
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:
@ZevEisenberg
ZevEisenberg / RxSignpost.swift
Last active May 18, 2020
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 / Files changed during macOS Security Update 2017-001 installation.txt
Created Nov 29, 2017
Files changed during macOS Security Update 2017-001 installation
View Files changed during macOS Security Update 2017-001 installation.txt
11:55:09 AM ↗️ 0x15900 /Users/zev/Library/Preferences/com.apple.spaces.plist.P2AbRcF
11:55:09 AM ↘️ 0x10800 /Users/zev/Library/Preferences/com.apple.spaces.plist
11:55:09 AM ↗️ 0x15900 /Users/zev/Library/Preferences/com.tristan.FSMonitor.plist.cR5WRLP
11:55:09 AM ↘️ 0x10800 /Users/zev/Library/Preferences/com.tristan.FSMonitor.plist
11:55:09 AM 🆕 0x14100 /Users/zev/Library/Preferences/ByHost/com.apple.loginwindow.0922F432-94E3-55A1-8672-6B66E786F21B.plist.8jDpEFP
11:55:10 AM ↗️ 0x15900 /Users/zev/Library/Preferences/ByHost/com.apple.loginwindow.0922F432-94E3-55A1-8672-6B66E786F21B.plist.8jDpEFP
11:55:10 AM ↘️ 0x10800 /Users/zev/Library/Preferences/ByHost/com.apple.loginwindow.0922F432-94E3-55A1-8672-6B66E786F21B.plist
11:55:10 AM 🛠 0x18000 /private/var/db/diagnostics/Persist/0000000000000283.tracev3
11:55:10 AM 🆕 0x14100 /Users/zev/Library/Preferences/com.tristan.FSMonitor.plist.tbghtkX
11:55:10 AM ❌ 0x11300 /Users/zev/Library/Caches/at.obdev.LaunchBar/IndexingProgressLog.plist
@ZevEisenberg
ZevEisenberg / Find Siteswap Loops.swift
Last active Feb 17, 2020
Find how long it takes for an async siteswap to loop
View Find Siteswap Loops.swift
//
// main.swift
// Swapper
//
// Created by Zev Eisenberg on 12/4/17.
// Copyright © 2017 Zev Eisenberg. All rights reserved.
//
// Code ported from https://www.reddit.com/r/juggling/comments/7839h0/find_number_of_beats_to_loop_a_given_siteswap/douuezu/
// It finds how many beats you would have to juggle an async siteswap pattern before
@ZevEisenberg
ZevEisenberg / keyboardShortcuts.sh
Last active Jan 2, 2020
Keyboard Shortcut Shell Script Magic
View keyboardShortcuts.sh
function addCustomMenuEntryIfNeeded
{
if [[ $# == 0 || $# > 1 ]]; then
echo "usage: addCustomMenuEntryIfNeeded com.company.appname"
return 1
else
local contents=`defaults read com.apple.universalaccess "com.apple.custommenu.apps"`
local grepResults=`echo $contents | grep $1`
if [[ -z $grepResults ]]; then
# does not contain app
@ZevEisenberg
ZevEisenberg / iOS 9 system font properties.json
Created Aug 13, 2015
Result of calling CTFontCopyFeatures on the system font in iOS 9 beta 5
View iOS 9 system font properties.json
[
{
"CTFeatureTypeIdentifier" : 0,
"CTFeatureTypeName" : "All Typographic Features",
"CTFeatureTypeNameID" : -100,
"CTFeatureTypeSelectors" : [
{
"CTFeatureSelectorDefault" : true,
"CTFeatureSelectorName" : "On",
"CTFeatureSelectorNameID" : -101,
@ZevEisenberg
ZevEisenberg / XCTestCase+Extensions.swift
Last active Oct 4, 2019
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 Sep 5, 2019
JSON hosting example
View File_1.json
{
"some key": "some value"
}
You can’t perform that action at this time.