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
# Name of the resource we're selectively copying | |
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist | |
# Get references to dev and prod versions of the GoogleService-Info.plist | |
# NOTE: These should only live on the file system and should NOT be part of the target (since we'll be adding them to the target manually) | |
GOOGLESERVICE_INFO_DEV=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Dev/${GOOGLESERVICE_INFO_PLIST} | |
GOOGLESERVICE_INFO_PROD=${PROJECT_DIR}/${TARGET_NAME}/Firebase/Prod/${GOOGLESERVICE_INFO_PLIST} | |
# Make sure the dev version of GoogleService-Info.plist exists | |
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_DEV}" |
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
protocol StackProtocol { | |
associatedtype ElementType | |
var isEmpty: Bool { get } | |
mutating func pop() -> ElementType? | |
mutating func push(_ value: ElementType) | |
} | |
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 where Element == Int { | |
var equilibriumIndexes: [Element]? { | |
var idxs = [Element]() | |
var sum = reduce(0,+) | |
var leftSum = 0 | |
let count = self.count | |
for i in 0..<count { | |
sum = sum - self[i] | |
if leftSum == sum { | |
idxs.append(i) |
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
let xs = [3,5,1,4,6,3,9,11,1,0,3] | |
let ys = ["t","e","a","z","o","v","p"] | |
extension Array where Element: Comparable { | |
func selectionSort() -> [Element] { | |
guard self.count > 1 else {return self} | |
var result = self | |
for index in (0..<count - 1) { | |
var indexLowest = index |
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 Foundation | |
/// A list is either empty or it is composed of a first element (head) | |
/// and a tail, which is a list itself. | |
/// | |
/// See http://www.enekoalonso.com/projects/99-swift-problems/#linked-lists | |
class List<T> { | |
var value: T | |
var nextItem: List<T>? | |
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 Foundation | |
class LinkedList<T> { | |
class Node<T> { | |
var value: T | |
var next: Node? | |
init (value: T){ | |
self.value = 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
import Foundation | |
protocol DelegateProtocol: class { | |
} | |
protocol Delegatable { | |
associatedtype DelegateType: DelegateProtocol | |
var delegate: DelegateType? { get set } |
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 Collection where Element: Collection { | |
func transposed() -> [[Element.Element]]? { | |
guard let maxCount = self.map({$0.count}).max() else {return nil} | |
var result = [[Element.Element?]](repeating: [Element.Element?](repeating: nil, count: self.count), count: maxCount) | |
for (r,row) in self.enumerated() { | |
for (c,v) in row.enumerated() { | |
result[c][r] = v | |
} | |
} | |
return result |
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 UITableView { | |
func updateTableHeaderView(with view: UIView?) { | |
guard | |
let view = view | |
else { | |
tableHeaderView = nil | |
return | |
} | |
let containerView = UIView() | |
containerView.translatesAutoresizingMaskIntoConstraints = false |