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 Eddie Espinal on 1/29/18. | |
import Foundation | |
enum Code2Icon: String { | |
case code0, code1, code2 | |
case code3, code4, code37, code38, code39, code40, code47 | |
case code5, code6, code7, code35 | |
case code8, code10, code17, code18 | |
case code9 | |
case code11, code12 |
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 Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
//This is the swift version of the following gist by @shexbeer https://gist.github.com/shexbeer/cb069d36ca8ec5edb515 | |
func cropCameraImage(original: UIImage, previewLayer: AVCaptureVideoPreviewLayer) -> UIImage? { | |
var image = UIImage() | |
let previewImageLayerBounds = previewLayer.bounds | |
let originalWidth = original.size.width | |
let originalHeight = original.size.height | |
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
let searchString = "this" | |
let baseString = "This is some string that contains the word \"this\" more than once. This substring has multiple cases. ThisthisThIs." | |
let attributed = NSMutableAttributedString(string: baseString) | |
var error: NSError? | |
let regex = NSRegularExpression(pattern: searchString, options: .CaseInsensitive, error: &error) | |
if let regexError = error { | |
println("Oh no! \(regexError)") |
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
// | |
// ELLowBitrateManager.swift | |
// | |
// | |
// Created by Eddie Espinal on 11/11/15. | |
// Copyright © 2015 EspinalLab, LLC. All rights reserved. | |
// | |
import UIKit |
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 this function below to check whether file exists at specified url** | |
+(void)checkWhetherFileExistsIn:(NSURL *)fileUrl Completion:(void (^)(BOOL success, NSString *fileSize ))completion | |
{ | |
//MAKING A HEAD REQUEST | |
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:fileUrl]; | |
request.HTTPMethod = @"HEAD"; | |
request.timeoutInterval = 3; | |
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) |
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
- (NSDictionary *)parseQueryString:(NSString *)query { | |
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:6]; | |
NSArray *pairs = [query componentsSeparatedByString:@"&"]; | |
for (NSString *pair in pairs) { | |
NSArray *elements = [pair componentsSeparatedByString:@"="]; | |
NSString *key = [[elements objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
NSString *val = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
[dict setObject:val forKey:key]; | |
} |
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
#pragma mark - DATE CONVERSION: | |
// These functions are not thread-safe, nor are the NSDateFormatter instances they return. | |
// Make sure that this function and the formatter are called on only one thread at a time. | |
static NSDateFormatter* getISO8601Formatter() { | |
static NSDateFormatter* sFormatter; | |
if (!sFormatter) { | |
// Thanks to DenNukem's answer in http://stackoverflow.com/questions/399527/ | |
sFormatter = [[NSDateFormatter alloc] init]; |
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 *)season | |
{ | |
// Months 12, 01, 02 | |
NSString *currentSeason = @"Winter"; | |
NSDate *date = [[self alloc] init]; | |
NSUInteger month = [date month]; | |
if (month >=3 && month <= 5) { | |
currentSeason = @"Spring"; |
NewerOlder