Skip to content

Instantly share code, notes, and snippets.

View zats's full-sized avatar

Sash Zats zats

View GitHub Profile
Class mock = mockClass([NSProcessInfo class]);
[mock processInfo];
[verify(mock) processInfo];
@zats
zats / gist:1a3fe941251b4a32b531
Created June 12, 2014 15:02
Enabling UIImageRenderingModeAlwaysTemplate for UIImageView
static NSString *const WMLTemplatedAnimationColorFillLayerName = @"WMLTemplatedAnimationFillLayerName";
static NSString *const WMLTemplatedAnimationMaskLayerName = @"WMLTemplatedAnimationMaskLayerName";
@interface UIImageView (WMLTemplatedAnimation)
- (void)wml_startAnimating;
- (void)wml_stopAnimating;
@end
@interface Calculator : NSObject
- (NSNumber *)methodA;
- (NSNumber *)methodB;
@end
@implementation Calculator
- (NSNumber *)methodA {
return [self methodB];
}
- (NSNumber *)methodB {
@zats
zats / ZTSDynamicProxy.h
Created June 28, 2014 12:27
Dynamic proxy
@interface ZTSDynamicProxy : NSProxy
+ (instancetype)dynamicProxyWithObject:(id)object;
@property (nonatomic, strong) id zts_object;
@end
@zats
zats / lookup.sh
Last active August 29, 2015 14:03
# 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
-u USERNAME -p PASSWORD
-vendor_id APP_SKU -subitemtype [InAppPurchase | GameCenterLeaderboard | GameCenterAchievement]
@zats
zats / NSProcessInfo+WMLCompatibility.m
Created October 5, 2014 11:46
Backport of -[NSProcessInfo isOperatingSystemAtLeastVersion:]
@implementation NSProcessInfo (WMLCompatibility)
+ (void)wml_addSelector:(SEL)originalSelector implementedWithSelector:(SEL)newSelector {
if (![self instancesRespondToSelector:originalSelector]) {
Method newMethod = class_getInstanceMethod(self, newSelector);
class_addMethod(self, originalSelector, method_getImplementation(newMethod), method_getTypeEncoding(newMethod));
}
}
+ (void)load {
@zats
zats / gist:178d829fed1242b27694
Created December 6, 2014 22:03
Dinamyc programming.swift
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
zats / Node.h
Last active March 18, 2021 17:48
Implementing NSCopying, NSMutableCopying for immutable class with mutable counterpart
#import <Foundation/Foundation.h>
@interface Node : NSObject <NSCopying, NSMutableCopying>
@property (nonatomic, weak, readonly) Node *parent;
@property (nonatomic, strong, readonly) Node *left;
@property (nonatomic, strong, readonly) Node *right;
- (instancetype)initWithParent:(Node *)parent left:(Node *)left right:(Node *)right;
@end
@interface MutableNode : Node
@zats
zats / WMLPushNotificationRegistrationService.h
Last active August 29, 2015 14:13
Push notifications registration: iOS7 & iOS8
#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
zats / README.md
Last active August 29, 2015 14:19
Make ViewDebugger in Xcode slightly less confusing

Enchance your view debugging with UIView-<MyViewController>