$ brew install imagemagick
In no particular order other than my Twitter list of follows...
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 | |
// This code is based on implementing the following: | |
// Implement an algorithm to determine if a string has all unique characters. What if you cannot use any additional data structures? | |
extension Character { | |
func toString() -> String { | |
return String(self) | |
} | |
} |
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 debounce<T>(delay: TimeInterval, function: @escaping (T) -> Void, complete: @escaping () -> Void = { }) -> (T) -> Void { | |
let queue = DispatchQueue(label: "Debouncer") | |
var current: DispatchWorkItem? | |
return { input in | |
current?.cancel() | |
let new = DispatchWorkItem { | |
function(input) | |
complete() | |
} |
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
// | |
// Coordinator | |
// | |
// Created by Ian Keen. | |
// Copyright © 2018 Ian Keen. All rights reserved. | |
// | |
import ObjectiveC | |
import UIKit |
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
public struct EncodableDictionary { | |
typealias EncodingFunction = (inout KeyedEncodingContainer<AnyCodingKey>) throws -> Void | |
// MARK: - Private Properties | |
private var data: [String: Any] = [:] | |
private var encodings: [String: EncodingFunction] = [:] | |
// MARK: - Lifecycle | |
public 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
// | |
// Operators.swift | |
// FastParsing | |
// | |
// Created by Chris Eidhof on 26/12/2016. | |
// Copyright © 2016 objc.io. All rights reserved. | |
// | |
// TODO: give appropriate credit. Many parts were stolen from SwiftParsec. |
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
/* | |
Joseph Weizenbaum's classic ELIZA chat bot in Swift. | |
Based on the IBM PC BASIC program from CREATIVE COMPUTING by Patricia | |
Danielson and Paul Hashfield, and the Java adaptation by Jesper Juul. | |
Run this script from Terminal: | |
$ swift eliza.swift | |
Press Ctrl-C or Ctrl-D to quit. (Or type "shut up".) |
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
extension UITextView { | |
// Note: This will trigger a text rendering! | |
func calculateViewHeightWithCurrentWidth() -> CGFloat { | |
let textWidth = self.frame.width - | |
self.textContainerInset.left - | |
self.textContainerInset.right - | |
self.textContainer.lineFragmentPadding * 2.0 - | |
self.contentInset.left - | |
self.contentInset.right | |
A common task when developing iOS apps is to register custom cell subclasses for both UITableView
and UICollectionView
. Well, that is if you don’t use Storyboards, of course.
Both UITableView
and UICollectionView
offer a similar API to register custom cell classes:
public func registerClass(cellClass: AnyClass?, forCellWithReuseIdentifier identifier: String)
public func registerNib(nib: UINib?, forCellWithReuseIdentifier identifier: String)
NewerOlder