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
protocol DictionaryConvertible: Codable { | |
func convertToDictionary() -> [String: Any] | |
} | |
extension DictionaryConvertible { | |
func convertToDictionary() -> [String: Any] { | |
let jsonEncoder = JSONEncoder() | |
let jsonData = try! jsonEncoder.encode(self) | |
do { | |
return try (JSONSerialization.jsonObject(with: jsonData, options: []) as? [String: Any])! |
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
protocol JSONConvertible: Codable { | |
func convertToJson() -> String | |
} | |
extension JSONConvertible { | |
func convertToJson() -> String { | |
let jsonEncoder = JSONEncoder() | |
let jsonData = try! jsonEncoder.encode(self) | |
let json = String(data: jsonData, encoding: String.Encoding.utf8) |
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 Date { | |
var currentUTCTimeZoneDate: String { | |
let calendar = Calendar.current | |
let timeZone = calendar.timeZone.identifier | |
let formatter = DateFormatter() | |
formatter.timeZone = TimeZone(identifier: timeZone) | |
formatter.amSymbol = "AM" | |
formatter.pmSymbol = "PM" | |
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ" | |
print(formatter) |
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
#!/usr/bin/env bash | |
# GIT FUNCTIONS | |
git_branch() { | |
git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
# TERMINAL PROMPT | |
PS1="\[\e[1;91m\]\u\[\e[m\]" # username |