Skip to content

Instantly share code, notes, and snippets.

View dmathewwws's full-sized avatar
🤠

Daniel Mathews dmathewwws

🤠
View GitHub Profile
//
// LHDFingerpaintView.m
// Drawing
//
// Created by Steven Masuch on 2014-07-31.
// Copyright (c) 2014 Lighthouse Labs. All rights reserved.
//
#import "LHDFingerpaintView.h"
## Week 3 Interview Questions
#### Goals
- Understand Storyboards
- Understanding basic application architecture
- Familiarity with most common Cocoa/Foundation classes & patterns (delegation, target-action)
##### Question 1
Delegation should be preferred method. For more information, see http://www.objc.io/issue-7/communication-patterns.html
The custom collection view cell subclass header should look similar to the following code snippet. A couple of things to look for:
It is important that the delegate callbacks include the cell (sender in the following snippet) as one of the parameters. We will need to know which cell invokes the delegate callback in order to find the index path for the cell, which we will then use to retrieve the Photo object to pass to the method to either share or report the photo.
The custom collection view cell subclass should never have or keep a reference to the photo object. Doing so would break MVC pattern where the view should never talk to the model directly.
@import UIKit;
@protocol PanoramaPhotoCollectionViewCellDelegate;

WWDC Sessions by Topics

Language and Runtime

  • 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
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;
}
@dmathewwws
dmathewwws / gist:d430e8817de54f138e81
Last active August 29, 2015 14:19
Completion blocks
// 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;
@dmathewwws
dmathewwws / gist:37a18558426cea5edc84
Created July 11, 2015 21:20
How to limit UITableView row reordering to a section
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;
}
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
# 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 {
@dmathewwws
dmathewwws / gist:6d5bc1ad8f380f0c72b593808ed9d576
Created July 25, 2016 18:08
W5D1 - Swift Mini Assignment
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"