Skip to content

Instantly share code, notes, and snippets.

View rubenroques's full-sized avatar

Ruben Roques rubenroques

  • Portugal
View GitHub Profile
class LiveView: UIView {
var startButton : UIButton
var resetButton : UIButton
var circle1 : UIView
var circle2 : UIView
var circle3 : UIView
@rubenroques
rubenroques / Aircrack Commands
Created December 18, 2015 10:37 — forked from victorreyesh/Aircrack Commands
Cracking WPA2 / WEP Wifi / Aircrack 10 seconds guide. For Mac OSX
//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]
+ (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;
@rubenroques
rubenroques / gist:0395c4ea97388b2c99d4
Created July 15, 2015 17:22
Action -> Dispatcher -> Store -> View
typealias Route = String
protocol Action {
func route() -> Route
}
protocol Store {
typealias ActionType = Action
func performAction(_: ActionType)
}
//: 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:
@rubenroques
rubenroques / gist:48f8bbba05bf7a01879c
Last active August 29, 2015 14:14 — forked from anonymous/gist:2ef9e04f237b889459ce
UIView extention - Fallback Constraints
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
@rubenroques
rubenroques / gist:5c201cd571cd5913f688
Last active August 29, 2015 14:14
Playground - Testing NSLayoutConstraints
// 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)
@rubenroques
rubenroques / FuzzySearch.swift
Last active April 29, 2018 16:03
Fuzzy String Search in Swift
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
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)])
{
[[UIDevice currentDevice] performSelector:@selector(setOrientation:) withObject:(id)UIInterfaceOrientationPortrait];
}
}