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 UIView { | |
| func add(_ subviews: UIView...) { | |
| subviews.forEach(addSubview) | |
| } | |
| } |
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 IntrinsicTableView: UITableView { | |
| override var contentSize: CGSize { | |
| didSet { | |
| self.invalidateIntrinsicContentSize() | |
| } | |
| } | |
| override var intrinsicContentSize: CGSize { | |
| self.layoutIfNeeded() |
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: Hashable { | |
| var histogram: [Element: Int] { | |
| return self.reduce(into: [:]) { counts, elem in counts[elem, default: 0] += 1 } | |
| } | |
| } |
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 | |
| enum DumbTest { | |
| case get(user: String) | |
| case get(pony: String, tail: String) | |
| func getSome() -> String { | |
| switch self { | |
| case .get(let user): |
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 Date { | |
| class func from(year: Int, month: Int , day: Int ) -> Date { | |
| let gregorianCalendar = NSCalendar(calendarIdentifier: .gregorian)! | |
| var dateComponents = DateComponents() | |
| dateComponents.year = year | |
| dateComponents.month = month | |
| dateComponents.day = day | |
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
| To install custom thrift ( like swift 3 from https://github.com/apocolipse/thrift), | |
| u will need do all this things probably, otherwise just use | |
| brew install thrift | |
| 1. Install homewbrew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
| 2. Install all needed from this: http://thrift.apache.org/docs/install/ | |
| 3. Be sure u installed bison, pkg-config, automake@1.15 | |
| 4. do ./bootstrap.sh, if 'automake command not found' - check if u using needed version, if it linked. Try unlink and link again. | |
| 5. Check if all needed linked, if not do for example: brew link automake | |
| 6. If u got fatal error: 'openssl/err.h' file not found, do: ./configure LDFLAGS='-L/usr/local/opt/openssl/lib' CPPFLAGS='-I/usr/local/opt/openssl/include' |