Skip to content

Instantly share code, notes, and snippets.

Andrey Isaev siberianisaev

Block or report user

Report or block siberianisaev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@siberianisaev
siberianisaev / html-table.swift
Last active Jan 14, 2016
Replace HTML table with spaces and new lines
View html-table.swift
extension UIFont {
func sizeOfString(string: NSString, constrainedToWidth width: Double) -> CGSize {
return string.boundingRectWithSize(CGSize(width: width, height: DBL_MAX), options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes: [NSFontAttributeName: self], context: nil).size
}
}
extension String {
@siberianisaev
siberianisaev / NSString+Email.swift
Created Dec 22, 2014
Email address validation (swift version)
View NSString+Email.swift
import Foundation
extension NSString {
/**
http://stackoverflow.com/questions/800123/what-are-best-practices-for-validating-email-addresses-in-objective-c-for-ios-2
RFC 2822 http://tools.ietf.org/html/rfc2822
*/
func isEmail() -> Bool {
let sRegex = "(?:[a-z0-9!#$%\\&'*+/=?\\^_`{|}~-]+(?:\\.[a-z0-9!#$%\\&'*+/=?\\^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"
@siberianisaev
siberianisaev / UINavigationBar+Height.swift
Last active Oct 17, 2018
Change height of UINavigationBar
View UINavigationBar+Height.swift
import Foundation
private var AssociatedObjectHandle: UInt8 = 0
extension UINavigationBar {
var height: CGFloat {
get {
if let h = objc_getAssociatedObject(self, &AssociatedObjectHandle) as? CGFloat {
View ExceptionHandler.h
#import <Foundation/Foundation.h>
@interface ExceptionHandler : NSObject
+ (void)startHandleExceptions;
@end
View NSString+URLEncoding.h
#import <Foundation/Foundation.h>
@interface NSString (URLEncoding)
- (NSString *)urlEncodedString;
- (NSString *)stringByDecodingURLFormat;
@end
@siberianisaev
siberianisaev / singleton
Created Feb 13, 2014
Singleton snippet for Xcode 5
View singleton
+ (<#Class name#> *)<#Singleton method#>
{
static <#Class name#> *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[<#Class name#> alloc] init];
});
return sharedInstance;
}
You can’t perform that action at this time.