Skip to content

Instantly share code, notes, and snippets.

View JoeFerrucci's full-sized avatar

Joe Ferrucci JoeFerrucci

  • Bunches
  • 🇺🇸
View GitHub Profile
@JoeFerrucci
JoeFerrucci / protocols.md
Created May 14, 2016 07:00 — forked from rbobbins/protocols.md
Notes from "Protocol-Oriented Programming in Swift"

PS: If you liked this talk or like this concept, let's chat about iOS development at Stitch Fix! #shamelessplug

Protocol-Oriented Programming in Swift

Speaker: David Abrahams. (Tech lead for Swift standard library)

  • "Crusty" is an old-school programmer who doesn't trust IDE's, debuggers, programming fads. He's cynical, grumpy.

  • OOP has been around since the 1970's. It's not actually new.

  • Classes are Awesome

    • Encapsulation
    • Access control
@JoeFerrucci
JoeFerrucci / zipmap.swift
Created May 2, 2016 21:04
Threw this together real quick. I'll refactor for more performant code and structure. Performance profiling coming soon.
import Foundation
extension Array {
func zipmap(key key: String, value: String, container: [AnyObject]) -> [[String:AnyObject]] {
var result = [[String:AnyObject]]()
let count = min(self.count, container.count)
for i in 0..<count {
var mapping = [String:AnyObject]()
let k = self[i] as! String
API CODE:
===========
GET api/:id/changes
route.get("api/:id/changes", function() {
queryMongoDB(USER_CHANGES).filter("id == %@", id, function(changesData) {
queryMongoDB()
@JoeFerrucci
JoeFerrucci / String+Additions.swift
Last active April 16, 2016 01:17
Repeat a String a number of times.
extension String {
func times(count: Int, separatedBy separator: String = "") -> String {
return Array(count: count, repeatedValue: self).joinWithSeparator(separator)
}
static func times(count: Int, repeatedValue s: String, separatedBy separator: String = "") -> String {
return Array(count: count, repeatedValue: s).joinWithSeparator(separator)
}
}