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
// Douglas Hill, December 2018 | |
// Made for https://douglashill.co/reading-app/ | |
// Find the latest version of this file at https://github.com/douglashill/KeyboardKit | |
import UIKit | |
/// A table view that allows navigation and selection using a hardware keyboard. | |
/// Only supports a single section. | |
class KeyboardTableView: UITableView { | |
// These properties may be set or overridden to provide discoverability titles for key commands. |
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 FluentPostgreSQL | |
import Vapor | |
public func configure(_ config: inout Config, _ env: inout Environment, _ services: inout Services) throws { | |
// (1) Standard PostgreSQL setup | |
try services.register(FluentPostgreSQLProvider()) | |
let pgURL = Environment.get("DATABASE_URL") ?? "postgres://vapor:vapor@127.0.0.1:5432/vapor" | |
let pgConfig = PostgreSQLDatabaseConfig(url: pgURL)! |
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 Foundation | |
extension String { | |
/// Converts an ISO 8601 formatted `String` into `NSDateComponents`. | |
/// | |
/// - Note: Does not accept fractional input (e.g.: P3.5Y), must be integers (e.g.: P3Y6M). | |
/// - SeeAlso: https://en.wikipedia.org/wiki/ISO_8601#Durations | |
/// - Returns: If valid ISO 8601, an `NSDateComponents` representation, otherwise `nil`. | |
func ISO8601DateComponents() -> NSDateComponents? { | |
// Regex adapted from Moment.js https://github.com/moment/moment/blame/develop/src/lib/duration/create.js#L16 |