Skip to content

Instantly share code, notes, and snippets.

View tudormunteanu's full-sized avatar
👨‍💻
Crafting and leading. 🛠️🚀 #TechLeader #OptimiseForLearning

Tudor M tudormunteanu

👨‍💻
Crafting and leading. 🛠️🚀 #TechLeader #OptimiseForLearning
View GitHub Profile
@tudormunteanu
tudormunteanu / gist:2365784
Created April 12, 2012 09:17
Simple Notification registering
- (void) changeLanguage:(NSNotification *)notif {
}
- (void) registerNotifications {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(changeLanguage:)
name:kLanguageChangeNotification object:nil];
}
typedef enum {
UIButtonTypeCustom = 0, // no button type
UIButtonTypeRoundedRect, // rounded rect, flat white button, like in address card
UIButtonTypeDetailDisclosure,
UIButtonTypeInfoLight,
UIButtonTypeInfoDark,
UIButtonTypeContactAdd,
} UIButtonType;
// retrieve a remote branch (and create it on local)
git checkout -b readability origin/readability
// push to remote a local branch (creates a new branch on the remote repo)
git push origin customButtons // simple, right?
@tudormunteanu
tudormunteanu / gist:3358337
Created August 15, 2012 09:57
Sort NSArray of NSDicts by a key
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:YES];
NSArray *preSortedFinals = [finals sortedArrayUsingDescriptors:[NSArray arrayWithObjects:descriptor, nil]];
NSArray *sortedFinals = [NSArray arrayWithArray:preSortedFinals];
[descriptor release];
return sortedFinals;
@tudormunteanu
tudormunteanu / gist:3359590
Created August 15, 2012 12:11
NSDate and NSDateFormatter
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"dd.MM.yyy HH:mm"];
NSString *date = [NSString stringWithFormat:@"%@ %@", schedule.date, schedule.time];
NSDate *realDate = [df dateFromString:date];
realDate = [realDate dateByAddingTimeInterval:60*60*2];
[df release];
@tudormunteanu
tudormunteanu / gist:3490451
Created August 27, 2012 17:09
UIImage flipped
UIImage *arrowRight = [UIImage imageNamed:@"arrow"];
// horizontal flip
UIImage *arrowLeft = [UIImage imageWithCGImage:arrowRight.CGImage
scale:2.0f orientation:UIImageOrientationUpMirrored];
// vertical flip
UIImage *arrowLeft = [UIImage imageWithCGImage:arrowRight.CGImage
scale:2.0f orientation:UIImageOrientationDownMirrored];
@tudormunteanu
tudormunteanu / gist:3610090
Last active October 10, 2015 01:27
some block examples
+ (void)iterateFromOneTo:(int)limit withBlock:(int (^)(int))block;
- (void) calculateLatestSpieltagWithCompletion:(void (^)(void))completion;
//
// Blocks as properties
//
typedef void(^MyCustomBlock)(void);
@tudormunteanu
tudormunteanu / gist:3656469
Created September 6, 2012 13:52
git improvements
pretty_git_log() {
git log --graph --pretty="tformat:${FORMAT}" $* |
# Replace (2 years ago) with (2 years)
sed -Ee 's/(^[^<]*) ago)/\1)/' |
# Replace (2 years, 5 months) with (2 years)
sed -Ee 's/(^[^<]*), [[:digit:]]+ .*months?)/\1)/' |
# Line columns up based on } delimiter
column -s '}' -t |
# Page only if we need to
less -FXRS
@tudormunteanu
tudormunteanu / gist:3664488
Created September 7, 2012 08:59
Deduplicate NSArray
@interface NSArray (CustomFiltering)
@end
@implementation NSArray (CustomFiltering)
- (NSArray *) filterObjectsByKey:(NSString *) key {
NSMutableSet *tempValues = [[NSMutableSet alloc] init];
NSMutableArray *ret = [NSMutableArray array];
for(id obj in self) {
if(! [tempValues containsObject:[obj valueForKey:key]]) {
@tudormunteanu
tudormunteanu / gist:3755624
Created September 20, 2012 12:36
Xcode 4.5 code snippet path
~/Library/Developer/Xcode/UserData/CodeSnippets/