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
/// JavaのStringBuilder的なインターフェースを想定 | |
final class URLBuilder { | |
private var components: URLComponents | |
init?(string: String) { | |
guard let components = URLComponents(string: string) else { | |
return nil | |
} | |
self.components = components | |
} |
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 | |
struct Parsed<Token> { | |
var token: Token | |
var remaining: String | |
init(_ token: Token, remaining: String) { | |
self.token = token | |
self.remaining = remaining | |
} |
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 | |
import RealmSwift | |
private extension Object { | |
/// 再帰的にDictionary型に変換する | |
func asDictionary() -> [String: Any] { | |
return objectSchema.properties | |
.reduce(into: [String: Any](), { (dictionary, property) in | |
let value = self[property.name] | |
dictionary[property.name] = _serializableValue(value) |
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
extension CGPoint { | |
func map(_ transform: (CGFloat) -> CGFloat) -> CGPoint { | |
CGPoint(x: transform(x), y: transform(y)) | |
} | |
} |
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 | |
import RxSwift | |
import RxRelay | |
final class UpdatableArray<T>: ObservableType { | |
enum Action { | |
case replace([T]) | |
case append([T]) | |
case filter((T) -> Bool) |
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
extension Trie { | |
class Node { | |
var element: Element? | |
var children: [Path: Node] | |
init() { | |
self.element = nil | |
self.children = [:] | |
} |
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
private func _jsonSerialization(from encodable: Encodable) throws -> String { | |
let jsonEncoder = JSONEncoder() | |
jsonEncoder.outputFormatting = .prettyPrinted | |
let encodedData = try jsonEncoder.encode(config) | |
return String(data: encodedData, encoding: .utf8)! | |
} | |
func prettyPrint(_ encodable: Encodable) { | |
do { | |
print(try _jsonSerialization(from: encodable)) |
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
// swiftlint:disable all | |
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen | |
{% if catalogs %} | |
{% set imageAlias %}{{param.imageAliasName|default:"AssetImageTypeAlias"}}{% endset %} | |
{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %} | |
#if os(OSX) | |
import AppKit.NSImage | |
{{accessModifier}} typealias {{imageAlias}} = NSImage | |
#elseif os(iOS) || os(tvOS) || os(watchOS) |
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
#!/bin/sh | |
echo "Running pre-commit..." | |
# pre-commit自体が最新かどうかをチェック | |
PRECOMMIT_MASTER_FILE='./script/pre-commit' | |
if [ -e $PRECOMMIT_MASTER_FILE ]; then | |
diff -s $PRECOMMIT_MASTER_FILE ./.git/hooks/pre-commit > /dev/null 2>&1 | |
if [ $? -ne 0 ]; then | |
cp $PRECOMMIT_MASTER_FILE ./.git/hooks/pre-commit |
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 CachableRequestState { | |
/// 読み込み前 | |
case possible | |
/// 読込中 | |
case loading | |
/// 直近のリクエストがエラー | |
case error(Error) | |