This file contains hidden or 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
// | |
// ViewPlace.swift | |
// | |
import UIKit | |
extension UIView { | |
/** | |
Add `self` and `otherView` to a new view and align them along the provided `edge`. | |
- Returns: A new view that is now the superview of `self` and `otherView` |
This file contains hidden or 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 UIGestureRecognizer { | |
private class TargetAndSelector: NSObject { | |
let closure: UIGestureRecognizer -> Void | |
let recognizer: UIGestureRecognizer | |
init(recognizer: UIGestureRecognizer, closure: UIGestureRecognizer -> Void) { | |
self.recognizer = recognizer | |
self.closure = closure | |
} |
This file contains hidden or 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 where Key: StringLiteralConvertible, Value:AnyObject { | |
subscript(keysAndIndexes: AnyObject ...) -> AnyObject? { | |
guard let jsonObject = self as? AnyObject else { fatalError("\(self) is not a json dictionary") } | |
return _extractValueFrom(keysAndIndexes, from: jsonObject) | |
} | |
} | |
extension Array where Element:AnyObject { | |
subscript(keysAndIndexes: AnyObject ...) -> AnyObject? { | |
return _extractValueFrom(keysAndIndexes, from: self) |
This file contains hidden or 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
NS_INLINE NSException * _Nullable tryBlock(void(^_Nonnull tryBlock)(void)) { | |
@try { | |
tryBlock(); | |
} | |
@catch (NSException *exception) { | |
return exception; | |
} | |
return nil; | |
} |
This file contains hidden or 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 DictionaryOfInstanceVariables(container:AnyObject, objects: String ...) -> [String:AnyObject] { | |
var views = [String:AnyObject]() | |
for objectName in objects { | |
guard let object = object_getIvar(container, class_getInstanceVariable(container.dynamicType, objectName)) else { | |
assertionFailure("\(objectName) is not an ivar of: \(container)"); | |
continue | |
} | |
views[objectName] = object | |
} | |
return views |
This file contains hidden or 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 generatorForTuple(tuple: Any) -> AnyGenerator<Any> { | |
return anyGenerator(Mirror(reflecting: tuple).children.lazy.map { $0.value }.generate()) | |
} | |
let someTuple = ("1", 2, ["3"]) | |
for value in generatorForTuple(someTuple) { | |
print(value) | |
} |
This file contains hidden or 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
// | |
// SwiftRequests.swift | |
// | |
import Foundation | |
@objc class SwiftRequests : NSObject { | |
enum SwiftRequestsError { | |
case InvalidURL |
This file contains hidden or 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
-(NSArray *)allInstanceVariablesForClass:(Class)klass { | |
NSMutableArray *iVarList = [NSMutableArray array]; | |
unsigned int count; | |
Ivar* ivars=class_copyIvarList(klass, &count); | |
for(int i=0; i < count; i++) { | |
Ivar ivar= ivars[i]; | |
This file contains hidden or 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
#!/usr/bin/python2.4 | |
import string | |
from string import rstrip | |
import subprocess | |
from subprocess import Popen, PIPE, call | |
from time import time | |
import os | |
# copy a folder to a remote folder |