/// | World |
/// |------------------------------------------|
/// | Module A | Module B | Module C | Module D|
- World is a module
- World is aware of all modules.
- Modules aren't aware of World.
/// | World |
/// |------------------------------------------|
/// | Module A | Module B | Module C | Module D|
| #!/usr/bin/swift | |
| import AppKit | |
| // MARK: - Helpers | |
| @inline(__always) func error(_ message: String) { | |
| print("💥 \(message)") | |
| } | |
| @inline(__always) func success(_ message: String) { |
| extension Collection where SubSequence: Sequence, SubSequence.Iterator.Element == Iterator.Element { | |
| func cut(atSuccession shouldCut: (Iterator.Element, Iterator.Element) throws -> Bool) rethrows -> [Self.SubSequence] { | |
| var (fromIndex, toIndex) = (startIndex, startIndex) | |
| var result: [SubSequence] = [] | |
| for (x, y) in zip(self, dropFirst()) { | |
| defer { toIndex = index(after: toIndex) } | |
| guard try shouldCut(x, y) else { continue } | |
| result.append(self[fromIndex...toIndex]) | |
| fromIndex = index(after: toIndex) | |
| } |
| // | |
| // DON'T do this, or else you risk a deadlock (e.g., by accidentally performing it in a different order somewhere) | |
| // | |
| dispatch_async(firstQueue, ^{ | |
| dispatch_sync(secondQueue, ^{ | |
| // code requiring both queues | |
| }); | |
| }); |
| [ | |
| { "keys": ["super+0"], "command": "toggle_side_bar" }, | |
| { "keys": ["super+shift+o"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} }, | |
| { "keys": ["super+shift+y"], "command": "show_panel", "args": {"panel": "console", "toggle": true} }, | |
| { | |
| "keys": ["super+enter"], | |
| "command": "set_layout", | |
| "args": | |
| { | |
| "cols": [0.0, 1.0], |
| static NSData *PSPDFCalculateSHA256FromFileURL(NSURL *fileURL, CC_LONG dataLength, NSError **error) { | |
| NSCParameterAssert(fileURL); | |
| NSData *shaData; | |
| int fd = open(fileURL.path.UTF8String, O_RDONLY); | |
| if (fd < 0) { | |
| if (error) *error = [NSError pspdf_errorWithCode:PSPDFErrorCodeUnableToOpenPDF description:@"Failed to open file for calculating SHA256."]; | |
| return nil; | |
| } |
| static NSData *PSPDFCalculateSHA256FromFileURL(NSURL *fileURL, CC_LONG dataLength, NSError **error) { | |
| NSCParameterAssert(fileURL); | |
| dispatch_queue_t shaQueue = dispatch_queue_create("com.pspdfkit.sha256-queue", DISPATCH_QUEUE_SERIAL); | |
| __block dispatch_io_t readChannel; | |
| void (^processIntError)(int intError) = ^(int intError) { | |
| if (intError != 0) { | |
| PSPDFLogWarning(@"Stream error: %d", intError); | |
| if (error) *error = [NSError errorWithDomain:@"SHA256Error" code:100 userInfo:@{NSLocalizedDescriptionKey: @"failed to open file for calculating SHA256."}]; |
| #!/usr/bin/env ruby | |
| device_types_output = `xcrun simctl list devicetypes` | |
| device_types = device_types_output.scan /(.*) \((.*)\)/ | |
| runtimes_output = `xcrun simctl list runtimes` | |
| runtimes = runtimes_output.scan /(.*) \(.*\) \((com.apple[^)]+)\)$/ | |
| devices_output = `xcrun simctl list devices` | |
| devices = devices_output.scan /\s\s\s\s(.*) \(([^)]+)\) (.*)/ |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| // put this in your AppDelegate | |
| - (void)changeRootViewController:(UIViewController*)viewController { | |
| if (!self.window.rootViewController) { | |
| self.window.rootViewController = viewController; | |
| return; | |
| } | |
| UIView *snapShot = [self.window snapshotViewAfterScreenUpdates:YES]; | |
| [viewController.view addSubview:snapShot]; | |
| self.window.rootViewController = viewController; |