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
// Copyright © 2019 Nicholas Peterson. All rights reserved. | |
// | |
import Foundation | |
protocol BlacklistInterface { | |
/* | |
* Creates a new list from an array of blacklisted words. | |
* Runs at worst in O(n * m) time where n is the length of the longest word and m is the total number of words. | |
*/ |
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
// Created by Nick Peterson on 8/7/19. | |
// Copyright © 2019 Nicholas Peterson. All rights reserved. | |
// | |
import Foundation | |
class Cache<T> { | |
class Node<T> { | |
var object: T? | |
let 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
- (NSString *)normalizedPhoneNumber { | |
NSString *normalString = self; | |
if (!self) return nil; | |
normalString = [normalString lowercaseString]; | |
NSCharacterSet *normalizationSet = [[NSCharacterSet characterSetWithCharactersInString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"] invertedSet]; | |
normalString = [[[normalString componentsSeparatedByCharactersInSet:normalizationSet] componentsJoinedByString:@""] uppercaseString]; | |
NSMutableString *phoneNumber = [[normalString mutableCopy] autorelease]; | |
char tmpChar; |
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
@interface UIColor (NPUIExtras) | |
/** | |
Generates a color with random values. (not guarenteed to be truely random) | |
*/ | |
+ (UIColor *)randomColor; | |
/** | |
Used to construct a color using values from 0 - 255 rather then 0 - 1. | |
*/ |
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
// Use NS_OPTIONS for some compiler sugar. | |
// | |
// Use a type that fits your struct but consider using | |
// types directly to avoid 32/64bit width inconsistencies. | |
typedef NS_OPTIONS(UInt16, MaskType) { | |
MaskTypeOptionNone = 0, | |
MaskTypeOptionOne = 1 << 0, | |
MaskTypeOptionTwo = 1 << 1, | |
}; |
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
// Requires SBJSON, Uses my own percent escapeing, But cocoas will do for this task. | |
// All methods return nil on errors. | |
@interface NSURL (Bitly) | |
// Easy NSURL | |
+ (NSURL *) shortUrlWithString:(NSString *)string; | |
// Easy URL String | |
+ (NSString *)shortAbsoluteURLStringWithString:(NSString *)string; | |
// Returns full bitly response |