Skip to content

Instantly share code, notes, and snippets.

Avatar

Sash Zats zats

View GitHub Profile
@zats
zats / gist:4068316
Created Nov 13, 2012
Updating fork from original repository
View gist:4068316
# 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 Dec 15, 2015
Dynamic category icons – Foursquare approach
View gist:5212898
- (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"];
View readme.md
#!/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 Dec 25, 2015
Knowing the nature of text changes, helps to deal with it better.
View ChangeType.md

Change type enumeration

typedef NS_ENUM(NSUInteger, SZSTextChangeType) {
	SZSTextChangeTypeDelete,
	SZSTextChangeTypeInsert,
	SZSTextChangeTypeReplace
};
@zats
zats / UIStoryboardSegueTemplate.m
Last active Jan 2, 2016
Guessed implementation of the `-[UIStoryboardSegueTemplate _perform:]`
View UIStoryboardSegueTemplate.m
- (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 Jan 3, 2016
Git hook to run pod install automatically upon checkout if Podfile change comparing to the last commit
View post-checkout.sh
# 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 Jan 20, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// 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
Fix for ImagePicker's camera resetting [UIApplication sharedApplication].idleTimerDisabled = YES;
View ZTSCameraControllerHelper.m
@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 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:@"http://placekitten.com/%tu/%tu", width, height]];
}
View gist:7a957e72b63f4f6333ee
id mock = mockClass([NSProcessInfo class]);
[mock processInfo];
[verify(mock) processInfo];