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
// | |
// UKPostcodeValidator.swift | |
// Medio | |
// | |
// Created by Daniel Tavares on 20/03/2016. | |
// Copyright © 2016 Daniel Tavares. All rights reserved. | |
// References: http://stackoverflow.com/questions/164979/uk-postcode-regex-comprehensive | |
// References: http://benscheirman.com/2014/06/regex-in-swift/ | |
// Usage: UKPostcodeValidator.validate("W1D 5LH") | |
// |
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 | |
# ------- | |
# Usage sh unusedImages.sh (jpg|png|gif) | |
# ------- | |
# Caveat | |
# 1 - | |
# NSString *imageName = [NSString stringWithFormat:@"image_%d.png", 1]; | |
# This script would incorrectly list these images as unreferenced. For example, you might have | |
# This script will incorrectly think image_1.png is unreferenced. | |
# 2 - If you have a method, or variable with the same name as the image it won't pick it up |
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
CGFloat height = 100.f; | |
UIBezierPath *straightPath = [UIBezierPath bezierPath]; | |
[straightPath moveToPoint:CGPointMake(0, 0)]; | |
[straightPath addCurveToPoint:CGPointMake(0, height) controlPoint1:CGPointMake(0, height * 0.5) controlPoint2:CGPointMake(0, height * 0.5)]; | |
UIBezierPath *bendiPath = [UIBezierPath bezierPath]; | |
[bendiPath moveToPoint:CGPointMake(0, 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
+(CAGradientLayer *)layerFromArray:(NSArray *)gradientsArray | |
{ | |
//create gradient from gradient | |
NSMutableArray *arrayOfColors = [NSMutableArray arrayWithCapacity:10]; | |
NSMutableArray *arrayOfPositions = [NSMutableArray arrayWithCapacity:10]; | |
for (NSString *string in gradientsArray) | |
{ | |
NSArray *arr = [string componentsSeparatedByString:@","]; | |
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
var userPreferences: [String]? = [""] | |
/// Type safe method to check if collection is nil and if not if it has values | |
func nilOrEmptyCollection<Collection where Collection: CollectionType>(collection: Collection?) -> Bool { | |
guard let collection = collection else { return true } | |
return collection.isEmpty | |
} | |
/// Extension on Options with constraint to collection type | |
extension Optional where Wrapped: CollectionType { |
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 UIStoryboardSegue { | |
/* | |
Generic way of loading destinationViewController | |
Usage: | |
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | |
if let controller = segue.destinationController("SegueName", type: CustomController.self) { | |
print(controller) | |
} | |
} | |
*/ |
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
// | |
// UILabel+Paragraph.swift | |
// | |
// Created by Daniel Tavares on 09/02/2016. | |
// Copyright © 2016 Daniel Tavares. All rights reserved. | |
// | |
import Foundation | |
//MARK: - Associated Value Struct |
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
// Do any additional setup after loading the view. | |
[[CBTimer instance] startTimerWithMaxTime:5 mode:CBTimerModeDecrease timerDoneBlock:^ (CFTimeInterval elapsed, BOOL isFinished) | |
{ | |
self.counterLabel.text = [NSString stringWithFormat:@"%.3f",elapsed]; | |
if (isFinished) | |
{ | |
UIAlertView *finished =[[UIAlertView alloc] initWithTitle:@"Finished" message:@"Finito" delegate:nil cancelButtonTitle:@"OKAY" otherButtonTitles:nil]; | |
[finished show]; | |
} |
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
# recursively delete original files after a git merge failure | |
find . -name *.orig -delete |
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
// | |
// NSArray_NSArrayUtils.h | |
// GCDAndBlocks | |
// | |
// Created by Daniel Hollis on 21/02/2012. | |
// Copyright (c) 2012 Mobile Interactive Group. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |