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 NSCoder { | |
// works but not optimal | |
func encodeProtocol<T: SequenceType>(objv: T, forKey key: String) { | |
let aCollection = objv.map { $0 as! AnyObject } | |
self.encodeObject(aCollection, forKey: key) | |
} | |
// want: func encodeObject<T: SqeuenceType where T.Element is AnyProtocol>(objv: T, forKey key: String) { ... } | |
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 MyViewController : UIViewController { | |
func refactorThis() { | |
if let navigationController = navigationController, | |
let topViewController = navigatonController.topViewController, | |
let someProperty = topViewController.someproperty { | |
someProperty = "new 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
@objc public protocol ResponseObjectSerializable { | |
init(response: NSHTTPURLResponse, representation: AnyObject) | |
} | |
extension Alamofire.Request { | |
public func responseObject<T:ResponseObjectSerializable>(completionHandler: (NSURLRequest, NSHTTPURLResponse?, T?, NSError?) -> Void) -> Self { | |
let serializer: Serializer = { | |
(request, response, data) in | |
let JSONSerializer = Request.JSONResponseSerializer(options: .AllowFragments) |
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 Alamofire.Request { | |
class func imageResponseSerializer() -> Serializer { | |
return { request, response, data in | |
if data == nil { | |
return (nil, nil) | |
} | |
let image = UIImage(data: data!, scale: UIScreen.mainScreen().scale) | |
return (image, nil) |
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 myArray = [1, 2, 3, 4, 5] | |
let longMap = myArray.map({ (number) in | |
return number * 10 | |
}) | |
let convienceMap = myArray.map { number in | |
return number * 10 | |
} | |
let shortMap = myArray.map { $0 * 10 } |
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
if [ -d `brew --prefix`/etc/bash_completion.d ]; then | |
COMPLETIONS=`brew --prefix`/etc/bash_completion.d/* | |
for COMPLETION in $COMPLETIONS | |
do | |
source $COMPLETION | |
done | |
fi |
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 TheOneAndOnlyKraken { | |
static let sharedInstance = TheOneAndOnlyKraken() | |
} |
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 Dictionary { | |
mutating func unionInPlace(dictionary: Dictionary<Key, Value>) { | |
for (key, value) in dictionary { | |
self[key] = value | |
} | |
} | |
mutating func unionInPlace<S: SequenceType where S.Generator.Element == (Key, Value)>(sequence: S) { | |
for (key, value) in sequence { | |
self[key] = 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
require File.expand_path("../../Abstract/abstract-php-extension", __FILE__) | |
class Php54Uopz < AbstractPhp54Extension | |
init | |
homepage 'http://php.net/manual/en/book.uopz.php' | |
url 'https://github.com/krakjoe/uopz/archive/v2.0.7.tar.gz' | |
sha1 '9b49b52954046d7d4b3d41a8ca8f44f724795f8a' | |
head 'https://github.com/krakjoe/uopz.git' | |
version '2.0.7' |
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
#!/bin/sh | |
GIT=`which git` | |
GIT_DIRS=`find vendor -name .git -type d` | |
for GIT_DIR in $GIT_DIRS; do | |
if [ -d "${GIT_DIR}" ]; then | |
WORK_TREE=`dirname ${GIT_DIR}` | |
${GIT} --git-dir=${GIT_DIR} --work-tree=${WORK_TREE} clean -f | |
fi | |
done |