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 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 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 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 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 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 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 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: - Read-Write Queue | |
class ReadWriteQueue { | |
private let specificKey = DispatchSpecificKey<String>() | |
private let queue: DispatchQueue | |
private var isAlreadyInQueue: Bool { | |
return DispatchQueue.getSpecific(key: specificKey) == queue.label | |
} |
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
class ReadWriteQueue { | |
private let specificKey = DispatchSpecificKey<String>() | |
private let queue: DispatchQueue | |
private var isAlreadyInQueue: Bool { | |
return DispatchQueue.getSpecific(key: specificKey) == queue.label | |
} | |
init(label: String = "read-write.queue") { | |
queue = DispatchQueue(label: label, attributes: .concurrent) |
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
enum S { | |
case a, b | |
} | |
struct MapOfS<T> { | |
private var a: T, b: T | |
subscript(_ s: S) -> T { | |
get { | |
switch s { |
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 s<A, B, C>(_ f: @escaping (A) -> (B) -> C) -> (@escaping (A) -> B) -> (A) -> C { | |
return { g in { x in f(x)(g(x)) } } | |
} | |
func k<A, B>(_ x: A) -> (B) -> A { | |
return { _ in x } | |
} | |
func i<A>(_ x: A) -> A { | |
return x |