This file contains 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
/// Returns a string representation of the time elapsed since the entry was logged. | |
/// It works at 4 resolutions: | |
/// - Full: "5yr, 6mo, 3d, 4h, 25m, 35s" | |
/// - Years/Months: "5yr, 6mo" | |
/// - Days/Hours: "3d, 4h" | |
/// - Minutes/Seconds: "25m, 35s" | |
/// - Note: Only non-zero values are rendered: "24m" instead of "24m, 0s" | |
/// - Parameters: | |
/// - loggedDate: The Date when the record was first logged | |
/// - full: A flag that specifies the resolution: if true full resolution, if false scoped resolution |
This file contains 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 UIKit | |
var str = "Hello, playground" | |
/// Int Array Map Function: Adds a value to each element of an array of integers and returns | |
/// the resulting array | |
/// | |
/// - Parameters: | |
/// - delta: value to add to each element of the array | |
/// - array: array of values to increment |
This file contains 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 | |
import UIKit | |
import Foundation | |
class CalculatorBrain { | |
enum Op: CustomStringConvertible { | |
case Operand(Double) | |
case BinaryOperation(String, (Double, Double) -> Double) |
This file contains 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
// bad code | |
func performOperationWith(operation: (Double, Double) -> Double) { | |
if operandStack.count >= 2 { | |
displayValue = operation(operandStack.removeLast(), operandStack.removeLast()) | |
enter() | |
} | |
} | |
func performOperation(operation: Double -> Double) { | |
if operandStack.count >= 1 { |
This file contains 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 *fontFamilyNames = [UIFont familyNames]; | |
for (NSString *familyName in fontFamilyNames) { | |
NSLog(@"Font Family Name = %@", familyName); | |
NSArray *names = [UIFont fontNamesForFamilyName:familyName]; | |
NSLog(@"Font Names = %@", names); | |
} |
This file contains 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)awakeFromNib | |
{ | |
NSLog(@"%@" , NSStringFromSelector(_cmd)); | |
} | |
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tv | |
{ | |
NSLog(@"%@" , NSStringFromSelector(_cmd)); | |
return (NSInteger)0; | |
} |
This file contains 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
// Assumes you've created a texture atlas with at least 2 image init: | |
// initial_image.png and new_image.png | |
// Load the texture atlas into the shared frame cache early in your game… | |
CCSpriteFrameCache* frameCache = [CCSpriteFrameCache sharedSpriteFrameCache]; | |
[frameCache addSpriteFramesWithFile:@"textureAtlas.png"]; | |
// Create your sprite in your layer’s – init method… | |
// (Note: niceSprite is a CSprint* instance variable so we can reuse it) | |
niceSprite = [CCSprite spriteWithSpriteFrameName:@"initial_image.png"]; |