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
exports.myStorageFunction = functions | |
.region('australia-southeast1') | |
.storage | |
.object() | |
.onFinalize((object) => { | |
// ... | |
}); | |
// Reference: https://stackoverflow.com/questions/43569595/firebase-deploy-to-custom-region-eu-central1 |
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
override func viewDidLoad() { | |
super.viewDidLoad() | |
#if DEVELOPMENT | |
print("Development environment.") | |
#elseif PRODUCTION | |
print("Production environment.") | |
#else | |
print("Unknown environment.") | |
#endif |
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 CryptoKit | |
extension String { | |
var md5: String { | |
let digest = Insecure.MD5.hash(data: self.data(using: .utf8) ?? Data()) | |
return digest.map { | |
String(format: "%02hhx", $0) | |
}.joined() | |
} |
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
// | |
// TextFieldWithLabelCell.swift | |
// Apy | |
// | |
// Created by Artur Daylidonis on 20/5/20. | |
// Copyright © 2020 Artur Daylidonis. All rights reserved. | |
// | |
import UIKit |
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
// | |
// ViewController.swift | |
// HandleCSVFile | |
// | |
// Created by Artur Daylidonis on 18/5/20. | |
// Copyright © 2020 Artur Daylidonis. All rights reserved. | |
// | |
import UIKit | |
import MobileCoreServices |
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
public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { | |
guard let myURL = urls.first else { | |
return | |
} | |
print("import result : \(myURL)") | |
if let data = handleCSVFile(url: myURL) { | |
cells = data | |
tableView.reloadData() | |
} | |
} |
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 UIViewController { | |
func handleCSVFile(url: URL) -> [[String]]? { | |
if let data = try? String(contentsOf: url) { | |
var result: [[String]] = [] | |
let rows = data.components(separatedBy: "\r\n") | |
for row in rows { | |
let columns = row.components(separatedBy: ",") | |
var cells: [String] = [] | |
for item in columns { |
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
func selectFile() { | |
let importMenu = UIDocumentPickerViewController(documentTypes: [(kUTTypeCommaSeparatedText as String)], in: .import) | |
importMenu.delegate = self | |
importMenu.modalPresentationStyle = .formSheet | |
self.present(importMenu, animated: true, completion: 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
public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { | |
guard let myURL = urls.first else { | |
return | |
} | |
print("import result : \(myURL)") | |
} | |
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) { | |
print("view was cancelled") | |
dismiss(animated: true, completion: 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
override func viewDidLoad() { | |
super.viewDidLoad() | |
tableView.register(UINib(nibName: "DataCell", bundle: nil), forCellReuseIdentifier: "DataCell") | |
} | |
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCell(withIdentifier: "DataCell", for: indexPath) as! DataCell | |
return cell |
NewerOlder