Skip to content

Instantly share code, notes, and snippets.

@benjaminsnorris
benjaminsnorris / gist:f864e4e522c8c07bb47f
Created September 10, 2014 14:08
GitReferenceDataFunction
func myGitCommands() -> [String: String] {
var commands = [String: String]()
commands["git status"] = ": shows changed files"
commands["git diff"] = ": shows actual changes"
commands["git add"] = ": adds changed files to the commit"
commands["git commit -m\"notes\""] = ": commits the changes"
commands["git push origin _branch_"] = ": pushes commits to branch named _branch_"
commands["git log"] = ": displays progress log"
commands["git comment --amend"] = ": re-enter last commit message"
@benjaminsnorris
benjaminsnorris / FetchedResultsControllerDataSource.h
Created October 4, 2014 04:55
FetchedResultsControllerDataSource
//
//
// FetchedResultsControllerDataSource.h
//
// Created by Ben Norris on 10/3/14.
// Copyright (c) 2014 BSN Design. All rights reserved.
//
#import <Foundation/Foundation.h>
@benjaminsnorris
benjaminsnorris / navAndStatusBarHeight.m
Created October 29, 2014 04:36
Method for height of nav and status bar
- (CGFloat)navAndStatusBarHeight {
return self.navigationController.navigationBar.frame.size.height + [UIApplication sharedApplication].statusBarFrame.size.height;
}
@benjaminsnorris
benjaminsnorris / ViewController.m
Created November 14, 2014 18:13
UINavigationController Toolbar
self.navigationController.toolbarHidden = NO;
UIBarButtonItem *editingButton = self.editButtonItem;
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
[self setToolbarItems:@[editingButton,spaceItem]];
@benjaminsnorris
benjaminsnorris / TableViewController.m
Created November 17, 2014 23:42
Edit Actions for Table View Row
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *removeButton = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Remove" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
[self deletePlayerAtIndexPath:indexPath];
self.game.startingNumberOfPlayers = @(self.game.startingNumberOfPlayers.integerValue - 1);
}];
UITableViewRowAction *resetScoreButton = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Reset Score" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
[self.game resetScoresForPlayer:[self.fetchedResultsControllerDataSource.fetchedResultsController objectAtIndexPath:indexPath]];
}];
resetScoreButton.backgroundColor = [UIColor primaryColorLight];
return @[removeButton,resetScoreButton];
@benjaminsnorris
benjaminsnorris / main.js
Created November 21, 2014 01:17
Parse Cloud Code Attempt
Parse.Cloud.define("inviteRecipientLogic", function(request, response) {
Parse.Cloud.useMasterKey();
var InviteRecipient = Parse.Object.extend("InviteRecipient");
var Invite = Parse.Object.extend("Invite");
var inviteRecipientQuery = new Parse.Query(InviteRecipient);
var userId = request.params.id;
var user = new Parse.User();
user.id = userId;
@benjaminsnorris
benjaminsnorris / ContactsViewController.m
Created November 22, 2014 02:14
Updating User from Contacts
- (void)updateUserWithContactInfo {
PFUser *currentUser = [PFUser currentUser];
NSString *name = currentUser[nameKey];
NSArray *people = (NSArray *)CFBridgingRelease(ABAddressBookCopyPeopleWithName(ABAddressBookCreateWithOptions(NULL, NULL), (__bridge CFStringRef)(name)));
if (people != nil && people.count > 0) {
ABRecordRef person = (__bridge ABRecordRef)[people objectAtIndex:0];
NSData *photoData = CFBridgingRelease(ABPersonCopyImageDataWithFormat(person, kABPersonImageFormatThumbnail));
NSString *firstName = CFBridgingRelease(ABRecordCopyValue(person, kABPersonFirstNameProperty));
NSString *lastName = CFBridgingRelease(ABRecordCopyValue(person, kABPersonLastNameProperty));
@benjaminsnorris
benjaminsnorris / GradientView.h
Created November 24, 2014 16:28
Gradient View
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface GradientView : UIView
@property (nonatomic, strong) UIColor *startColor;
@property (nonatomic, strong) UIColor *midpointColor;
@property (nonatomic, strong) UIColor *finishColor;
@property (nonatomic, readwrite) float progress;