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
// | |
// MP4View.swift | |
// | |
// Created by Tobin Schwaiger-Hastanan on 3/25/16. | |
// Copyright © 2016 Tobin Schwaiger-Hastanan. All rights reserved. | |
// | |
import UIKit | |
import AVFoundation |
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
/// returns optional relative date interval string like "2d" | |
/// depending on the unitsstyle, see docs at http://apple.co/1ox2sOX | |
/// inject an existing NSDateComponentsFormatter() for performance | |
func relativeDateInterval(date: NSDate, | |
unitsStyle: NSDateComponentsFormatterUnitsStyle, | |
formatter: NSDateComponentsFormatter) -> String? { | |
// inspired by top answer at http://bit.ly/1TzMQqV | |
let formatter = NSDateComponentsFormatter() | |
formatter.unitsStyle = unitsStyle //.Abbreviated, .Full, ... | |
formatter.includesApproximationPhrase = false |
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
@objc class JPTiltShiftGenerator: NSObject, CIFilterConstructor { | |
@objc func filterWithName(name: String)->CIFilter? { | |
return JPTiltShift() | |
} | |
} | |
class JPTiltShift : CIFilter { | |
class func register() { |
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
NSMutableArray *mArray = [NSMutableArray array]; | |
// fetch all image assets | |
PHFetchOptions *fetchOptions = [[PHFetchOptions alloc] init]; | |
fetchOptions.predicate = [NSPredicate predicateWithFormat:@"mediaType == %d", PHAssetMediaTypeImage]; | |
PHFetchResult *result = [PHAsset fetchAssetsWithOptions:fetchOptions]; | |
[result enumerateObjectsUsingBlock:^(PHAsset * __nonnull asset, NSUInteger idx, BOOL * __nonnull stop) { | |
// filter with subtype for screenshot | |
if (asset.mediaSubtypes & PHAssetMediaSubtypePhotoScreenshot) { | |
[mArray addObject:asset]; |
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
// #!Swift-1.1 | |
import Foundation | |
// MARK: - (1) classes | |
// Solution 1: | |
// - Use classes instead of struct | |
// Issue: Violate the concept of moving model to the value layer | |
// http://realm.io/news/andy-matuschak-controlling-complexity/ |
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
- (void)mapView:(GMSMapView*)mapView idleAtCameraPosition:(GMSCameraPosition*)position | |
{ | |
CLLocationCoordinate2D topLeft = mapView.projection.visibleRegion.farLeft; | |
CLLocationCoordinate2D bottomLeft = mapView.projection.visibleRegion.nearLeft; | |
double lat = fabs(topLeft.latitude - bottomLeft.latitude); | |
double mpp = cos(lat * M_PI / 180) * 2 * M_PI * 6378137 / (256 * pow(2, mapView.camera.zoom)); | |
double distance = mpp * mapView.frame.size.width; | |
[[SearchManager shareInstance] distance: distance]; | |
} |
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
/* | |
This example shows how you can use your data structure as a basis for | |
your Firebase security rules to implement role-based security. We store | |
each user by their Twitter uid, and use the following simplistic approach | |
for user roles: | |
0 - GUEST | |
10 - USER | |
20 - MODERATOR |
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
// | |
// ViewController.m | |
// AVPlayerCaching | |
// | |
// Created by Anurag Mishra on 5/19/14. | |
// Sample code to demonstrate how to cache a remote audio file while streaming it with AVPlayer | |
// | |
#import "ViewController.h" | |
#import <AVFoundation/AVFoundation.h> |
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 <UIKit/UIKit.h> | |
@interface DateFlowLayout : UICollectionViewFlowLayout | |
@end |