This file contains hidden or 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
| /* @flow */ | |
| import React from 'react' | |
| export interface ReactComponentable<T, U> { | |
| props: T; | |
| state: U; | |
| configureStateFor(props: T): ?U; | |
| } | |
| export class TypedReactComponent<T, U> extends React.Component<*, *, *> implements ReactComponentable<T, U> { |
This file contains hidden or 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 UIKit | |
| protocol StoryboardInstantiate { | |
| static var storyboardIdentifier: String { get } | |
| static var storyboardName: String { get } | |
| } | |
| extension UIStoryboard { | |
| static func instantiateViewController<ViewController: UIViewController>() -> ViewController where ViewController: StoryboardInstantiate { |
This file contains hidden or 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 UIKit | |
| protocol Nibable { | |
| static var nibName: String { get } | |
| } | |
| extension UINib { | |
| convenience init<View: UIView>(nibableClass: View.Type) where View: Nibable { | |
| self.init(nibName: nibableClass.nibName, bundle: nil) |
This file contains hidden or 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
| type SortDirection = "ascending" | "descending" | |
| reverseDirection(sortDirection: SortDirection): SortDirection { | |
| return sortDirection == "ascending" ? "descending" : "ascending" | |
| } | |
| sortStatement(lhs: any, rhs: any, sortDirection: SortDirection): number { | |
| if (lhs === rhs) { | |
| return 0 |
This file contains hidden or 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
| fun main(args: Array<String>) { | |
| Distributer<Initial>().hoge() | |
| // Distributer<Fetch>().hoge() -> | |
| // Type mismatch: inferred type is Distributer<Fetch> but Distributer<Initial> was expected | |
| } | |
| interface DistributeStatusable { | |
| } |
This file contains hidden or 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 Array where Element == Int { | |
| /// Returns the sum of all elements in the array | |
| var total: Element { | |
| return reduce(0, +) | |
| } | |
| /// Returns the average of all elements in the array | |
| var average: Double { | |
| return isEmpty ? 0 : Double(reduce(0, +)) / Double(count) | |
| } | |
| } |
This file contains hidden or 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
| final class SlideView: UIView { | |
| // MARK: - Property | |
| private lazy var scrollView = UIScrollView() | |
| private var contentViews: [UIView] = [] | |
| // MARK: - Initialize | |
This file contains hidden or 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 UIKit | |
| /// viewのlayerとして追加するとクルクル回るようにするコンポーネント | |
| class InfinityRotateAnimation: CABasicAnimation { | |
| override init() { | |
| super.init() | |
| self.keyPath = "transform" | |
| self.repeatCount = .infinity | |
| self.duration = 0.5 |
This file contains hidden or 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 BlinkView: UIView { | |
| // MARK: - Property | |
| private var contentViews: [UIView] = [] | |
| private(set) var displayView: UIView? { | |
| willSet { | |
| displayView?.removeFromSuperview() | |
| if let displayView = newValue { |