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
| // Requires: Moya | |
| // (source): https://stackoverflow.com/questions/31949118/send-post-parameters-with-multipartformdata-using-alamofire-in-ios-swift | |
| private static func uploadAsMultipart(_ params: Encodable) -> Task { | |
| let multipart = params.asParams().map { (key, value) -> MultipartFormData in | |
| let data = (value as! String).data(using: .utf8, allowLossyConversion: false)! | |
| return MultipartFormData(provider: .data(data), name: key) | |
| } | |
| return .uploadMultipart(multipart) | |
| } |
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: | |
| 1. Add a dummy UIView behind the main UIView where you want to have a shadow with corner radius effect. | |
| 2. Apply your corner radius to the main UIView. | |
| 3. Call this function with the dummy UIView as the argument for shadowView. | |
| */ | |
| func initShadow(shadowView: UIView, cornerRadius: CGFloat) { | |
| DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { | |
| guard shadowView.layer.shadowPath == nil 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
| let c = """ | |
| <html> | |
| <head> | |
| <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/> | |
| </head> | |
| <body> | |
| \(content ?? "") | |
| </body> | |
| </html> | |
| """ |
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
| // | |
| // URL+naiveUniformType.swift | |
| // MyPocketDoctor | |
| // | |
| // Created by Mark on 26/12/2018. | |
| // Copyright © 2018 Mediaxes. All rights reserved. | |
| // | |
| import Foundation | |
| 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
| // | |
| // FileUploaderService.swift | |
| // https://gist.github.com/markrufino/c0712635fbd258a192f4bb26c57ce443 | |
| // | |
| // Created by Mark on 25/12/2018. | |
| // Copyright © 2018 Mark Rufino. All rights reserved. | |
| // | |
| import AVKit | |
| import Foundation |
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 os | |
| from shutil import copyfile | |
| i = 0 | |
| def mapper(p): | |
| global i | |
| for file_or_dir in os.listdir(p): | |
| d = f"{p}/{file_or_dir}" | |
| if os.path.isfile(d): |
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
| /// - Groups an array of `T` objects, that conform to the `DateSortableType` protocol, based on their `sortingDate` property. | |
| struct DateSortablesContainer<T: DateSortableType> { | |
| /// - An array of dates to be used as keys for `DateSortablesContainer.objectsGroupedByDate`. This is sorted in ascending order. | |
| let dates: [Date] | |
| /// - A dictionary of `[T]` arrays. | |
| let objectsGroupedByDate: Dictionary<Date, [T]> | |
| init(_ dateSortables: [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
| #!/usr/local/bin/python3 | |
| import os | |
| import requests | |
| current_working_directory = os.getcwd() | |
| print(f"Creating a .gitignore for a Swift project @ {current_working_directory}") | |
| swift_gitignore_url = "https://raw.githubusercontent.com/github/gitignore/master/Swift.gitignore" | |
| print(f"Downloading latest gitignore for Swift @ {swift_gitignore_url}") |
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
| // A sample closure that handles your pdf data download | |
| { (response) in | |
| let data = response.data | |
| var writeUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last | |
| writeUrl = writeUrl?.appendingPathComponent("aeon-billing-statement.pdf") | |
| try! data.write(to: writeUrl!) | |
| return writeUrl! | |
| } | |
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 | |
| // TODO: Create custom protocol. | |
| class ViewController: UIViewController { | |
| enum TableViewAssortedCellTypes { | |
| case withSwitch(isOn: Bool) | |
| case withImage(imageName: String) |