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
| public extension UserDefaults { | |
| var overridedUserInterfaceStyle: UIUserInterfaceStyle { | |
| get { | |
| UIUserInterfaceStyle(rawValue: integer(forKey: #function)) ?? .unspecified | |
| } | |
| set { | |
| set(newValue.rawValue, forKey: #function) | |
| } | |
| } |
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
| class ResumableTimer: NSObject { | |
| private var timer: Timer? = Timer() | |
| private var callback: () -> Void | |
| private var startTime: TimeInterval? | |
| private var elapsedTime: TimeInterval? | |
| // MARK: Init |
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 { | |
| func foregroundColor(_ color: UIColor) -> NSAttributedString { | |
| NSAttributedString(string: self, attributes: [.foregroundColor : color]) | |
| } | |
| func background(_ color: UIColor) -> NSAttributedString { | |
| NSAttributedString(string: self, attributes: [.backgroundColor: color]) | |
| } | |
| func underline(_ color: UIColor, style: NSUnderlineStyle = .single) -> NSAttributedString { | |
| NSAttributedString(string: self, attributes: [.underlineColor: color, .underlineStyle: style.rawValue]) | |
| } |
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 MyLoginViewController: ASAuthorizationControllerPresentationContextProviding { | |
| func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { | |
| return self.view.window! | |
| } | |
| } |
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
| // ==UserScript== | |
| // @name always_mobile_wikipedia | |
| // @namespace https://gist.github.com/leakypixel | |
| // @description Redirect desktop Wikipedia to mobile | |
| // @author leakypixel | |
| // @include http://*.wikipedia.org/* | |
| // @include https://*.wikipedia.org/* | |
| // @version 0.2 | |
| // @grant none | |
| // ==/UserScript== |
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 gradient = CAGradientLayer() | |
| gradient.frame = tableView.superview?.bounds ?? CGRectNull | |
| gradient.colors = [UIColor.clearColor().CGColor, UIColor.clearColor().CGColor, UIColor.blackColor().CGColor, UIColor.blackColor().CGColor, UIColor.clearColor().CGColor, UIColor.clearColor().CGColor] | |
| gradient.locations = [0.0, 0.15, 0.25, 0.75, 0.85, 1.0] | |
| tableView.superview?.layer.mask = gradient | |
| tableView.backgroundColor = UIColor.clearColor() |