This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.
To capture the video (filesize: 19MB), using the free "QuickTime Player" application:
#import <UIKit/UIKit.h> | |
@interface DateFlowLayout : UICollectionViewFlowLayout | |
@end |
// | |
// 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 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 |
- (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]; | |
} |
// #!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/ |
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]; |
@objc class JPTiltShiftGenerator: NSObject, CIFilterConstructor { | |
@objc func filterWithName(name: String)->CIFilter? { | |
return JPTiltShift() | |
} | |
} | |
class JPTiltShift : CIFilter { | |
class func register() { |
/// 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 |