This file contains 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 Foundation | |
struct RawNode { | |
let name: String | |
let value: Int | |
let rawDependencies: [String] | |
} | |
// Given a DAG of RawNodes uniquely identified by a `name` |
This file contains 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
{"lastUpload":"2021-12-03T21:46:55.902Z","extensionVersion":"v3.4.3"} |
This file contains 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 Combine | |
let queue = DispatchQueue(label: "bg", qos: .background) | |
let asyncOpQueue = DispatchQueue(label: "async-op-queue") | |
var cancellable: AnyCancellable? | |
func example() { | |
let source = PassthroughSubject<Bool, Never>() | |
cancellable = source |
This file contains 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
func makeUppercase(_ string: String, completion: (String) -> Void) { | |
sleep(2) | |
completion(string.uppercased()) | |
} | |
let subject = CurrentValueSubject<String, Never>("foo") | |
let publisher = subject.eraseToAnyPublisher() | |
let group = DispatchGroup() |
This file contains 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 Subject { | |
let dependency: Dependency | |
func doSomethingAsync() { | |
DispatchQueue.main.async { | |
dependency.doSomething() | |
} | |
} | |
} |
This file contains 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
let group = DispatchGroup() | |
group.notify(queue: .main, work: DispatchWorkItem(block: { | |
print("everything finished") | |
})) | |
func asyncOne() { | |
sleep(2) | |
group.enter() | |
print("finished A") |
This file contains 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 Foundation | |
// Models: | |
struct TrackModel { | |
let title: String | |
} | |
struct UserModel { | |
let name: String |
This file contains 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 | |
protocol CommandExecuting { | |
func run(commandName: String, arguments: [String]) throws -> String | |
} | |
enum BashError: Error { | |
case commandNotFound(name: String) | |
} |
This file contains 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
/** | |
Credit: I've started by reading this SO question: http://stackoverflow.com/questions/20794187/uiimagepickercontroller-editing-view-circle-overlay-edited | |
Trick to add a circle view on image picker editing to facilitate circular cropping | |
Tested on iPhone4s, iPhone5, iPhone6, iPhone6+, iPad - iOS 7 and iOS 8 - on May 2015 | |
**/ | |
#pragma mark - UINavigationControllerDelegate | |
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated |