Skip to content

Instantly share code, notes, and snippets.

View zats's full-sized avatar

Sash Zats zats

View GitHub Profile
@zats
zats / gist:4068316
Created November 13, 2012 20:52
Updating fork from original repository
# Adding original repository as a fork
git remote add --track master forked_from git://github.com/user/repo.git
# Fetch from remote called forked_from
git fetch forked_from
# Merging codeabase
git merge forked_from/master
@zats
zats / gist:5212898
Last active December 15, 2015 05:59
Dynamic category icons – Foursquare approach
- (AFHTTPRequestOperation *)imageFetchOperationForCategoryWithURL:(NSURL *)URL success:(void(^)(AFHTTPRequestOperation *operation, id response))success failure:(void(^)(AFHTTPRequestOperation *operation, NSError *error))failure
{
static NSString *categoriesCacheDirectory;
static NSCache *inMemoryCache;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
inMemoryCache = [[NSCache alloc] init];
categoriesCacheDirectory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
categoriesCacheDirectory = [categoriesCacheDirectory stringByAppendingPathComponent:@"location_icons"];
#!/bin/sh
info_plist="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
spot_environment=$(echo "$GCC_PREPROCESSOR_DEFINITIONS" | sed -n 's/^.*ENVIRONMENT=\(.\)/\1/p')
facebook_url="fb0000000000${spot_environment}"
current_facebook_url=$(/usr/libexec/PlistBuddy -c "Print CFBundleURLTypes:0:CFBundleURLSchemes:0" "$info_plist")
@zats
zats / ChangeType.md
Last active December 25, 2015 23:58
Knowing the nature of text changes, helps to deal with it better.

Change type enumeration

typedef NS_ENUM(NSUInteger, SZSTextChangeType) {
	SZSTextChangeTypeDelete,
	SZSTextChangeTypeInsert,
	SZSTextChangeTypeReplace
};
@zats
zats / UIStoryboardSegueTemplate.m
Last active January 2, 2016 12:59
Guessed implementation of the `-[UIStoryboardSegueTemplate _perform:]`
- (void)_perform:(id)sender {
NSString *identifier = self.destinationViewControllerIdentifier;
UIViewController *sourceViewController = self.viewController;
UIStoryboard *storyboard = sourceViewController.storyboard;
UIViewController *destinationViewController = [storyboard instantiateViewControllerWithIdentifier:identifier];
UIStoryboardSegue *segue = [self segueWithDestinationViewController:destinationViewController];
[sourceViewController prepareForSegue:segue
sender:destinationViewController];
[segue perform];
}
@zats
zats / post-checkout.sh
Last active January 3, 2016 14:19
Git hook to run pod install automatically upon checkout if Podfile change comparing to the last commit
# Existent podfile
current_directory="${PWD}"
current_podfile_path="$current_directory/Podfile"
current_directory_md5=`md5 -q -s "$current_directory"`
temporary_podfile_path="/tmp/${current_directory_md5}.podfile"
echo "Comparing Podfiles\nOld: $current_podfile_path\nNew: $temporary_podfile_path"
# Comparing it to the new Podfile
comparison_result=`comm -1 -3 -i $current_podfile_path $temporary_podfile_path`
@zats
zats / 0_reuse_code.js
Created January 20, 2014 15:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@zats
zats / ZTSCameraControllerHelper.m
Created May 20, 2014 12:18
Fix for ImagePicker's camera resetting [UIApplication sharedApplication].idleTimerDisabled = YES;
@interface ZTSCameraControllerHelper ()
@property (nonatomic, assign, getter = isIdleTimerDisabled) BOOL idleTimerDisabled;
@end
@implementation ZTSCameraControllerHelper
+ (instancetype)sharedInstance {
static ZTSCameraControllerHelper *instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
@zats
zats / gist:bc3083faf59926476392
Last active August 29, 2015 14:01
Random kitten as a debugQuickLookObject
- (id)debugQuickLookObject {
NSUInteger width = 100 + (([self hash] >> 4) & 0xFF);
NSUInteger height = 100 + (([self hash] >> 8) & 0xFF);
return [NSURL URLWithString:[NSString stringWithFormat:@"http://placekitten.com/%tu/%tu", width, height]];
}
id mock = mockClass([NSProcessInfo class]);
[mock processInfo];
[verify(mock) processInfo];