Skip to content

Instantly share code, notes, and snippets.

@johnno1962
johnno1962 / swiftui.swift
Last active November 6, 2019 23:51
SwiftUI Injection
// First, install InjectionIII.app from the Mac AppStore
// https://apps.apple.com/us/app/injectioniii/id1380446739?mt=12
// Make these changes to your code:
// add the following to application(didFinishLaunchingWithOptions:)
#if DEBUG
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle")?.load()
#endif
@nicklockwood
nicklockwood / Withable.swift
Created January 28, 2019 12:06
Withable.swift
/// Withable is a simple protocol to make constructing
/// and modifying objects with multiple properties
/// more pleasant (functional, chainable, point-free)
public protocol Withable {
init()
}
public extension Withable {
/// Construct a new instance, setting an arbitrary subset of properties
init(with config: (inout Self) -> Void) {
@gaquino
gaquino / gist:87bdf0e6e852e445c0489379d3e9732a
Last active April 15, 2024 06:52
MacOS (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools))
If you are facing an error like that on new MacOS version.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
It means that you need to install XCode command line, open a Terminal and run this command:
$ xcode-select --install
Note:
If you want to download and install Command Line tools manually, it can be downloaded from: https://developer.apple.com/download/more/
@sgr-ksmt
sgr-ksmt / file.swift
Created September 26, 2016 05:55
Safe DispatchQueue.main.sync (Swift3.0)
extension DispatchQueue {
class func mainSyncSafe(execute work: () -> Void) {
if Thread.isMainThread {
work()
} else {
DispatchQueue.main.sync(execute: work)
}
}
class func mainSyncSafe<T>(execute work: () throws -> T) rethrows -> T {
@vasanthk
vasanthk / System Design.md
Last active May 23, 2024 18:22
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?