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
| ################################################################# | |
| # = This script transfers bash history to zsh history | |
| # = Change bash and zsh history files, if you don't use defaults | |
| # | |
| # = Usage: ruby bash_to_zsh_history.rb | |
| # | |
| # = Author: Ankit Goyal | |
| ################################################################# | |
| # change if you don't use default values |
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
| protocol ArrayRepresentable { | |
| typealias ArrayType | |
| func toArray() -> ArrayType[] | |
| } | |
| extension Range : ArrayRepresentable { | |
| func toArray() -> T[] { | |
| return T[](self) | |
| } |
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
| // Protocol for a type that supports a fromRaw(Int) conversion | |
| // (such as "enum Foo: Int { ... }") | |
| protocol ConvertibleFromRawInt { | |
| class func fromRaw(raw: Int) -> Self? | |
| } | |
| // Note: Tried to use Swift's standard RawRepresentable protocol rather | |
| // than ConvertibleFromRawInt, but couldn't get it to compile. | |
| // Don't know whether it is a Swift bug or something I was doing wrong. |
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
| - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath { | |
| UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"More" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){ | |
| // maybe show an action sheet with more options | |
| [self.tableView setEditing:NO]; | |
| }]; | |
| moreAction.backgroundColor = [UIColor lightGrayColor]; | |
| UITableViewRowAction *blurAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Blur" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){ | |
| [self.tableView setEditing:NO]; | |
| }]; |
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 | |
| /// An abstract class that makes building simple asynchronous operations easy. | |
| /// Subclasses must implement `execute()` to perform any work and call | |
| /// `finish()` when they are done. All `NSOperation` work will be handled | |
| /// automatically. | |
| open class AsynchronousOperation: Operation { | |
| // MARK: - Properties |
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
| // Playground - noun: a place where people can play | |
| // | |
| // | |
| // By: Hooman Mehr (hooman@mac.com) | |
| // Gist: https://gist.github.com/hooman/599e381d5f037b87d20b (The latest version is always here) | |
| // | |
| // | |
| // Update: 07/30/2014 | |
| // Added WeaklyOwned & removeOrphans for memory management support, added more generics & basic access control. | |
| // 08/06/2014 |
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
| // get your image | |
| var image = UIImage(named: "image.jpg") | |
| // begin a new image | |
| UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, false, UIScreen.mainScreen().scale) | |
| // add a clip in the shape of a rounded rectangle | |
| UIBezierPath(roundedRect: imageView.bounds, cornerRadius: 10.0).addClip() | |
| // draw the image in the view | |
| image.drawInRect(imageView.bounds) | |
| // set the image | |
| imageView.image = UIGraphicsGetImageFromCurrentImageContext() |
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
| protocol Index { | |
| typealias IndexType | |
| typealias Result | |
| subscript (i: IndexType) -> Result { get } | |
| } | |
| protocol IndexMut: Index { | |
| typealias IndexType | |
| typealias Result |
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(Note) | |
| class Note: NSManagedObject { | |
| @NSManaged var content: String | |
| @NSManaged var date: NSDate | |
| @NSManaged var business: Business | |
| @NSManaged var coldcall: ColdCall | |
| @NSManaged var contact: Contact | |
| } |