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 RxSwift | |
import RxCocoa | |
public extension UIScrollView { | |
public var rx_reachedBottom: Observable<Bool> { | |
return rx_contentOffset.map { $0.y == (self.contentSize.height - self.frame.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
let view = UIView(frame: CGRectZero) | |
// ↓ | |
let view = UIView(frame: CGRect.zero) | |
// ↓ | |
let view = UIView(frame: .zero) |
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
# rules | |
#- colon | |
#- control_statement | |
#- file_length | |
#- force_cast | |
#- function_body_length | |
#- leading_whitespace | |
#- line_length | |
#- nesting | |
#- operator_whitespace |
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
public protocol FilePathConvertible { | |
var filePath: String { get } | |
var fileURL: NSURL { get } | |
} | |
extension String: FilePathConvertible { | |
public var filePath: String { | |
return self | |
} | |
public var fileURL: NSURL { |
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 UIKit | |
typealias Replacer = String -> String | |
extension String { | |
var first: String { | |
return String(characters.prefix(1)) | |
} | |
} |
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
public extension String { | |
public func split(length: Int) -> [String] { | |
let array = self.characters.map { String($0) } | |
let limit = self.characters.count | |
return 0 | |
.stride(to: limit, by: length) | |
.map({ | |
array[$0..<$0.advancedBy(length, limit: limit)].joinWithSeparator("") | |
}) | |
} |
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 UIKit | |
enum NotificationKey: String { | |
case Hoge | |
} | |
//--------------- pattern1: use protocol-extension | |
protocol NSNotificationObservable: RawRepresentable { | |
var rawValue: String { get } |
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/bash | |
calc_percentage() { | |
echo "$1/$2*100" | bc -l | awk '{s=($0<0)?-1:1;print int($0*s*100+0.5)/100/s;}' | |
} | |
arr=($(cloc --exclude-dir=Pods,Carthage --include-lang=Swift,Objective\ C ./ | sed -e '1,5d' | sed 's/-//g' | sed 's/Objective C/ObjectiveC/g' | awk '{print $5}' | grep -v -e 'code' -e '^S*$')) | |
swift_files=${arr[0]} | |
objc_files=${arr[1]} | |
sum=${arr[2]} |