Skip to content

Instantly share code, notes, and snippets.

View mattorb's full-sized avatar
🎯
Always trying to find more time for reading and experiments.

Matt Smith mattorb

🎯
Always trying to find more time for reading and experiments.
View GitHub Profile
@mattorb
mattorb / gist:8d1ff62f7b4abb2310b1
Created May 12, 2014 05:03
Enable OS X quicklook text selection
defaults write com.apple.finder QLEnableTextSelection -bool true
killall Finder
@mattorb
mattorb / gist:6451835
Created September 5, 2013 15:35
Objective C block syntax cheat sheet
@mattorb
mattorb / Is iOS dev center back on-line?
Created July 22, 2013 13:44
one-liner to check when dev center is back and say something (bash)
while true; do if `curl -m 15 https://developer.apple.com/devcenter/ios/index.action | grep -v --quiet "maintenance"`; then say "dev center is back online"; fi; sleep 60; done
@mattorb
mattorb / gist:4718078
Created February 5, 2013 21:50
Eliminate dynamic branching in glsl - OpenGL ES 2.0
// Original w/branching
float result;
if(varA < varB)
{
result=100.0;
}
else
{
result=32.0;
}
- (void)scrollViewDidScroll:(UIScrollView *)sender {
BOOL isScrollingRight = _scrollView.contentOffset.x > _previousContentOffsetX;
_mostRecentScrollWasRight = isScrollingRight;
_previousContentOffsetX = _scrollView.contentOffset.x;
CGFloat pageWidth = _scrollView.frame.size.width;
int scrollingToPageNum = isScrollingRight ? (ceil((_scrollView.contentOffset.x - pageWidth) / pageWidth) + 1) : (floor((_scrollView.contentOffset.x -pageWidth) / pageWidth) + 1);
int percentOfScrollToPageOnscreen = isScrollingRight ? floor((((int)_scrollView.contentOffset.x % (int)pageWidth) / pageWidth)*100)
@mattorb
mattorb / gist:415172
Created May 26, 2010 22:31
discrete, custom timed (per frame) UIImageView Animation
// keyTimes = array floats for second [(NSNumber)1.2,(NSNumber)2.0] == 2 frames, 1.2 secs for first frame, 2.0 seconds for second frame
- (void) addDiscreteTimedImageAnimation:(NSString *)animationName view:(UIImageView *)imageView images:(NSArray *)images keyTimes:(NSArray *)keyTimes repeatCount:(float)repeatCount onDone:(SEL)callback {
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
NSMutableArray *values = [[NSMutableArray alloc] initWithCapacity:[images count]];
NSMutableArray *keyTimesAsPercent = [[NSMutableArray alloc] initWithCapacity:[keyTimes count]];
double totalDuration = 0.0;
for(UIImage *image in images) {
[values addObject:(id)(image.CGImage)];
}
notes from the web on better debug breakpoints in xcode
Run > Manage Breakpoints > Add Symbolic Breakpoint
add a breakpoint called "objc_exception_throw"
Create a file named .gdbinit and place it in your home directory. This is the contents of mine:
fb -[NSException raise]
fb -[_NSZombie release]