ls - show the current diretory pwd - show the current folder cd - go to folder nano - edit file cat - show the content of a file mv - move a folder to another location
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
| // This snippet is a lazy, temporary, inappropriate, not secure fix for error: | |
| // | |
| // "No 'Access-Control-Allow-Origin' header is present on the requested resource". | |
| // | |
| // It works as a proxy and add 'Access-Control-Allow-Origin: *' to the response header. | |
| // | |
| // 1) Init proejct and add dependencies: | |
| // | |
| // ``` | |
| // npm init |
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 ViewController: UIViewController { | |
| private let manager = NewsManager() | |
| private let disposeBag = DisposeBag() | |
| private var articles: [Article] = [] | |
| private let titleLabel: UILabel = { | |
| let label = UILabel() | |
| label.text = NSLocalizedString("News", comment: "") |
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 Foundation | |
| import RxSwift | |
| import RxCocoa | |
| class NewsManager { | |
| typealias NewsLoadState = LoadState<ArticlesResponse> | |
| enum LoadError: Error { | |
| case unknownError | |
| } |
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 Foundation | |
| enum LoadState<T> { | |
| case loading | |
| case updating | |
| case loaded(response: T) | |
| case failed(error: Error) | |
| } |
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 ViewController: UITableViewDataSource { | |
| ... | |
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| let tableViewCell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! NewsTableViewCell | |
| let article = articles[indexPath.row] | |
| tableViewCell.titleLabel.text = article.title | |
| tableViewCell.contentLabel.text = article.content |
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 | |
| import Alamofire | |
| class ImageManager { | |
| private let session = Alamofire.Session() | |
| static let shared = ImageManager() | |
| func load(url: URLConvertible, completionHandler: @escaping (UIImage) -> Void) -> Void { |
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 | |
| class NewsTableViewCell: UITableViewCell { | |
| let titleLabel: UILabel = { | |
| let lable = UILabel() | |
| lable.translatesAutoresizingMaskIntoConstraints = false | |
| lable.numberOfLines = 3 | |
| lable.font = UIFont.systemFont(ofSize: 14) | |
| return lable |
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 | |
| import RxSwift | |
| class ViewController: UIViewController { | |
| private let disposeBag = DisposeBag() | |
| private let client = NewsClient() | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| client.headlines().subscribe(onSuccess: { (response) in |