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
@propertyWrapper | |
public struct MaxSizeCollection<Value: Collection> { | |
private let _maxSize: UInt? | |
public var _value: Value | |
public init(wrappedValue value: Value) { | |
_value = value | |
_maxSize = nil | |
} |
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 | |
final class SnapshotContainer: UIView { | |
let view: UIView | |
init(_ view: UIView, width: CGFloat, backgroundColor: UIColor = .white) { | |
self.view = view | |
super.init(frame: .zero) |
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 | |
final class MockableTests { | |
struct MockNotFound: Error { | |
let message: String | |
} | |
} | |
extension Bundle { | |
static let tests = Bundle(for: MockableTests.self) |
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 | |
extension UIStackView { | |
@discardableResult | |
func removeAllArrangedSubviews() -> [UIView] { | |
return arrangedSubviews.reduce([UIView]()) { $0 + [removeArrangedSubViewProperly($1)] } | |
} | |
func removeArrangedSubViewProperly(_ view: UIView) -> UIView { | |
removeArrangedSubview(view) |
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
// | |
// YTMXResolver.h | |
// | |
// Copyright 2011 Yasir M Turk. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
#include <dns_sd.h> |
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
dispatch_semaphore_t semaphore = dispatch_semaphore_create(1); | |
dispatch_queue_t renderQueue = dispatch_queue_create("com.throttling.queue", NULL); | |
- (void) onlyExecuteOnceAtATime { | |
if (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW) == 0) { | |
dispatch_async(renderQueue, ^{ | |
// execution code goes here | |
dispatch_semaphore_signal(semaphore); | |
}); | |
} |
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
/* | |
* Log the complete ASIHTTPRequest HTTP Request | |
*/ | |
+ (void)logRequest:(ASIHTTPRequest *)request{ | |
NSLog(@"url:%@", request.url); | |
NSLog(@"method:%@", request.requestMethod); | |
NSLog(@"head:%@", request.requestHeaders); | |
if (request.postLength > 0) { | |
NSLog(@"body:%@", [[NSString alloc]initWithBytes:[request.postBody bytes] length:request.postLength encoding:NSUTF8StringEncoding]); | |
} |
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
// | |
// YTCoreDataAdapter.h | |
// the smart engineer | |
// | |
// Copyright (c) 2013 Yasir M Turk. No rights reserved. | |
// | |
@interface YTCoreDataAdapter : NSObject { | |
} |
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
// | |
// SingletonClass+ARC.h | |
// the smart engineer | |
// | |
// Copyright (c) 2013 Yasir M Turk. No rights reserved. | |
// | |
#import <foundation/Foundation.h> | |
@interface SingletonClass : NSObject { |
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
/* | |
* We can fetch a record, modify it and then call this save function to save our changes | |
*/ | |
- (BOOL)saveToDb{ | |
NSError *error = nil; | |
BOOL returnVal = ( [[self managedObjectContext] save:&error] ); | |
if(error != nil) | |
NSLog(@"%@", error); | |
return returnVal; | |
} |
NewerOlder