- WWDC 2012 Session 405 — Modern Objective-C
- WWDC 2012 Session 413 — Migration to Modern Objective-C
- WWDC 2013 Session 228 — Hidden Gems in Cocoa and Cocoa Touch
- WWDC 2014 Session 402 — Introduction to Swift
- WWDC 2014 Session 403 — Intermediate Swift
- WWDC 2014 Session 404 — Advanced Swift
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 Vapor | |
| let drop = Droplet() | |
| drop.get("welcome") { request in | |
| return "Hello" | |
| } | |
| drop.get("uppercase") { request in | |
| guard let word = request.data["word"]?.string else { return "Could not grab the name" } |
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
| public extension UIDevice { | |
| var deviceType: String { | |
| var systemInfo = utsname() | |
| uname(&systemInfo) | |
| let machine = systemInfo.machine | |
| let mirror = Mirror(reflecting: machine) | |
| var identifier = "" | |
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
| private static func createUserEventData(user:SKUser, eventType:SKEventType, sticker:Sticker?) { | |
| // server endpoint | |
| let endpoint = "https://app.stickerkit.io/userEvent/v1/\(user.projectID)" | |
| guard let endpointUrl = URL(string: endpoint) else { | |
| return nil | |
| } | |
| //Make JSON to send to send to server |
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
| Write a function that pluralizes words. | |
| • By default, it just adds "s" to the end. | |
| • But there are some exceptions ("goose" -> "geese") | |
| • Create a dictionary of exceptions, so I can look up "hoof" and get back "hooves". | |
| • The function should first check the dictionary, to see if it has an exception, then fall back to appending "s" |
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
| # HTTP - redirect all requests to HTTPS | |
| server { | |
| listen 80; | |
| listen [::]:80 default_server ipv6only=on; | |
| return 301 https://$host$request_uri; | |
| } | |
| # HTTPS - proxy requests to /parse-server/ | |
| # through to Parse Server | |
| server { |
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
| apt-get update -y | |
| apt-get upgrade -y | |
| apt-get install git -y | |
| curl -fsSL https://get.docker.com/ | sh | |
| apt-get install python-pip -y | |
| pip install docker-compose |
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
| override func tableView(tableView: UITableView, targetIndexPathForMoveFromRowAtIndexPath sourceIndexPath: NSIndexPath, toProposedIndexPath proposedDestinationIndexPath: NSIndexPath) -> NSIndexPath { | |
| if sourceIndexPath.section != proposedDestinationIndexPath.section { | |
| var row = 0 | |
| if sourceIndexPath.section < proposedDestinationIndexPath.section { | |
| row = tableView.numberOfRowsInSection(sourceIndexPath.section) - 1 | |
| } | |
| return NSIndexPath(forItem: row, inSection: sourceIndexPath.section) | |
| } | |
| return proposedDestinationIndexPath; | |
| } |
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
| // How to create your own completion blocks | |
| + (void)responseFrom4sq:(CLLocation*)currentLocation limit:(NSString*)limit block:(void (^)(NSArray *locationDictionary, NSError *error))completionBlock{ | |
| NSString *apiString4aq= @"https://api.foursquare.com/v2/venues/search?ll="; | |
| NSString *clientID = @"&client_id=x&client_secret=y"; | |
| NSString *version = @"&v=20121219"; | |
| NSMutableURLRequest *foursqRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%1.6f,%1.6f%@%@&limit=%@",apiString4aq,currentLocation.coordinate.latitude,currentLocation.coordinate.longitude,clientID,version,limit]]]; | |
| dispatch_queue_t foursqQueue; |
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
| range binaryRangedSearch(int array[], int searchValue, int minimumSearchBounds,int maximumSearchBounds) | |
| { | |
| // We would perform the search much like above | |
| // where we go to find the value. But once we've found it, | |
| // we need to find out where it occurs first and where it occurs last. | |
| if (minimumSearchBounds > maximumSearchBounds) { | |
| range notFound = {-1, 0}; | |
| return notFound; | |
| } |