Skip to content

Instantly share code, notes, and snippets.


Sash Zats zats

View GitHub Profile
zats / ZTSCameraControllerHelper.m
Created May 20, 2014
Fix for ImagePicker's camera resetting [UIApplication sharedApplication].idleTimerDisabled = YES;
View ZTSCameraControllerHelper.m
@interface ZTSCameraControllerHelper ()
@property (nonatomic, assign, getter = isIdleTimerDisabled) BOOL idleTimerDisabled;
@implementation ZTSCameraControllerHelper
+ (instancetype)sharedInstance {
static ZTSCameraControllerHelper *instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
zats / gist:bc3083faf59926476392
Last active Aug 29, 2015
Random kitten as a debugQuickLookObject
View gist:bc3083faf59926476392
- (id)debugQuickLookObject {
NSUInteger width = 100 + (([self hash] >> 4) & 0xFF);
NSUInteger height = 100 + (([self hash] >> 8) & 0xFF);
return [NSURL URLWithString:[NSString stringWithFormat:@"", width, height]];
View gist:7a957e72b63f4f6333ee
id mock = mockClass([NSProcessInfo class]);
[mock processInfo];
[verify(mock) processInfo];
View gish.m
Class mock = mockClass([NSProcessInfo class]);
[mock processInfo];
[verify(mock) processInfo];
View mock.m
@interface Calculator : NSObject
- (NSNumber *)methodA;
- (NSNumber *)methodB;
@implementation Calculator
- (NSNumber *)methodA {
return [self methodB];
- (NSNumber *)methodB {
# You can use lookup mode to retrieve your app’s current metadata.
# Lookup mode will create an App Store package at the set destination.
# The package name will be the app's SKU with the .itmsp extension.
# For example, if your app’s SKU is “myapp1” on iTunes Connect,
# your filename would be myapp1.itmsp. The metadata.xml file within
# the App Store package contains the app's metadata.
iTMSTransporter -m lookupMetadata
-vendor_id APP_SKU -subitemtype [InAppPurchase | GameCenterLeaderboard | GameCenterAchievement]
zats / gist:178d829fed1242b27694
Created Dec 6, 2014
Dinamyc programming.swift
View gist:178d829fed1242b27694
func memoize<T: Hashable, U>( body: ((T)->U, T)->U ) -> (T)->U {
var memo = Dictionary<T, U>()
var result: ((T)->U)!
result = { x in
if let q = memo[x] { return q }
let r = body(result, x)
memo[x] = r
return r
return result
zats / WMLPushNotificationRegistrationService.h
Last active Aug 29, 2015
Push notifications registration: iOS7 & iOS8
View WMLPushNotificationRegistrationService.h
#import <Foundation/Foundation.h>
@interface WMLPushNotificationRegistrationService : NSObject
+ (instancetype)sharedInstance;
@property (nonatomic, readonly, getter=isRegisteredForPushNotifications) BOOL registeredForPushNotifications;
* Must be called every app startup, once got user's permission to send push notificaitons
zats /
Last active Aug 29, 2015
Make ViewDebugger in Xcode slightly less confusing

Enchance your view debugging with UIView-<MyViewController>

View gist:e1524d10e6bd35f15088
let str: String
dispatch_sync(dispatch_get_global_queue(QOS_CLASS_UTILITY, 0)) { // Variable 'str' used before being initialized
str = "Hello"
print(str) // Variable 'str' used before being initialized