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
#if canImport(SwiftUI) && DEBUG | |
import SwiftUI | |
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable { | |
func updateUIViewController(_ uiViewController: ViewController, context: Context) { | |
} | |
let viewController: ViewController | |
init(_ builder: @escaping () -> 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
format = """ | |
$username\ | |
$hostname\ | |
$directory\ | |
$git_branch\ | |
$git_state\ | |
$git_status\ | |
$git_metrics\ | |
$fill\ | |
$nodejs\ |
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
export ZSH="$HOME/.oh-my-zsh" | |
ZSH_THEME="" | |
plugins=( | |
git | |
zsh-syntax-highlighting | |
zsh-autosuggestions | |
pod | |
) |
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
extension Array { | |
mutating func removeFirst(where shouldBeRemoved: ((Element) -> Bool)) -> Element? { | |
for (index, element) in self.enumerated() { | |
let shouldBeRemoved: Bool = shouldBeRemoved(element) | |
if shouldBeRemoved == true { | |
return self.remove(at: 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
extension URLRequest { | |
/** | |
Configures the URL request for `multipart/form-data`. The request's `httpBody` is set, and a value is set for the HTTP header field `Content-Type`. | |
- Parameter parameters: The form data to set. | |
- Parameter encoding: The encoding to use for the keys and values. | |
- Throws: `MultipartFormDataEncodingError` if any keys or values in `parameters` are not entirely in `encoding`. | |
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
extension UIImage { | |
class func with(fileNamed: String, | |
withExtension fileExtension: String = ".png") -> UIImage { | |
guard let url = Bundle.main.url(forResource: fileNamed, withExtension: fileExtension) else { return UIImage() } | |
guard let data = try? Data(contentsOf: url) else { return UIImage() } | |
return UIImage(data: data) ?? UIImage() | |
} | |
} |
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
extension Date { | |
static var appInstallDate: Date { | |
let urlToDocumentsFolder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last! | |
let installDate = (try! FileManager.default.attributesOfItem(atPath: urlToDocumentsFolder.path)[FileAttributeKey.creationDate]) as! Date | |
return installDate | |
} | |
} |
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
extension TimeInterval { | |
static var second: TimeInterval { | |
return 1.0 | |
} | |
static var minute: TimeInterval { | |
return second * 60.0 | |
} | |
static var hour: TimeInterval { |
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
extension UIColor { | |
var redValue: CGFloat{ return CIColor(color: self).red } | |
var greenValue: CGFloat{ return CIColor(color: self).green } | |
var blueValue: CGFloat{ return CIColor(color: self).blue } | |
var alphaValue: CGFloat{ return CIColor(color: self).alpha } | |
convenience init(r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat = 1) { | |
self.init(red: r / 255, green: g / 255, blue: b / 255, alpha: a) | |
} | |
} |
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
extension String { | |
var isBlank: Bool { | |
return self.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty | |
} | |
func replace(string:String, replacement:String) -> String { | |
return self.replacingOccurrences(of: string, with: replacement, options: NSString.CompareOptions.literal, range: nil) | |
} | |
func removeWhitespace() -> String { | |
return self.replace(string: " ", replacement: "") |
NewerOlder