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
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset { | |
// if the velocity is "slow" it should just go the next cell, otherwise let it go to the next paged position | |
// positive x is moving right, negative x is moving left | |
// slow is < 2.0 | |
CGFloat width = CGRectGetWidth(self.collectionView.frame); | |
NSUInteger currentIndex = MAX(MIN(round(self.collectionView.contentOffset.x / CGRectGetWidth(self.collectionView.frame)), kNumberOfItems - 1), 0); | |
if (fabsf(velocity.x) > 2.0) { | |
CGFloat x = targetContentOffset->x; |
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
// Dependencies: | |
// "rest": "^1.2.0", | |
// "when": "^3.4.6" | |
var when = require('when'); | |
var rest = require('rest'); | |
// allows promises to be passed in as an array | |
var waitForPromises = function(promises) { | |
return when.join.apply(this, promises); |
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
- (BOOL)isNowAGoodTimeForADrink { | |
NSDate *now = [NSDate date]; | |
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; | |
NSDateComponents *components = [gregorian components:NSCalendarUnitWeekday|NSCalendarUnitHour fromDate:now]; | |
BOOL isWeekend = components.weekday == 7 || components.weekday == 0; // sat or sun | |
// it is a good time for a drink on weekends after 11am and weekdays after 5pm | |
return (isWeekend && components.hour >= 11) || (!isWeekend && components.hour >= 17); | |
} |
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
# Input Files | |
# $(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME) | |
# Output Files | |
# $(DERIVED_FILE_DIR)/ParseCrashReporting.txt | |
echo "Parse Crash Reporting" | |
CLOUD_CODE_DIR=${PROJECT_DIR}/ParseCloudCode |
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
# Add the alias below to ~/.bash_profile on a Mac | |
# Save the file and run: source ~/.bash_profile | |
alias code='open $@ -a "Visual Studio Code"' |
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 <XCTest/XCTest.h> | |
// When setting bit shifted values use NS_OPTIONS instead of NS_ENUM | |
// set the value using bit shifting | |
typedef NS_OPTIONS(NSUInteger, MyState) { | |
MyStateNone = 0, // (0000 = 0) | |
MyStateOn = (1 << 0), // (0001 = 1) | |
MyStateOff = (1 << 1), // (0010 = 2) | |
MyStateEnabled = (1 << 2), // (0100 = 4) |
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 <XCTest/XCTest.h> | |
typedef NS_OPTIONS(NSUInteger, LoginState) { | |
LoginStateNone = 0, | |
LoginStateSuccess = (1 << 0), | |
LoginStateFailure = (1 << 1), | |
LoginStateIncomplete = (1 << 2), | |
}; |
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
#pragma mark - Font Size | |
#pragma mark - | |
// Origin: Facebook SDK in FBSDKUIUtility.h (2015) | |
CG_INLINE CGSize ceilForSize(CGSize value) { | |
return CGSizeMake(ceil(value.width), ceil(value.height)); | |
} | |
- (CGSize)getTextSize:(NSString *)text font:(UIFont *)font constrainedSize:(CGSize)constrainedSize lineBreakMode:(NSLineBreakMode)lineBreakMode { |
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
//// Making Code More Readable with Enums and Bitwise Operators | |
// simple enum | |
typedef enum { | |
StatusNone, | |
StatusSuccess, | |
StatusError, | |
} Status; |
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
# LLDB Init | |
# http://lldb.llvm.org/tutorial.html | |
# Import Frameworks | |
# http://furbo.org/2015/05/11/an-import-ant-change-in-xcode/ | |
command alias uikit expr @import UIKit | |
command alias foundation expr @import Foundation | |
# Facebook Chisel | |
command script import /usr/local/opt/chisel/libexec/fblldb.py |