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
// A simple type declaration for our Task model | |
// You can look at it as a light-weight model. | |
// Predefining what keys and types a dictionary has. | |
type Task = { | |
createdAt?: string | |
doneAt?: string | |
isDone: Boolean | |
taskType: string | |
title: string | |
userID: 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 | |
import Firebase | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
// Always call first, before doing anything Firebase related. | |
FirebaseApp.configure() | |
// The reference to our wrapper. | |
// You might want to pass it down to your controllers using dependency injection. |
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 UserNotifications | |
import Firebase | |
typealias NotificationPayload = [AnyHashable: Any] | |
protocol NotificationManagerDelegate: class { | |
func notificationsManager(didReceiveToken token: String) | |
func notificationsManager(didReceiveError error: Error) | |
func notificationsManager(didReceiveNotification payload: NotificationPayload, withResponse didRespond: Bool) |
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 | |
import Vision | |
struct TextRecognizer { | |
static func get(from image: CGImage, onComplete: @escaping (String) -> Void) { | |
// We kick off a text recognition handler | |
handle(VNRecognizeTextRequest { (request, error) in | |
// First we need to make sure, that the request returned results | |
guard let observations = request.results as? [VNRecognizedTextObservation] else { |
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 | |
import Vision | |
struct ImageRecognizer { | |
static func get(from image: CGImage, onComplete: @escaping (String) -> Void) { | |
// Kick off a new ML Configuration. | |
// Here I'm not sure if it's a better idea | |
// to create one configurator for the whole class, | |
// or to create a new one every time we want to recognize stuff. |
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
typealias WholeCards = (left: Card, right: Card) | |
struct Game { | |
// The whole card are your left and your right hand. | |
var wholeCards: WholeCards = (.none, .none) { | |
didSet { | |
// We're printing the new cards to debug the ML models. | |
print("New wholeCards: ", wholeCards) | |
} | |
} |
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
var body: some View { | |
VStack { | |
... | |
} | |
.frame(maxWidth: .infinity, maxHeight: .infinity) | |
// We need to start our runner within the body | |
// So we are able to update our immutable view attributes | |
.onAppear(perform: self.run) | |
} | |
} |
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 | |
import SwiftUI | |
struct Canvas { | |
// The image for SwiftUI View | |
let image: Image | |
// The CGImage for further processing | |
let screenshot: CGImage | |
// Failable initializer | |
init?() { |
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
https://docs.brew.sh/Homebrew-on-Linux | |
git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew | |
mkdir ~/.linuxbrew/bin | |
ln -s ~/.linuxbrew/Homebrew/bin/brew ~/.linuxbrew/bin | |
eval $(~/.linuxbrew/bin/brew shellenv) |
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 searchBST(_ root: TreeNode?, _ val: Int) -> TreeNode? { | |
/** | |
Without a root, nothing to find. | |
This is the exist condition of our recursion. | |
*/ | |
guard let node = root else { | |
return nil | |
} |