Skip to content

Instantly share code, notes, and snippets.

@leoneparise
leoneparise / appsettings.json
Created February 18, 2018 00:42
PT Feeder App Settings
{
"General": {
"BaseCurrency": "BTC",
"BuyStrategy": "EMASPREAD",
"BuyValue": "-0.3",
"Cost": "2.5",
"DcaEnabled": "-1.5",
"DcaMaxBuySpread": "1.5",
"DcaMaxBuyTimes": "5",
"DcaMaxCost": "0",
//: Playground - noun: a place where people can play
import Foundation
protocol EventType {
var name: String { get }
var info: [ String : Any ] { get }
}
protocol TimedEventType {
//: Playground - noun: a place where people can play
import Foundation
protocol EventType {
var name: String { get }
var category: String? { get }
var info: [ String : Any ] { get }
}
enum SBTEvents:EventType {
module.exports = {
body: {
email: Joi.string().email().required(),
password: Joi.string().regex(/[a-zA-Z0-9]{3,30}/).required()
}
};
import UIKit
import ObjectiveC
fileprivate struct Keys {
static var notificationActive = "lp_notificationActive"
static var notificationDeffered = "lp_notificationDeferred"
}
fileprivate extension NotificationCenter {
if let userInfo = launchOptions?[.remoteNotification] as? [AnyHashable : Any],
let notification = notificationFactory(userInfo: userInfo) {
NotificationCenter.default.post(notification)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if let notification = notificationFactory(userInfo: userInfo) {
NotificationCenter.default.post(notification)
}
completionHandler(.noData)
}
fileprivate func notificationFactory(userInfo: [AnyHashable : Any]) -> RemoteNotificationType? {
guard let type = userInfo["type"] as? String else { return nil }
if type == Notifications.openUserProfile.name.rawValue {
return Notifications.openUserProfile(userInfo: userInfo)
}
return nil
}
extension Notifications {
struct openUserProfile: RemoteNotificationType {
var userId:String
var title: String?
var alert: String?
static var name: Notification.Name {
return Notification.Name("LP_openUserProfile")
}
protocol RemoteNotificationType: NotificationType {
var title:String? { get }
var alert:String? { get }
init?(userInfo: [AnyHashable : Any ])
}