This file contains hidden or 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
import Cocoa | |
let folderPath = "/Users/admin/Downloads/1-30" | |
let newPath = "/Users/admin/tmp/" | |
let fileManager = NSFileManager.defaultManager() | |
let enumerator:NSDirectoryEnumerator = fileManager.enumeratorAtPath(folderPath)! | |
while let element = enumerator.nextObject() as? String { | |
if element.hasSuffix("dg.mp3") { |
This file contains hidden or 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
enum Rank: Int { | |
case Ace = 1 | |
case Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten | |
case Jack, Queen, King | |
func simpleDescription() -> String { | |
switch self { | |
case .Ace: | |
return "ace" | |
case .Jack: | |
return "jack" |
This file contains hidden or 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
//emailValidation | |
-(BOOL) NSStringIsValidEmail:(NSString *)checkString | |
{ | |
BOOL stricterFilter = YES; // Discussion http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/ | |
NSString *stricterFilterString = @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}"; | |
NSString *laxString = @".+@([A-Za-z0-9]+\\.)+[A-Za-z]{2}[A-Za-z]*"; | |
NSString *emailRegex = stricterFilter ? stricterFilterString : laxString; | |
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; |
This file contains hidden or 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
// textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; | |
- (BOOL)doesStringContainDecimal:(NSString*) string | |
{ | |
NSString *searchForDecimal = @"."; | |
NSRange range = [string rangeOfString:searchForDecimal]; | |
//If we find a decimal return YES. Otherwise, NO |
This file contains hidden or 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
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
UITextView *textView = [[UITextView alloc] init]; | |
textView.translatesAutoresizingMaskIntoConstraints = NO; | |
[self.view addSubview:textView]; | |
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[textView]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(textView)]]; | |
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[textView]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(textView)]]; | |
NSString *htmlString = @"<h1>Header</h1><h2>Subheader</h2><p>Some <em>text</em></p><img src='http://blogs.babble.com/famecrawler/files/2010/11/mickey_mouse-1097.jpg' width=70 height=100 />"; |
This file contains hidden or 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
# Xcode | |
# | |
build/ | |
*.pbxuser | |
!default.pbxuser | |
*.mode1v3 | |
!default.mode1v3 | |
*.mode2v3 | |
!default.mode2v3 | |
*.perspectivev3 |
This file contains hidden or 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
CGRect viewRect = [[UIScreen mainScreen] bounds]; | |
self.window = [[UIWindow alloc] initWithFrame:viewRect]; | |
UIViewController *viewController = [[UIViewController alloc] init]; | |
UIView *colorView = [[UIView alloc] initWithFrame:viewRect]; | |
colorView.backgroundColor = [UIColor darkGrayColor]; | |
viewController.view = colorView; | |
self.window.rootViewController = viewController; |
This file contains hidden or 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
#coding:utf-8 | |
import unittest | |
def myadd(a,b): | |
return a+b | |
class test(unittest.TestCase): | |
def setUp(self): | |
print "start ", | |
def tearDown(self): | |
print " end" |