Skip to content

Instantly share code, notes, and snippets.

View activcoding's full-sized avatar
👾
Coding

Tom Ludwig activcoding

👾
Coding
View GitHub Profile
@activcoding
activcoding / FuzzySearch.swift
Created February 6, 2024 17:40
This Fuzzy Search algorithm offers both speed and ease of understanding. A significant advantage is its capability to not only provide the score but also the range of matching characters.
import Foundation
/// FuzzySearchCharacters is used to normalise strings
struct FuzzySearchCharacter {
let content: String
// normalised content is referring to a string that is case- and accent-insensitive
let normalisedContent: String
}
/// FuzzySearchString is just made up by multiple characters, similar to a string, but also with normalised characters
@activcoding
activcoding / FuzzySearch.swift
Created November 1, 2023 14:46
Fuzzy Search in Swift
import Foundation
import CollectionConcurrencyKit
enum FuzzySearch {
/// Searches an array of view models for occurrences of a fuzzy search query.
///
/// This function takes a fuzzy search `query` and an array of `URL`s, and returns a new array that contains only
/// those url's that match the query.
/// The function uses the `score` function to calculate a score for each url and
/// includes only those url's whose scores are greater than 0.0.
@activcoding
activcoding / Webview.swift
Created August 24, 2021 18:47 — forked from joshbetz/Webview.swift
A simple SwiftUI Webview
import SwiftUI
import WebKit
struct ContentView: View {
var body: some View {
Webview(url: URL(string: "https://google.com")!)
}
}
struct Webview: UIViewRepresentable {