How to Deploy a Rails App to DigitalOcean with Ubuntu 14.04, Phusion Passenger & Nginx, Postgres, and Capistrano
- Choose Server Image
- Choose Size (if this is a hobby app you can probably get away with the smallest)
| class Cart { | |
| var items: [Product] | |
| var paymentMethod: PaymentMethod | |
| // Old implementation | |
| var deliveryAddress: String | |
| var shippingOption: ShippingOption | |
| } |
| class OrderSummaryViewController: UIViewController { | |
| override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
| if segue.identifier == "checkout" { | |
| let vc = segue.destination as! ShippingOptionViewController | |
| vc.cart = cart // pass along cart information to next view controller | |
| } | |
| } | |
| } |
| class OrderSummaryViewController: UIViewController { | |
| override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
| if segue.identifier == "checkout" { | |
| let vc = segue.destination as! DeliveryAddressViewController | |
| vc.cart = cart // pass along cart information to next view controller | |
| } | |
| } | |
| } |
| extension KeyedEncodingContainer { | |
| mutating func encode(_ value: UIImage, | |
| forKey key: KeyedEncodingContainer.Key) throws { | |
| let imageData = value.jpegData(compressionQuality: 1) | |
| let prefix = "data:image/jpeg;base64," | |
| guard let base64String = imageData?.base64EncodedString(options: .lineLength64Characters) else { | |
| throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: "Can't encode image to base64 string.")) |
| func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
| if segue.identifier == "showDetail" { | |
| if let indexPath = tableView.indexPathForSelectedRow { | |
| let object = fetchedResultsController.object(at: indexPath) | |
| let controller = (segue.destination as! UINavigationController).topViewController as! DetailViewController | |
| controller.detailItem = object | |
| controller.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem | |
| controller.navigationItem.leftItemsSupplementBackButton = true | |
| } | |
| } |
| enum ImageEncodingQuality: CGFloat { | |
| case png = 0 | |
| case jpegLow = 0.2 | |
| case jpegMid = 0.5 | |
| case jpegHigh = 0.75 | |
| } | |
| extension KeyedEncodingContainer { | |
| mutating func encode(_ value: UIImage, |
| struct Base64ImageWrapper: Codable { | |
| let image: UIImage | |
| public init(from decoder: Decoder) throws { | |
| let container = try decoder.singleValueContainer() | |
| let base64String = try container.decode(String.self) | |
| let components = base64String.split(separator: ",") | |
| if components.count != 2 { | |
| throw DecodingError.dataCorruptedError(in: container, debugDescription: "Wrong data format") | |
| } |
| var float: Float = 0.01 | |
| var floatSum: Float = 0 | |
| for i in 0..<100 { | |
| floatSum += float | |
| } | |
| floatSum | |
| floatSum == 1 | |
| var double: Double = 0.01 |
On OS/X Sierra, after recently running a brew update I started receiving the error message Sorry, you can't use byebug without Readline when trying to run some rake tasks in my ruby project folder. I observed this in projects and gems that include byebug or pry in their Gemfile or gem.spec. I've found in my googling that many begin encountering this error message after running a brew update but there are other triggering conditions as well.
>> rake aws:show_config
WARN: Unresolved specs during Gem::Specification.reset:
mime-types (>= 0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
Sorry, you can't use byebug without Readline. To solve this, you need to