This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if canImport(Combine) | |
import Combine | |
import CasePaths | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public typealias Effect<Output> = AnyPublisher<Output, Never> | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Effect { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct BubbleFramesValue { | |
var framesForKey: [AnyHashable: [CGRect]] = [:] | |
var gradientFrame: CGRect? = nil | |
} | |
struct BubbleFramesKey { } | |
extension BubbleFramesKey: PreferenceKey { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Show the Xcode version number over the Dock icon. | |
defaults write com.apple.dt.Xcode DVTEnableDockIconVersionNumber -bool YES | |
# Or set ShowDVTDebugMenu. | |
# Show Index in the Report navigator. | |
# https://pspdfkit.com/blog/2019/how-xcode-indexing-works-and-how-to-solve-problems/ | |
defaults write com.apple.dt.Xcode IDEIndexShowLog -bool YES |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import PlaygroundSupport | |
struct EqualWidthKey: PreferenceKey { | |
static var defaultValue: CGFloat? { nil } | |
static func reduce(value: inout CGFloat?, nextValue: () -> CGFloat?) { | |
switch (value, nextValue()) { | |
case (_, nil): break | |
case (nil, let next): value = next |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See https://stackoverflow.com/q/59367202/77567 | |
import Combine | |
import Foundation | |
extension Publisher { | |
func step(with stepper: @escaping (SteppingSubscriber<Output, Failure>.Event) -> ()) -> AnyCancellable { | |
let subscriber = SteppingSubscriber<Output, Failure>(stepper: stepper) | |
self.subscribe(subscriber) | |
return .init(subscriber) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/xcrun swift | |
// http://alastairs-place.net/blog/2012/06/06/utis-are-better-than-you-think-and-heres-why/ | |
extension String { | |
static let bitsForCodeUnit: [Character: [UInt8]] = { | |
var dict = [Character: [UInt8]]() | |
for (i, ch) in "abcdefghkmnpqrstuvwxyz0123456789".enumerated() { | |
let bits = Array((0 ..< 5).map({ UInt8((i >> $0) & 1) }).reversed()) | |
dict[ch] = bits |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyObject { } | |
var o = MyObject() | |
print("strong o = \(o)") | |
unowned let u = o | |
print("unowned u = \(u)") | |
o = MyObject() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import AppKit; | |
@import ImageIO; | |
@import CoreServices; | |
#define fromCF (__bridge id) | |
#define toCF (__bridge CFTypeRef) | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
CGRect rect = CGRectMake(0, 0, 100, 100); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import PlaygroundSupport | |
typealias Radians = CGFloat | |
extension UIBezierPath { | |
static func simonWedge(innerRadius: CGFloat, outerRadius: CGFloat, centerAngle: Radians, gap: CGFloat) -> UIBezierPath { | |
let innerAngle: Radians = CGFloat.pi / 4 - gap / (2 * innerRadius) | |
let outerAngle: Radians = CGFloat.pi / 4 - gap / (2 * outerRadius) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Decimal / NSDecimal support for lldb | |
# | |
# Put this file somewhere, e.g. ~/.../lldb/Decimal.py | |
# Then add this line to ~/.lldbinit: | |
# command script import ~/.../lldb/Decimal.py | |
import lldb | |
def stringForDecimal(sbValue, internal_dict): | |
from decimal import Decimal, getcontext |