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
_ = (Date(timeIntervalSinceNow: -100)..<Date()) ~= Date(timeIntervalSinceNow: -50) | |
// true |
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 StoryboardInstantiatable { | |
static var storyboardName: String { get } | |
static var viewControllerIdentifier: String? { get } | |
static var bundle: Bundle? { get } | |
} | |
public extension StoryboardInstantiatable where Self: UIViewController { | |
public static var storyboardName: String { | |
return String(describing: self) | |
} |
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 CustomStringConvertible where Self: RawRepresentable { | |
var description: String { | |
return String(describing: self.rawValue) | |
} | |
} | |
enum Hoge: Int, CustomStringConvertible { | |
case 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
#!/usr/bin/env xcrun --sdk macosx swift | |
import Foundation | |
let version = "1.1" | |
var debug = false | |
// MARK: Exit status code | |
enum ExitCode: Int32 { | |
case success = 0 |
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 UIScrollView { | |
public enum ScrollDirection { | |
case top | |
case bottom | |
case left | |
case right | |
} | |
public func scroll(to direction: ScrollDirection, animated: Bool) { | |
let offset: CGPoint |
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 DispatchQueue { | |
class func mainSyncSafe(execute work: () -> Void) { | |
if Thread.isMainThread { | |
work() | |
} else { | |
DispatchQueue.main.sync(execute: work) | |
} | |
} | |
class func mainSyncSafe<T>(execute work: () throws -> T) rethrows -> T { |
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
DispatchQueue.main.asyncAfter(deadline: .now() + __var__) { | |
} |
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
#!/usr/bin/env xcrun swift | |
let arguments = Array(Process.arguments.dropFirst()) | |
print(arguments.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
extension ReusableTableViewCell { | |
static var cellIdentifier: String { | |
return String(self) | |
} | |
} |
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 UIView { | |
static func animateIfNeeded(animated: Bool, duration: NSTimeInterval, animations: () -> Void, completion: ((Bool) -> Void)?) { | |
if animated { | |
self.animateWithDuration(duration, animations: animations, completion: completion) | |
} else { | |
animations() | |
completion?(true) | |
} | |
} | |
} |