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
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath | |
{ | |
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; | |
for (id obj in cell.subviews) { | |
if ([NSStringFromClass([obj class]) isEqualToString:@"UITableViewCellScrollView"]) { | |
UIScrollView* scroll = (UIScrollView*)obj; | |
scroll.delaysContentTouches = NO; | |
break; | |
} |
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
- (void)registerForAppStateNotifications | |
{ | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil]; | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillEnterForeground) name:UIApplicationWillEnterForegroundNotification object:nil]; | |
} | |
- (void)applicationDidEnterBackground | |
{ | |
self.suspendedRotation = [self.imageView.layer.presentationLayer valueForKeyPath:@"transform.rotation.z"]; | |
} |
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
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { | |
// if decelerating, let scrollViewDidEndDecelerating: handle it | |
if (decelerate == NO) | |
[self snapTable]; | |
} | |
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { | |
[self snapTable]; | |
} |
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
export CLICOLOR=1 | |
export LSCOLORS=GxFxCxDxBxegedabagaced | |
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' | |
alias ls="ls -lA" | |
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
NSBitmapImageRep* offscreenRep = [[NSBitmapImageRep alloc] | |
initWithBitmapDataPlanes:NULL | |
pixelsWide:size.width | |
pixelsHigh:size.height | |
bitsPerSample:8 | |
samplesPerPixel:4 | |
hasAlpha:YES | |
isPlanar:NO | |
colorSpaceName:NSCalibratedRGBColorSpace | |
bytesPerRow:0 |
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
@implementation NSColor (DDExtensions) | |
- (float)distanceTo:(NSColor*)color | |
{ | |
// Calculate color similarity/distance in RGBA color space | |
// http://stackoverflow.com/questions/4754506/color-similarity-distance-in-rgba-color-space | |
// max((r₁-r₂)², (r₁-r₂ - a₁+a₂)²) + | |
// max((g₁-g₂)², (g₁-g₂ - a₁+a₂)²) + | |
// max((b₁-b₂)², (b₁-b₂ - a₁+a₂)²) |
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
- (CGSize)deviceSize | |
{ | |
CGSize size = [UIScreen mainScreen].bounds.size; | |
if ([UIScreen instancesRespondToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] > 1) { | |
size = CGSizeMake(size.width * 2, size.height * 2); // Retina screenshot size support | |
} | |
return 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
# install command line developer tools | |
xcode-select --install | |
# update macports | |
sudo port selfupdate; sudo port upgrade outdated | |
# install cmake | |
sudo port install cmake | |
# download and extract libpng |
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
// | |
// AFNetworkingGDataXMLHTMLResponseSerializer.m | |
// | |
// Created by _ on 17/07/14. | |
// Copyright (c) 2014 cobysy. All rights reserved. | |
// | |
#import "AFNetworkingGDataXMLHTMLResponseSerializer.h" | |
#import <GDataXML-HTML/GDataXMLNode.h> |
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
// memoized Levenshtein Distance | |
// description given here: http://programmingpraxis.com/2014/09/12/levenshtein-distance/ | |
import Foundation | |
// memoize for a two parameter recursive function | |
func memoize<T1: Hashable, T2: Hashable, U>(body: ((T1, T2) -> U, T1, T2) -> U) -> ((T1, T2) -> U) { | |
var memo = [T1: [T2: U]]() | |
var result: ((T1, T2) -> U)! | |
result = { |
OlderNewer