This file contains hidden or 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 Cocoa | |
struct TaskTitleArray: Equatable { | |
let title: String | |
let children: [TaskTitleArray] | |
init(title: String, children: [TaskTitleArray]) { | |
self.title = title | |
self.children = children | |
} |
This file contains hidden or 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 NonemptySequence<Element> { | |
fileprivate let _storage: [Element] | |
public init(first: Element, rest: [Element]) { | |
_storage = [first] + rest | |
} | |
} | |
extension NonemptySequence: Sequence { | |
// call through to _storage here |
This file contains hidden or 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
var photos = Application("Photos"); | |
var al = photos.albums.whose({ name: 'ALBUM_NAME' })[0].get(); | |
photos.add([photos.mediaItems.whose({ filename: 'FILE_NAME.jpg' })[0].get()], { to: al }); | |
// ... |
This file contains hidden or 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
/* | |
* DO NOT EDIT. | |
* | |
* Generated by the protocol buffer compiler. | |
* Source: Sync/Proto/echo.proto | |
* | |
*/ | |
/* | |
* Copyright 2018, SwiftGRPC Authors All rights reserved. |
This file contains hidden or 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
/* | |
* DO NOT EDIT. | |
* | |
* Generated by the protocol buffer compiler. | |
* Source: echo.proto | |
* | |
*/ | |
/* | |
* Copyright 2018, gRPC Authors All rights reserved. |
This file contains hidden or 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 NIOConcurrencyHelpers | |
import Vapor | |
public protocol CloseableResource: class { | |
var eventLoop: EventLoop { get } | |
var isClosed: Bool { get } | |
func close() | |
} |
This file contains hidden or 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 | |
extension QueryBuilder where Result: Model, | |
Result.Database == Database, | |
Database.Query: FluentSQLQuery, | |
Database.QueryField: SQLColumnIdentifier, | |
Database.QueryField: Hashable, | |
Database.QueryData == Dictionary<String, Database.Query.Expression> { | |
public func update<T>(_ keyPath: WritableKeyPath<Result, T>, to value: T) -> Future<Void> where T: Encodable { | |
Database.queryDataSet(Database.queryField(.keyPath(keyPath)), to: value, on: &query) |
This file contains hidden or 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 Collection where Element: FutureType { | |
/// Flattens an array of futures into a future with an array of results. | |
/// - note: the order of the results will match the order of the futures in the input array. | |
public func flatten(on worker: Worker) -> Future<[Element.Expectation]> { | |
let eventLoop = worker.eventLoop | |
// Avoid unnecessary work | |
guard count > 0 else { | |
return eventLoop.newSucceededFuture(result: []) | |
} |
This file contains hidden or 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 func attributeMarkdownString(_ string: String, defaultAttributes: [NSAttributedString.Key: Any]) -> NSAttributedString { | |
let result = NSMutableAttributedString(string: string, attributes: defaultAttributes) | |
let linkExpression = try! NSRegularExpression(pattern: "\\[([^]]+)\\]\\(([^)]+)\\)") | |
while let linkMatch = linkExpression.firstMatch(in: result.string, range: NSRange(location: 0, length: result.length)) { | |
let linkString = NSMutableAttributedString(attributedString: result.attributedSubstring(from: linkMatch.range(at: 1))) | |
linkString.addAttributes([ | |
.foregroundColor: Appearance.colors.link, | |
.link: result.attributedSubstring(from: linkMatch.range(at: 2)).string, | |
], range: NSRange(location: 0, length: linkString.length)) |
This file contains hidden or 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 | |
import Logging | |
import NIOConcurrencyHelpers | |
import NIO | |
import Async | |
import Service | |
public protocol CloseableResource: AnyObject { | |
var eventLoop: EventLoop { get } | |
OlderNewer