Skip to content

Instantly share code, notes, and snippets.

View RuiNelson's full-sized avatar

Rui Nelson RuiNelson

  • Porto, Portugal
View GitHub Profile
import UIKit
import SwiftUI
class ViewController: UIViewController {
var hosting: UIHostingController<SwiftUIView>?
override func viewDidLoad() {
@RuiNelson
RuiNelson / FileManager+isDirectory.swift
Created August 22, 2018 18:01
Check if path is a directory in Swift 4.x
import Foundation
extension FileManager {
func isDirectory(atPath: String) -> Bool {
var check: ObjCBool = false
if fileExists(atPath: atPath, isDirectory: &check) {
return check.boolValue
} else {
return false
}
@RuiNelson
RuiNelson / Levenshtein.swift
Last active August 2, 2023 03:50
Levenshtein distance between two String for Swift 4.x
import Foundation
extension String {
subscript(index: Int) -> Character {
return self[self.index(self.startIndex, offsetBy: index)]
}
}
extension String {
public func levenshtein(_ other: String) -> Int {