This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Array { | |
func chunk<T : Equatable>(by valueToCompare: (Element) -> T) -> [[Element]] { | |
var currentValue = self[0] | |
var startIndex = 0 | |
var splits = [[Element]]() | |
for (index, value) in self.enumerate() { | |
if valueToCompare(value) != valueToCompare(currentValue) { | |
let newSplit = self[startIndex..<index] | |
splits.append(Array(newSplit)) | |
startIndex = index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
IB_DESIGNABLE @interface BadgedPin : UIView | |
@property (nonatomic, assign) IBInspectable CGFloat badgeDiameter; | |
@property (nonatomic, strong) IBInspectable UIColor *badgeColor; | |
@property (nonatomic, assign) IBInspectable CGFloat badgeStrokeWidth; | |
@property (nonatomic, strong) IBInspectable UIColor *fillColor; | |
@property (nonatomic, strong) IBInspectable NSString *imageName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
http://zoesmith.io | |
Export Bookmarks from Evernote to Pinboard | |
v1.4 12th September 2012 | |
This script takes selected notes in Evernote and sends an email for each to Pinboard, extracting each note's title, source URL and associated tags. The user should enter their Pinboard email address in the pinboardEmail property below, and can choose a default tag to add to each bookmark on import. | |
This code is hacky, horrible and non-error checking (but it worked for me). Don't use on thousands of notes at a time, it'll go all crashy. Try selecting one test note first to see if it works for you. | |
Change log: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/a/16881312/2199136 | |
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { | |
NSString *cellIdentifier = [self cellIdentifierForIndexPath:indexPath]; | |
static NSMutableDictionary *heightCache; | |
if (!heightCache) | |
heightCache = [[NSMutableDictionary alloc] init]; | |
NSNumber *cachedHeight = heightCache[cellIdentifier]; | |
if (cachedHeight) | |
return cachedHeight.floatValue; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In a subclass of UITableViewCell: | |
- (void)awakeFromNib { | |
// http://stackoverflow.com/a/14127936/2199136 | |
[super awakeFromNib]; | |
[self layoutIfNeeded]; | |
self.originalSize = self.bounds.size; | |
self.originalimportantUIElementSize = self.originalimportantUIElement.bounds.size; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://benscheirman.com/2014/03/quick-look-debugging-with-uiview/ | |
#import "UIView+DebugObject.h" | |
@implementation UIView (DebugObject) | |
- (id)debugQuickLookObject { | |
UIGraphicsBeginImageContext(self.frame.size); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
[self.layer renderInContext:context]; |
NewerOlder