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
extension String { | |
func getDecimalDigits(includeDecimal: Bool = true) -> String { | |
let set = includeDecimal ? "1234567890.": "1234567890" | |
return self.components(separatedBy: CharacterSet(charactersIn: set).inverted).joined() | |
} | |
func lettersOnly() -> String { | |
let characterSet = CharacterSet(charactersIn: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").inverted |
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
struct Device { | |
/// Detects if the current architecture is a Simulator | |
static let isSimulator: Bool = { | |
var isSim = false | |
#if arch(i386) || arch(x86_64) | |
isSim = true | |
#endif | |
return isSim | |
}() |
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
import Foundation | |
/// General doc comment | |
struct SomeClass { | |
private static var count: Int = 0 | |
let aString: String | |
// MARK: - Initializers | |
init(aString: 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
static boolean isBetween(String start, String end) { | |
def sdf = new SimpleDateFormat("HH:mm") | |
def startCalendar = Calendar.getInstance() | |
startCalendar.setTime(sdf.parse(start)) | |
def endCalendar = Calendar.getInstance() | |
endCalendar.setTime(sdf.parse(end)) | |
def currentCalendar = Calendar.getInstance() |
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
//Simple Type - Person | |
struct Person: Codable { | |
let name: String | |
let age: Int | |
func getString() -> String { | |
return "Name: \(name), Age: \(age)" | |
} | |
} |
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
import UIKit | |
//Abbreviated OpenAPI product response for example purposes | |
let jsonData = """ | |
{ | |
"paging": { | |
"total": 8, | |
"offset": 0, | |
"limit": 40, | |
"returned": 8 |
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
read SIMVERSION <<< $(xcrun simctl list | awk '/^iOS[[:space:]][0-9\.]+/ { print $2 }') | |
#echo $SIMVERSION | |
#Output: 10.3 |
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
find "{directory}" -name "{filename}" -print0 | xargs -0 "{command}" | |
# Example find "./" -name "*.txt" -print0 | xargs -0 echo |
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
import compileall | |
import os | |
import sys | |
# Get path of this file's directory | |
directory = os.path.dirname(os.path.realpath(__file__)) | |
# Check that files are compileable | |
success = compileall.compile_dir(dir=directory, maxlevels=20, force=True) |