This file contains hidden or 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
typealias DistanceRange = (from: Double, to: Double) // meters | |
typealias WaterListResult = (water: Water, lodging: Lodging, distance: Double, price: Float?) | |
typealias LodgingAndDistance = (lodging: Lodging, distance: Double?) | |
extension Water { | |
// Returns waters that are sorted by their nearest (nearest to `center`) lodging's distance to `center`. | |
static func watersByProximity(distanceRange: DistanceRange, center: CLLocation) -> [WaterListResult] { | |
return ModelsStorage.waters | |
.flatMap { (water: Water) -> [WaterListResult] in // Map to water's lodgings combined with their distances to center |
This file contains hidden or 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 Foundation | |
typealias someCompletionHandler = (success: Bool) -> () | |
class SomeAbstractLayer { | |
static let sharedInstance = SomeAbstractLayer() | |
var subscribers: [someCompletionHandler] | |
This file contains hidden or 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
// Good old UIWebView delegate | |
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool { | |
if let noArticle = request.URL?.absoluteString?.rangeOfString("article.html")?.isEmpty { | |
if !noArticle, | |
let foundURL = request.URL, | |
let components = NSURLComponents(URL: foundURL, resolvingAgainstBaseURL: false), | |
let queryItems = components.queryItems as? [NSURLQueryItem], | |
let articleIdQueryItem = filter(queryItems, { $0.name == "article_id" }).first, | |
let articleId = articleIdQueryItem.value?.toInt() { |
This file contains hidden or 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
BOOL asyncWaitFor(BOOL *flag, NSTimeInterval timeout) { | |
NSDate *timeoutDate = [NSDate dateWithTimeIntervalSinceNow:timeout]; | |
do { | |
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:timeoutDate]; | |
if ([timeoutDate timeIntervalSinceNow] < 0.0) { | |
break; | |
} | |
} | |
while (!*flag); |
This file contains hidden or 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
#!/bin/bash | |
set -x | |
cd ${0%/*}/.. | |
ARCHIVEPATH=`pwd`/archive | |
IPA_PATH=("${ARCHIVEPATH}"/*.ipa) | |
DSYM_PATH=("${ARCHIVEPATH}"/*.dSYM.zip) | |
CRASHLYTICS_API_KEY=XXXX |
This file contains hidden or 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
// Just a quick hack to achieve something like this: https://www.dropbox.com/s/6a6lsqasee0zp1q/bgview.png?dl=0 | |
@interface MMGradientBackgroundView() | |
@property (strong, nonatomic) UIImage *noiseImage; | |
@end | |
@implementation MMGradientBackgroundView | |
- (instancetype)initWithFrame:(CGRect)frame { |
This file contains hidden or 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
@interface MMBaseReactiveSearchTableViewModel() | |
// Most of these will actually be public/header file | |
@property (copy, nonatomic) NSArray *searchResults; | |
@property (copy, nonatomic) NSString *searchTerm; | |
@property (strong, nonatomic) NSError *error; | |
@property (assign, nonatomic) BOOL isLoading; | |
@property (strong, nonatomic) RACSubject *forceRestartServerRequestSubject; | |
@end |
This file contains hidden or 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
static UIView *PSPDFViewWithSuffix(UIView *view, NSString *classNameSuffix) { | |
if (!view || classNameSuffix.length == 0) return nil; | |
UIView *theView = nil; | |
for (__unsafe_unretained UIView *subview in view.subviews) { | |
if ([NSStringFromClass(subview.class) hasSuffix:classNameSuffix]) { | |
return subview; | |
}else { | |
if ((theView = PSPDFViewWithSuffix(subview, classNameSuffix))) break; | |
} |
This file contains hidden or 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
# /app/controllers/comment.coffee | |
`import promisedProperty from "../utils/promised_property"` | |
CommentController = Ember.ObjectController.extend | |
needs: ["application"] | |
currentUser: Ember.computed.alias('controllers.application.currentUser') | |
isCommentController: true |
This file contains hidden or 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
@interface MMTableViewWithParallaxHeader : UITableView | |
@property (strong, nonatomic) NSArray *forwardTouchesOnTransparentCellToViews; | |
@end | |
@implementation MMTableViewWithParallaxHeader | |
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { | |
if ([self pointInside:point withEvent:event]) { |