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 where Element: Equatable { | |
| func distinctUntilChanged() -> Self { | |
| var resultArray = Self() | |
| for element in self { | |
| if resultArray.last != element { | |
| resultArray.append(element) | |
| } | |
| } | |
| return resultArray | |
| } |
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 Optional where Wrapped == String { | |
| var isEmptyOrNil: Bool { | |
| return self?.isEmpty != false | |
| } | |
| var isNotEmptyNorNil: Bool { | |
| return !isEmptyOrNil | |
| } | |
| } |
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
| JEKYLL_ENV=production bundle exec jekyll build | |
| firebase deploy |
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
| #!/bin/sh | |
| echo $1 | python3 -c "import sys; from urllib.parse import unquote; print(unquote(sys.stdin.read()));" |
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 UIKit | |
| extension UIViewController { | |
| /// Creates an instance of `ViewControllerType` defined in a storyboard. | |
| /// | |
| /// The setup for this method to work is the following: | |
| /// 1. The storyboard needs to have a single view controller of the type `ViewControllerType` | |
| /// 2. This view controller needs to be set as the initial view controller | |
| /// 3. The name of the view controller needs to match the name of the storyboard and end with "ViewController". | |
| /// e.g. Some.storyboard and SomeViewController |
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
| typealias AlertActionStyle = UIAlertAction.Style | |
| extension UIAlertController { | |
| static func create( | |
| style: UIAlertController.Style, | |
| title: String?, | |
| message: String?, | |
| actions: [AlertAction] = [], | |
| onDismiss: VoidHandler? = nil | |
| ) -> UIAlertController { |
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 FileManager { | |
| func isDirectory(at url: URL) -> Bool { | |
| var isDirectory: ObjCBool = false | |
| guard FileManager.default.fileExists(atPath: url.path, isDirectory: &isDirectory) else { | |
| return false | |
| } | |
| return isDirectory.boolValue | |
| } | |
| } |
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
| /// Inspired by | |
| /// http://blog.benjamin-encz.de/post/main-queue-vs-main-thread/ | |
| /// and https://stackoverflow.com/a/60348601 | |
| /// Associates a predefined key/value pair with the main queue and later uses the presence of it | |
| /// to determine whether the current queue is the main queue. | |
| extension DispatchQueue { | |
| private static let mainQueueCheckKey: DispatchSpecificKey<String> = { | |
| let mainQueueCheckKey = DispatchSpecificKey<String>() | |
| DispatchQueue.main.setSpecific(key: mainQueueCheckKey, value: mainQueueCheckValue) | |
| return mainQueueCheckKey |
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 UIView { | |
| static func withoutConstraints() -> Self { | |
| let instance = self.init() | |
| instance.translatesAutoresizingMaskIntoConstraints = false | |
| return instance | |
| } | |
| func addSubviews(_ views: UIView...) { | |
| for view in views { | |
| addSubview(view) |
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
| autoload -U colors && colors | |
| ## rbenv | |
| eval "$(rbenv init - zsh)" | |
| ## git | |
| autoload -Uz vcs_info | |
| zstyle ':vcs_info:*' enable git svn | |
| zstyle ':vcs_info:git*' formats "%r/%S%{$fg[grey]%} %{$fg[blue]%}%b%{$reset_color%} (%a) %m%u%c%{$reset_color%} " | |
| precmd() { |