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
| // Swift 3 | |
| extension URLComponents { | |
| var pathExtension: String { | |
| get { | |
| return NSString(string: self.path).pathExtension | |
| } | |
| set { | |
| let nsStringPath = NSString(string: self.path) | |
| let nsStringPathWithoutExtension = NSString(string: nsStringPath.deletingPathExtension) |
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 Sequence { | |
| func destructure() -> (Element, AnySequence<Element>)? { | |
| var iterator = self.makeIterator() | |
| guard let first = iterator.next() else { return nil } | |
| return (first, AnySequence(IteratorSequence(iterator))) | |
| } | |
| } | |
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 | |
| protocol OptionalType { | |
| associatedtype Wrapped | |
| var value: Wrapped? { get } | |
| } | |
| extension Optional: OptionalType { | |
| var value: Wrapped? { |
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
| --- | |
| layout: null | |
| --- | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> | |
| <channel> | |
| <title>{{ site.title | xml_escape }}</title> | |
| <description>{{ site.description | xml_escape }}</description> | |
| <link>{{ site.real_url }}/</link> | |
| <atom:link href="{{ "/feed.xml" | prepend: site.real_url }}" rel="self" type="application/rss+xml"/> |
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 Credentials { | |
| public init(key: String, secret: String) { | |
| self.key = key | |
| self.secret = secret | |
| } | |
| public let key: String | |
| public let secret: String | |
| } |
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 | |
| struct Person: Codable { | |
| let name: String | |
| } | |
| let person = Person(name: "Soroush") | |
| let archiver = NSKeyedArchiver(forWritingWith: NSMutableData()) |
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
| {% for type in types.implementing.AutoRelationshipable %} | |
| extension {{ type.name }} { | |
| {% for variable in type.storedVariables %} | |
| {% if variable.name|hasSuffix:"ID" and variable.annotations.relationshipType %} | |
| var {% if variable.annotations.relationshipName %}{{ variable.annotations.relationshipName }}{% else %}{{ variable.name|replace:"ID","" }}{% endif %}: {{ variable.annotations.relationshipType }}? { | |
| {% if variable.isOptional %} | |
| guard let {{ variable.name }} = {{ variable.name }} else { return nil } | |
| return FlatCache.shared.get(id: {{ variable.name }}) |
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 { | |
| func chunk(size: Int) -> ChunkedCollection<Self> { | |
| ChunkedCollection(self, size: size) | |
| } | |
| } | |
| struct ChunkedCollection<Base: Collection>: Collection { | |
| private let base: Base | |
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 Vapor | |
| import HTTP | |
| import Foundation | |
| extension Node { | |
| var backDoorToRealValues: Any { | |
| return self.wrapped.backDoorToRealValues | |
| } | |
| } |