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 | |
{# So far getting imports hardcoded from config, correct approach might be found here: https://github.com/krzysztofzablocki/Sourcery/issues/670 #} | |
{% for import in argument.imports %} | |
import {{ import }} | |
{% endfor %} | |
{% if argument.testable %}{% for testable in argument.testable %} | |
@testable import {{ testable }} | |
{% endfor %}{% endif %} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>DVTConsoleDebuggerInputTextColor</key> | |
<string>1 1 1 1</string> | |
<key>DVTConsoleDebuggerInputTextFont</key> | |
<string>SFMono-Medium - 12.0</string> | |
<key>DVTConsoleDebuggerOutputTextColor</key> | |
<string>1 1 1 1</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
require 'getoptlong' | |
require 'gitlab' | |
opts = GetoptLong.new( | |
['--help', '-h', GetoptLong::NO_ARGUMENT], | |
['--endpoint', '-e', GetoptLong::REQUIRED_ARGUMENT], | |
['--token', '-t', GetoptLong::REQUIRED_ARGUMENT], | |
['--group', '-g', GetoptLong::REQUIRED_ARGUMENT], | |
['--webhook', '-w', GetoptLong::REQUIRED_ARGUMENT] | |
) |
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
// MARK: - Original material | |
// Brandon Williams - Lenses in Swift: https://youtu.be/ofjehH9f-CU | |
// Lenses and Prisms in Swift: a pragmatic approach: https://broomburgo.github.io/fun-ios/post/lenses-and-prisms-in-swift-a-pragmatic-approach/ | |
// Lenses and Prisms in Swift - Elviro Rocca: https://youtu.be/8VhYFEAQ0FY | |
// Elviro Rocca - Advanced Swift Optics: https://youtu.be/ki2WSw2WXV4 | |
// MARK: - Either | |
enum Either<Left, Right> { |
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 ReactiveSwift | |
import Result | |
// MARK: - Task | |
final class Task<V, E: Error> { | |
typealias ProcessingHandler = (@escaping (Result<V, E>) -> Void, DisposableBag) -> Void | |
enum State { | |
case idle |
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
func prettyDescription(of subject: Any, indentCoeff: Int = 0) -> String { | |
let mirror = Mirror(reflecting: subject) | |
let properties = mirror.children | |
guard let displayStyle = mirror.displayStyle else { | |
return String(reflecting: subject) | |
} | |
let indent = "\t" | |
let globalIndent = String(repeating: indent, count: indentCoeff) |
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
struct ExponentialBackoffConfig { | |
let initialRetries: Int | |
let initialInterval: TimeInterval | |
let maxInterval: TimeInterval | |
let factor: TimeInterval | |
init(initialRetries: Int = 2, initialInterval: TimeInterval = 0.3, maxInterval: TimeInterval = 120, factor: TimeInterval = 1.6) { | |
precondition(initialRetries >= 0 && initialInterval >= 0 && maxInterval >= initialInterval && factor > 1) | |
self.initialRetries = initialRetries |
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
// inspired by https://blog.jle.im/entry/introduction-to-singletons-1.html | |
protocol DoorState {} | |
enum Opened: DoorState {} | |
enum Closed: DoorState {} | |
enum Locked: DoorState {} | |
struct Door<State: DoorState> { | |
let id: Int | |
} |
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 indirect enum OneOrMore<T> { | |
case one(T) | |
case more(T, Self) | |
} | |
// MARK: Creation simplified | |
public extension OneOrMore { | |
static func few(_ head: T, _ tail: T...) -> OneOrMore { | |
few(head, tail) |
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 CoreLocation | |
/// Geohash algorithm implementation. | |
/// | |
/// It is a hierarchical spatial data structure which subdivides space into buckets of grid shape, | |
/// which is one of the many applications of what is known as a Z-order curve, and generally space-filling curves. | |
/// | |
/// Geohashes offer properties like arbitrary precision | |
/// and the possibility of gradually removing characters from the end of the code to reduce its size (and gradually lose precision). | |
/// Geohashing guarantees that the longer a shared prefix between two geohashes is, the spatially closer they are together. |