This file contains 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 Foundation | |
public protocol Invocable: class { | |
func invoke(_ notification: String, _ data: Any) | |
} | |
public protocol Observer: Invocable { | |
associatedtype Value | |
typealias Callback = (_ notification: String, _ data: Value) -> Void | |
var callback: Callback { get } |
This file contains 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 | |
class BaseTableHandler<T> : NSObject, UITableViewDelegate, UITableViewDataSource { | |
typealias TableSection = (name: String?, items: [T]) | |
typealias Action = (T)->Void | |
var collection: [TableSection] = [] | |
weak var table: UITableView? | |
private let selectAction: Action? |
This file contains 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 UIKit based Playground for presenting user interface | |
import UIKit | |
import PlaygroundSupport | |
class EdgeInsetLabel: UILabel { | |
private let textInsets: UIEdgeInsets | |
init(inset: UIEdgeInsets) { | |
textInsets = inset |
This file contains 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 protocol TableCellGenerator: class { | |
var identifier: UITableViewCell.Type { get } | |
var cellHeight: CGFloat { get } | |
var estimatedCellHeight: CGFloat? { get } | |
func generate(tableView: UITableView, for indexPath: IndexPath) -> UITableViewCell | |
func registerCell(in tableView: UITableView) | |
} | |
This file contains 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 XCTest { | |
func expectToEventually(_ test: @autoclosure () -> Bool, timeout: TimeInterval = 1.0, message: String = "") { | |
let runLoop = RunLoop.current | |
let timeoutDate = Date(timeIntervalSinceNow: timeout) | |
repeat { | |
// 1 | |
if test() { | |
return | |
} | |
// 2 |
This file contains 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 Decimal { | |
init(value: NSNumber, precision: Int) { | |
let exponent = pow(10.0, Double(precision)) | |
let mantisa = Decimal((value.doubleValue * exponent).rounded()) | |
let sign = value.floatValue > 0 ? FloatingPointSign.plus : FloatingPointSign.minus | |
self = Decimal(sign: sign, exponent: -precision, significand: mantisa) | |
} | |
} |
This file contains 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
- (NSComparisonResult)compareDatesWith:(NSDate*)otherDate { | |
NSCalendar* calendar = [NSCalendar currentCalendar]; | |
unsigned unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay; | |
NSDateComponents* comp1 = [calendar components:unitFlags fromDate:self]; | |
NSDateComponents* comp2 = [calendar components:unitFlags fromDate:otherDate]; | |
NSInteger comparison = [comp1 year] * 10000 + [comp1 month] * 100 + [comp1 day] - | |
([comp2 year] * 10000 + [comp2 month] * 100 + [comp2 day]); | |
return comparison > 0 ? NSOrderedDescending : comparison < 0 ? NSOrderedAscending : NSOrderedSame; |
This file contains 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
@implementation JsonCleaner | |
- (NSDictionary*)clearJsonDictionaryFromPrivateProperties:(NSDictionary*)jsonDictionary { | |
NSMutableDictionary *tempDict = [NSMutableDictionary dictionaryWithDictionary:jsonDictionary]; | |
for (NSString* key in tempDict.allKeys) { | |
if ([tempDict[key] isKindOfClass:NSDictionary.class]) { | |
tempDict[key] = [self clearJsonDictionaryFromPrivateProperties:tempDict[key]]; | |
} else if ([tempDict[key] isKindOfClass:NSArray.class] && | |
[tempDict[key][0] isKindOfClass:NSDictionary.class]) { | |
NSMutableArray *array = [NSMutableArray array]; |
This file contains 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 Foundation | |
import PortfolioSummaryClient | |
protocol ClassInfo : CustomDebugStringConvertible { | |
var className: String { get } | |
var properties: String { get } | |
} | |
extension NSObject : ClassInfo { |
This file contains 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 interface IProfilable { | |
TimeSpan MeasureWrite(); | |
TimeSpan MeasureRead(); | |
TimeSpan MeasureFind(); | |
} | |
public class Result { | |
public Measurement[] measurements; | |
public Result(params Measurement[] array) { |
NewerOlder