Skip to content

Instantly share code, notes, and snippets.

View dennislysenko's full-sized avatar

Dennis Lysenko dennislysenko

View GitHub Profile
@dennislysenko
dennislysenko / UIKit+Convenience.swift
Created March 27, 2018 19:04
Tiny set of helpers to make autoresizing-mask-based programmatic UI prototyping more palatable.
import UIKit
public extension UIView {
public var width: CGFloat {
set {
bounds.size.width = newValue
}
get {
return bounds.size.width
}
@dennislysenko
dennislysenko / SimpleMediaSaver.swift
Last active December 10, 2019 02:54
Simplifies saving media on iOS to an app-specific collection in the Photo Library
//
// SimpleMediaSaver.swift
//
// Created by Dennis Lysenko on 27-09-16.
// Copyright © 2016 Dennis Lysenko. All rights reserved.
// https://gist.github.com/dennislysenko/5388cacb83b754e8983e99bff7fef2d2
//
// This gist is licensed under the terms of the MIT license.
//
@dennislysenko
dennislysenko / BKTree.swift
Created June 11, 2015 02:09
Fuzzy String Matching (BK Tree)
// Fuzzy string-matching algorithm
// Implementation of algorithm described at: http://blog.notdot.net/2007/4/Damn-Cool-Algorithms-Part-1-BK-Trees
// Essentially builds an index of strings by levenshtein distance (N-ary tree) on which you can run range queries.
// The root node can be chosen arbitrarily. Each node holds a string and a collection of edges, representing distance to other strings, which then have their own children and so on, building a complete index.
// See https://github.com/vy/bk-tree for (impressive) performance statistics despite this tending to create an unbalanced N-ary tree
class BKTreeNode {
var value: String
var edges: Dictionary<Int, BKTreeNode>