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 | |
protocol Alphabet { | |
func compositeAction() | |
} | |
class A { | |
let aProperty = "A" | |
} |
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 ExpressionError: Error { | |
case invalidInput | |
case failedParsingValue | |
case unknown | |
} | |
indirect enum Expression { | |
case value(Double) | |
case plus(Expression, Expression) | |
case minus(Expression, Expression) |
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 CGRect { | |
/// 線形補間した矩形を返す | |
/// - parameter rate: 変化割合。0 <= rate <= 1の範囲で指定する。 | |
func lerp(to rect: CGRect, rate: CGFloat) -> CGRect { | |
let lerp = _lerpCurried(rate) | |
return CGRect( | |
x: lerp(origin.x, rect.origin.x), | |
y: lerp(origin.y, rect.origin.y), | |
width: lerp(width, rect.width), | |
height: lerp(height, rect.height) |
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
// | |
// Regex.swift | |
// ha1fRegex | |
// | |
// Created by はるふ on 2016/09/30. | |
// Copyright © 2016年 はるふ. All rights reserved. | |
// | |
import Foundation |
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 UIImage { | |
/// 文字の画像を生成する。文字は中心に置かれる。 | |
/// | |
/// - parameter text: 文字列 | |
/// - parameter font: フォント | |
/// - parameter textColor: 文字色 | |
/// - parameter imageSize: 生成する画像のサイズ(スクリーンスケール倍される) | |
/// - returns: 生成されたテキスト画像 | |
static func fromText(_ text: String, font: UIFont, textColor: UIColor, imageSize: CGSize) -> UIImage { | |
let attributes: [NSAttributedString.Key: Any] = [ |
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
// Disposable | |
enum Disposables { | |
static func create() -> Disposable { | |
NopDisposable() | |
} | |
static func create(_ dispose: @escaping () -> Void) -> Disposable { | |
ClosureDisposable(dispose) | |
} | |
} |
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
// | |
// CachableRequest.swift | |
// LIPS | |
// | |
import Foundation | |
import RxSwift | |
import RxCocoa | |
private extension ObservableType { |