origin: https://github.com/appleboy/git-test
remote: https://github.com/appleboy/html5-template-engine
| /// RepeatingTimer mimics the API of DispatchSourceTimer but in a way that prevents | |
| /// crashes that occur from calling resume multiple times on a timer that is | |
| /// already resumed (noted by https://github.com/SiftScience/sift-ios/issues/52 | |
| class RepeatingTimer { | |
| let timeInterval: TimeInterval | |
| init(timeInterval: TimeInterval) { | |
| self.timeInterval = timeInterval | |
| } |
| Step 1: Enable capabilities "background fetch" | |
| Step2 : Setup AppDelegate.swift | |
| func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { | |
| let settings = UIUserNotificationSettings(forTypes: UIUserNotificationType.Alert, categories: nil) | |
| UIApplication.sharedApplication().registerUserNotificationSettings(settings) | |
| UIApplication.sharedApplication().setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum) | |
| return true; |
| ACTION = build | |
| AD_HOC_CODE_SIGNING_ALLOWED = NO | |
| ALTERNATE_GROUP = staff | |
| ALTERNATE_MODE = u+w,go-w,a+rX | |
| ALTERNATE_OWNER = grantdavis | |
| ALWAYS_SEARCH_USER_PATHS = NO | |
| ALWAYS_USE_SEPARATE_HEADERMAPS = YES | |
| APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer | |
| APPLE_INTERNAL_DIR = /AppleInternal | |
| APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation |
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| import XCPlayground | |
| XCPSetExecutionShouldContinueIndefinitely(true) | |
| extension NSMutableURLRequest { | |
| /// Percent escape |
| extension URLRequest { | |
| private func percentEscapeString(_ string: String) -> String { | |
| var characterSet = CharacterSet.alphanumerics | |
| characterSet.insert(charactersIn: "-._* ") | |
| return string | |
| .addingPercentEncoding(withAllowedCharacters: characterSet)! | |
| .replacingOccurrences(of: " ", with: "+") | |
| .replacingOccurrences(of: " ", with: "+", options: [], range: nil) |
| extension Double { | |
| func stringFromInterval() -> String { | |
| let timeInterval = Int(self) | |
| let millisecondsInt = Int((self.truncatingRemainder(dividingBy: 1)) * 1000) | |
| let secondsInt = timeInterval % 60 | |
| let minutesInt = (timeInterval / 60) % 60 | |
| let hoursInt = (timeInterval / 3600) % 24 |
| // MARK: - ImageMessageModel | |
| import Chatto | |
| import ChattoAdditions | |
| protocol ImageMessageModelProtocol: PhotoMessageModelProtocol { | |
| var url: URL? { get set } | |
| } | |
| public class ImageMessageModel: PhotoMessageModel<MessageModel>, ImageMessageModelProtocol { | |
| // The MIT License (MIT) | |
| // | |
| // Copyright (c) 2017 Alexander Grebenyuk (github.com/kean). | |
| import Foundation | |
| import Alamofire | |
| import RxSwift | |
| import RxCocoa | |
| func makeGetCall() { | |
| // Set up the URL request | |
| let todoEndpoint: String = "https://jsonplaceholder.typicode.com/todos/1" | |
| guard let url = URL(string: todoEndpoint) else { | |
| print("Error: cannot create URL") | |
| return | |
| } | |
| let urlRequest = URLRequest(url: url) | |
| // set up the session |