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
| /// Default `extension` to conform to `TableRow` | |
| extension TableRow { | |
| /// TableRow - conformation | |
| func configure(with model: Any) { | |
| /// Just throw a fatalError | |
| /// because we don't need it. | |
| fatalError() | |
| } | |
| } |
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
| //MARK: - `Shadowed` Protocol Based Type Erasure | |
| /// `shadow` protocol | |
| protocol TableRow { | |
| /// - Recieves a parameter of Concrete Type `Any` | |
| func configure(with model: Any) | |
| } | |
| /// `Row` To be shadowed. | |
| protocol Row: TableRow { | |
| associatedtype Model |
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
| /// Heterogeneous Requirement and Dynamic dispatch availability | |
| /// Generic Wrapper `AnyCellRow` to match Heterogeneous Types + Dynamic Dispatch | |
| struct AnyCellRow: Row { | |
| private let configureClosure: (Any) -> Void | |
| init<T: Row>(_ row: T) { | |
| configureClosure = { object in | |
| /// Asserting that `object` received is `type` of `T.Model` | |
| guard let model = object as? T.Model else { return } |
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
| /// Rows `Interface` | |
| protocol Row { | |
| /// PAT Placeholder for unknown Concrete Type `Model` | |
| associatedtype Model | |
| /// Recieves a parameter of Concrete Type `Model` | |
| func configure(with model: Model) | |
| } | |
| /// Concrete Type `Product` | |
| struct Product { } | |
| /// Concrete Type `Item` |
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 Cell: TableViewCell { | |
| /// `associatedtype` adoption | |
| typealias T = Detail | |
| /// now the compiler knows and reuires | |
| /// to inject only `Detail` into the `func` | |
| func configure(_ model: T) { | |
| /// Configure your cool cell :) | |
| } | |
| } |
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
| /// usage | |
| let extendend = ExtendedDetail() | |
| let detail = Detail() | |
| let detailCell = Cell() | |
| /// This will error | |
| detailCell.configure(extendend) | |
| /// This will be successful. | |
| detailCell.configure(detail) |
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 Detail { | |
| /// `Concrete Type` that will replace the `T` | |
| } | |
| class ExtendedDetail { | |
| /// Potential `Concrete Type` that will replace the `T` | |
| } | |
| class Cell: TableViewCell { | |
| /// `associatedtype` adoption |
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
| protocol TableViewCell { | |
| ///Unknown `Concrete Type` declared as `T` | |
| associatedtype T | |
| /// A function that accepts the unknown `Concrete Type` | |
| /// as it's parameter | |
| func configure(_ model: T) | |
| } |
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
| // Marcin Krzyżanwski | |
| // Code for https://github.com/krzyzanowskim/CryptoSwift/issues/20 | |
| // PHP | |
| ///Please refer to issue: https://github.com/krzyzanowskim/CryptoSwift/issues/20 | |
| function encrypt($plaintext, $key, $iv) { | |
| $ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $plaintext, MCRYPT_MODE_CBC, $iv); | |
| return base64_encode($ciphertext); | |
| } |
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
| <?php | |
| // Credit should be given to; | |
| // https://gist.github.com/bradbernard/7789c2dd8d17c2d8304b#file-php-encyrption | |
| // https://gist.github.com/krzyzanowskim/043be69ab3ba9fd5ba58#file-encryptaeswithphp | |
| $data = '{"verification_code":"123456"}'; | |
| $key = '1234567890123456'; | |
| function aesEncrypt($data, $key) { | |
| $data = addPadding($data); |