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
| let weekday = ["", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] | |
| let dayOfWeek = (Sunday:1, Monday:2, Tuesday:3, Wednesday:4, Thursday:5, Friday:6, Saturday:7) | |
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
| // use this extension | |
| //https://gist.github.com/masters3d/b90a99aac6b923add0ee | |
| import Darwin | |
| var date0 = tm() | |
| var chars = asctime(&date0) | |
| var toReturnString = "" | |
| while chars.successor().memory != 0 { |
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 Darwin | |
| extension tm{ | |
| var year:Int32 { return tm_year + 1900 } | |
| var month:Int32 { return tm_mon + 1 } | |
| var day:Int32 { return tm_mday } | |
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
| private extension String { | |
| func trimWhiteSpace()-> String{ | |
| let removeSpaces = trimCharacters(" ", sourceText: self) | |
| if removeSpaces.hasSuffix("\n"){ | |
| return String(removeSpaces.characters.dropLast()) | |
| } | |
| return removeSpaces | |
| } |
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
| func splitStringToArray(inString:String) -> [String]{ | |
| return inString.characters.split(isSeparator: { splitAt($0) }).map{String($0)} | |
| } | |
| func splitAt(characterToCompare:Character, charToSplitAt:String = " !&$%^&,:")-> Bool{ | |
| for each in charToSplitAt.characters{ | |
| if each == characterToCompare{ | |
| return true | |
| } |
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
| func splitAtCamelCase(inString: String, var result:[String] = []) -> [String] { | |
| var previousLetter:String = "" | |
| var lastSplitIndex = 0 | |
| if !inString.isEmpty { previousLetter = inString.characters.first.map{String($0)} ?? "" } | |
| for (index, currentLetter) in inString.characters.map({String($0)}).enumerate(){ | |
| if previousLetter.isLowercase && currentLetter.isUppercase{ | |
| let rangeWord = Range<Int>(start: lastSplitIndex, end: index) | |
| result.append(inString.substringWithRangeInt(rangeWord)) | |
| lastSplitIndex = index | |
| } |
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
| func presentCameraFromFirstViewController(sender: AnyObject){ | |
| let storyboard = UIStoryboard(name: "Main", bundle: nil) | |
| let vc = storyboard?.instantiateViewControllerWithIdentifier("MasterNavigation") as! UINavigationController | |
| let vc1 = (storyboard?.instantiateViewControllerWithIdentifier("TabBarViewController") as! UITabBarController).viewControllers | |
| let vc2 = vc1?.first as! UINavigationController | |
| presentViewController(vc, animated: true, completion: nil) | |
| } |
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
| struct HelloWorld{ | |
| static func hello( _ input:String = "World") -> String{ | |
| return "Hello, \(input)!" | |
| } | |
| } |
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
| wget -P /Users/temp -mpck --user-agent="" -e robots=off --wait 1 -E --no-check-certificate https://cs.byu.edu/colloquia_files/2006Fall/presentations/Matz_slides/index.html | |
| //where /Users/temp is the destination folder |
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
| //http://www.raywenderlich.com/86205/nsregularexpression-swift-tutorial | |
| func highlightMatches(pattern: String, inString string: String) -> NSAttributedString { | |
| let regex = NSRegularExpression(pattern: pattern, options: .allZeros, error: nil) | |
| let range = NSMakeRange(0, countElements(string)) | |
| let matches = regex?.matchesInString(string, options: .allZeros, range: range) as [NSTextCheckingResult] | |
| let attributedText = NSMutableAttributedString(string: string) | |
| for match in matches { |