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
#!/bin/bash | |
set -e -u -o pipefail | |
main() { | |
echo '🔪 Kill Xcode' | |
if pgrep Xcode; then killall Xcode; fi | |
echo '💣 Delete cache' | |
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache" |
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 XCTest | |
final class WeakSetTests: XCTestCase { | |
var subject: WeakSet<ThemeObserver>! | |
override func setUp() { | |
subject = [] | |
} |
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
struct Urn {} | |
struct Track {} | |
// Return sync but is async :O | |
func track(for urn: Urn) -> Future<Track> { | |
let promise = Promise<Track>() | |
let remoteTrack = Track() // Imaginte this is async | |
promise.resolve(with: remoteTrack) |
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
# 1) Create an Applescrip, paste this code and save it as .app | |
# 2) Create an Event in Calendar at the time you want to wake up | |
# 3) Set custom Alarm to 'Open File' and select this script.app | |
# Volume | |
set morningVolume to 40 | |
# Happy Music to wake up | |
set morningTrack to "spotify:user:1243225188:playlist:09eeF2PyFuynRTXtIM0mew" |
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 | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
// Instance variable to prevent deallocation. | |
private let externalDependencies: ExternalDependeciesInjection = ExternalDependenciesImplementation() |
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 GoogleAnalytics | |
class GoogleAnalytics: Analytics { | |
func setup() { | |
GAI.sharedInstance().tracker(withTrackingId: "UA-123456789-1") | |
} | |
func track(event: String) { | |
// Common you are google... this is not a nice way to design an API. | |
guard let tracker = GAI.sharedInstance().defaultTracker else { return } | |
let toSend = GAIDictionaryBuilder.createEvent(withCategory: event, |
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 FancyReporter: CrashReporter { | |
func setup() { | |
FancyReporter.horribleSingleton().setup() | |
} | |
func print(error: Error) { | |
FancyReporter.horribleSingleton().report(error) | |
} | |
} |
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 SwiftConsoleReporter: CrashReporter { | |
func setup() { | |
// No need setup | |
} | |
func print(error: Error) { | |
Swift.print(error.localizedDescription) | |
} | |
} |
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 Crashlytics | |
class CrashlyticsReporter: CrashReporter { | |
func setup() { | |
Crashlytics.sharedInstance().setup() | |
} | |
func print(error: Error) { | |
Crashlytics.sharedInstance().recordError(error) | |
} | |
} |
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
protocol Analytics { | |
func setup() | |
func track(event: String) | |
} |
NewerOlder