Skip to content

Instantly share code, notes, and snippets.

View davidseek's full-sized avatar
💭
He/Him

David Seek davidseek

💭
He/Him
View GitHub Profile
@davidseek
davidseek / getIncompleteTasks.ts
Last active January 28, 2021 21:24
Push Notification getIncompleteTasks
// 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
@davidseek
davidseek / AppDelegate.swift
Created January 28, 2021 21:05
Notifications-AppDelegate.swift
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.
@davidseek
davidseek / NotificationsManager.swift
Created January 28, 2021 20:55
NotificationsManager.swift
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)
@davidseek
davidseek / TextRecognizer.swift
Last active January 18, 2021 22:54
TextRecognizer.swift
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 {
@davidseek
davidseek / ImageRecognizer.swift
Last active January 19, 2021 01:52
ImageRecognizer.swift
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.
@davidseek
davidseek / Game.swift
Last active January 18, 2021 22:49
Game.swift
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)
}
}
@davidseek
davidseek / Runner.swift
Last active January 18, 2021 22:48
Runner.swift
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)
}
}
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?() {
@davidseek
davidseek / brewonlinux
Last active September 2, 2020 20:52
Brew on linux
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)
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
}