Skip to content

Instantly share code, notes, and snippets.

View embrenneke's full-sized avatar

Emily Brenneke embrenneke

View GitHub Profile
@frankus
frankus / gist:f13830ea658bed55ca41
Created August 13, 2015 00:14
Updates Xcode's default file-header comment to correct filename
find . -iname '*.[mh]' -print0 | while IFS= read -r -d '' file; do basename=`basename "$file"`; sed -i .bak "2s|// .*\$|// $basename|" "$file"; done
@frankus
frankus / gist:5ce28924819a812a2035
Created August 12, 2015 23:16
One-liner to find filenames whose header comments no longer match
find . -iname "*.[mh]" -exec sed -n "2s|^// ||p" "{}" \; -exec basename "{}" \; | uniq -u
@pgor
pgor / NSArray+Batching.h
Last active August 29, 2015 14:07
Simple category on NSArray to process it in specified batch sizes
@interface NSArray (Batching)
- (void) enumerateObjectsWithBatchSize:(NSUInteger)batchSize
usingBlock:(void (^)(NSArray* batch, NSUInteger startIndex, BOOL *stop))block;
@end
@joshavant
joshavant / observer_pattern.md
Created April 17, 2014 22:04
Handy little design pattern that lets you kick off processes in arbitrary objects + lets arbitrary dependencies add themselves into a notification chain

##XXAppDelegate.m, XXSomeView.m, some other object, etc##

...
[[XXSomeSingletonController sharedInstance] doThatThing];
...

##XXSomeSingletonControllerObserver.h##

@protocol XXSomeSingletonControllerObserver 
@steipete
steipete / UITableViewMore.m
Last active January 29, 2018 14:19
Using the "More" button. Of course the simple way that Apple uses in Mail/iOS is not public. rdar://16600859
- (NSString *)tableView:(UITableView *)tableView titleForSwipeAccessoryButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"More";
}
- (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"I wanted to be a pretty public API, but then time ran out and they forgot me...");
// Hide the More/Delete menu.
[self setEditing:NO animated:YES];
}
@steventroughtonsmith
steventroughtonsmith / gist:6763213
Created September 30, 2013 12:39
Non-opaque application windows in iOS 7, with optional blur. Shows the user's wallpaper under the app, with Parallax if supported.
typedef enum _UIBackgroundStyle {
UIBackgroundStyleDefault,
UIBackgroundStyleTransparent,
UIBackgroundStyleLightBlur,
UIBackgroundStyleDarkBlur,
UIBackgroundStyleDarkTranslucent
} UIBackgroundStyle;
@interface UIApplication (UIBackgroundStyle)
-(void)_setBackgroundStyle:(UIBackgroundStyle)style;