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
My stuff is all based off the Xcode keymap—it helps you start with a little bit of familiarity. | |
Run is weird in appcode, cause it doesn't hit the breakpoints like Xcode's run does. What you want is Debug. | |
I have mapped Debug to ⌘+R, and Debug... to ⌘+⇧+R (Debug... is awesome!) (Also if you hold shift when you are in the Debug... menu you can run instead of debug) | |
I have remapped ⌘+T to Class... Effectively this allows me to open new tabs a la Sublime style where you hit command t for a new tab, and then enter the class name you want to open in that tab. | |
I don't like a lot of the ⌘+1 through ⌘+9 windows the way they are. I picked the ones I like and then remapped them to the lower keys for the ones I like to use a lot. I also hid all the tool window bars. |
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
var animals = ["cow", "dog", "pig"] | |
var emoji = ["🐮", "🐶", "🐷"] | |
for (animal, pic) in Zip2(animals, emoji) { | |
println("\(animal) \(pic)") | |
} |
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
extension Array { | |
func each (block : (T) -> ()) { | |
for item in self { | |
block(item) | |
} | |
} | |
} | |
animals.each(println) |
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
extension NSURL : StringLiteralConvertible { | |
public class func convertFromStringLiteral(value: String) -> Self { | |
return self(string: value) | |
} | |
public class func convertFromExtendedGraphemeClusterLiteral(value: String) -> Self { | |
return self(string: value) | |
} | |
} |
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
// TinyWeb OOP(ish) Style | |
import Foundation | |
class HTTPResponse { | |
let body: String | |
let responseCode: Int | |
init(body: String, responseCode: Int) { | |
self.body = body |
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
class Name : StringLiteralConvertible, Equatable { | |
var firstName: String | |
var lastName: String | |
required init(firstName: String, lastName: String) { | |
self.firstName = firstName | |
self.lastName = lastName | |
} | |
class func convertFromStringLiteral(value: StringLiteralType) -> Self { |
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
enum Fallible<T> { | |
case Error(NSError) | |
case Some(T) | |
init(value: T) { | |
self = .Some(value) | |
} | |
init(error: NSError) { | |
self = .Error(error) |
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
class EvenNaturalNumbers: SequenceType { | |
typealias GeneratorType = EvenNaturalNumbersGenerator | |
func generate() -> EvenNaturalNumbersGenerator { | |
return EvenNaturalNumbersGenerator() | |
} | |
} | |
class EvenNaturalNumbersGenerator : GeneratorType { | |
var current = 2 |
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 | |
typealias Vector2D = (x: Float, y: Float) | |
typealias Point2D = Vector2D | |
func -(lhs: Vector2D, rhs: Vector2D) -> Vector2D { | |
return (lhs.x - rhs.x, lhs.y - rhs.y) | |
} |
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
func meanSquaredError(predictions: [Double], values: [Double]) -> Double { | |
let sum = reduce(Zip2(predictions, values), 0.0) { (acc, y) in | |
let diff = y.0 - y.1 | |
return acc + (diff * diff) | |
} | |
return sum / Double(predictions.count) | |
} | |
// what I want is to bind the arguments in the closure to (acc, (yHat, y)) |
OlderNewer