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 | |
/// Defines the CacheService errors | |
/// | |
/// - encryptionFailed: the key encription has failed | |
/// - couldNotSaveData: the data could not be saved | |
/// - couldNotLoadData: the data could not be loaded | |
/// - raw: some system error, not previously defined | |
public enum CacheServiceError: Error { | |
case encryptionFailed |
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 Sequence { | |
func groupBy<G: Hashable>(closure: (Iterator.Element)->G) -> [G: [Iterator.Element]] { | |
var results = [G: Array<Iterator.Element>]() | |
forEach { | |
let key = closure($0) | |
if var array = results[key] { | |
array.append($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
import UIKit | |
/// An enum that defines an output to be passed on from | |
/// a child to it's parents over the responders Chain | |
public protocol CoordinatorOutput {} | |
/// An enum that defines an input to be passed on from | |
/// the parent to it's children | |
public protocol CoordinatorInput {} |
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
assign and copy properties | |
Property with ’retain (or strong)’ attribute must be of object type | |
so, declare a property as assign if it has a primitive value | |
@property (nonatomic, assign) int someNumber; | |
You also use assign for structs, because they aren’t objects either | |
@property (nonatomic, assign) CLLocationCoordinate2D coordinate; |
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
package com.interview.graph; | |
import java.util.HashSet; | |
import java.util.Set; | |
/** | |
* http://www.careercup.com/question?id=14942063 | |
*/ | |
public class Boggle { |
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 Node { | |
var val: String? | |
var parent: Node? | |
var children: [String: Node] = [:] |
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 Character { | |
var asciiValue: Int { | |
get { | |
let s = String(self).unicodeScalars | |
return Int(s[s.startIndex].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
// MARK: - Swizzling | |
extension UIFont { | |
class var defaultFontFamily: String { return "Georgia" } | |
override public class func initialize() | |
{ | |
if self == UIFont.self { | |
swizzleSystemFont() | |
} | |
} |
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
/* | |
Everyone on Stack Overflow does HTTP Basic Authentication on iOS by manually | |
building the HTTP headers. | |
This amounts to re-implementing HTTP. | |
Why? The Cocoa Touch URL Loading System aleady knows HTTP, and you can | |
configure your URLSession to supply HTTP Basic Authentication credentials | |
like so. |
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
// | |
// SRCopyableLabel.swift | |
// | |
// Created by Stephen Radford on 08/09/2015. | |
// Copyright (c) 2015 Cocoon Development Ltd. All rights reserved. | |
// | |
import UIKit | |
class SRCopyableLabel: UILabel { |