Skip to content

Instantly share code, notes, and snippets.

View kastiglione's full-sized avatar

Dave Lee kastiglione

View GitHub Profile
/*
* This is an example provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
@kastiglione
kastiglione / signalForSelector.m
Last active August 29, 2015 13:58 — forked from bobspryn/signalForSelector.m
Delegate dance
- (void)viewDidLoad
{
[super viewDidLoad];
@weakify(self);
self.exploreSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, mTCTableViewFrameWidth, 44)];
self.exploreSearchBar.placeholder = @"Search";
[self.exploreSearchBar setBackgroundImage:[UIImage squareImageWithColor:mTCLightTanColor dimension:1] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
self.tableView.tableHeaderView = self.exploreSearchBar;
void (^myBlock)(int);
__block __weak __typeof__(myBlock) myRecursiveBlock = myBlock = ^(int x) {
if (x > 5) {
return;
} else {
myRecursiveBlock(x + 1);
}
};
myBlock(1);
@kastiglione
kastiglione / gist:5679834
Last active December 17, 2015 22:09 — forked from alloy/gist:5679340
- (NSArray *)mapConcurrent;
{
NSArray *originals = self.listOfObjects;
NSUInteger count = originals.count;
NSMutableArray *collected = [[NSMutableArray alloc] initWithCapacity:count];
for (NSUInteger i = 0; i < count; i++) {
[collected addObject:[NSNull null]];
}
CGRect CGRectIntegralScaledEx(CGRect rect, CGFloat scale)
{
return CGRectMake(floorf(rect.origin.x * scale) / scale, floorf(rect.origin.y * scale) / scale, ceilf(rect.size.width * scale) / scale, ceilf(rect.size.height * scale) / scale);
}
CGRect CGRectIntegralScaled(CGRect rect)
{
return CGRectIntegralScaledEx(rect, [[UIScreen mainScreen] scale]);
}