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
//Install Macports. | |
//Install aircrack-ng: | |
sudo port install aircrack-ng | |
//Install the latest Xcode, with the Command Line Tools. | |
//Create the following symlink: | |
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport | |
//Figure out which channel you need to sniff: | |
sudo airport -s | |
sudo airport en1 sniff [CHANNEL] |
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
+ (NSString *)fixMalformedJSONString:(NSString *)originalString { | |
//Clean response body | |
originalString = [originalString stringByReplacingOccurrencesOfString:@"\\\"" withString:@"\""]; | |
originalString = [originalString stringByReplacingOccurrencesOfString:@"\"{" withString:@"{"]; | |
originalString = [originalString stringByReplacingOccurrencesOfString:@"}\"" withString:@"}"]; | |
originalString = [originalString stringByReplacingOccurrencesOfString:@"\"[" withString:@"["]; | |
originalString = [originalString stringByReplacingOccurrencesOfString:@"]\"" withString:@"]"]; | |
return originalString; |
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
typealias Route = String | |
protocol Action { | |
func route() -> Route | |
} | |
protocol Store { | |
typealias ActionType = Action | |
func performAction(_: ActionType) | |
} |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
func generateRandom()-> Int | |
{ | |
let randomNumber :Int = Int(arc4random_uniform(20)) | |
switch randomNumber | |
{ | |
case 1,2,3,4,8,11,13,14,18: |
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
view.addFallbackConstraints(item: labelB, attribute: .Top, relatedBy: .Equal, fallbackArrayItems:[topImageView], attribute: .Bottom, multiplier: 1, constant: 20, startPriority:110) | |
view.addFallbackConstraints(item: labelC, attribute: .Top, relatedBy: .Equal, fallbackArrayItems:[labelA,topImageView], attribute: .Bottom, multiplier: 1, constant: 20, startPriority:105) | |
view.addFallbackConstraints(item: labelD, attribute: .Top, relatedBy: .Equal, fallbackArrayItems:[labelB,labelA,topImageView], attribute: .Bottom, multiplier: 1, constant: 20, startPriority:100) | |
extension UIView { | |
func addFallbackConstraints(item view1: AnyObject, attribute attr1: NSLayoutAttribute, relatedBy relation: NSLayoutRelation, fallbackArrayItems: [AnyObject], attribute attr2: NSLayoutAttribute, multiplier: CGFloat = 1, constant c: CGFloat, startPriority: UILayoutPriority) -> UILayoutPriority { | |
var priorityDecrementer = startPriority |
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
// Playground - noun: a place where people can play | |
import UIKit | |
var base = UIView() | |
base.frame = CGRectMake(0, 0, 400, 500) | |
base.backgroundColor = UIColor.lightGrayColor() | |
var topImageView = UIImageView() | |
topImageView.setTranslatesAutoresizingMaskIntoConstraints(false) |
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
func fuzzySearch(var originalString: String, var stringToSearch: String, caseSensitive: Bool = false)->Bool { | |
if countElements(originalString)==0 || countElements(stringToSearch)==0 { | |
return false | |
} | |
if countElements(originalString) < countElements(stringToSearch) { | |
return false | |
} |
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
-(void)viewWillAppear:(BOOL)animated | |
{ | |
[super viewWillAppear:animated]; | |
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) | |
{ | |
[[UIDevice currentDevice] performSelector:@selector(setOrientation:) withObject:(id)UIInterfaceOrientationPortrait]; | |
} | |
} |