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 Foundation | |
| import Combine | |
| enum APIError: Error, LocalizedError { | |
| case unknown, apiError(reason: String) | |
| var errorDescription: String? { | |
| switch self { | |
| case .unknown: | |
| return "Unknown error" |
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 { | |
| /// Using regular expressions is not a correct approach for converting HTML to text, there are many pitfalls, like handling <style> and <script> tags. On platforms that support Foundation, one alternative is to use NSAttributedString's basic HTML support. Care must be taken to handle extraneous newlines and object replacement characters left over from the conversion process. It is a good idea to cache complex generated NSAttributedStrings either through storage or NSCache. | |
| func strippingHTML() throws -> String? { | |
| if isEmpty { | |
| return nil | |
| } | |
| if let data = data(using: .utf8) { | |
| let attributedString = try NSAttributedString(data: data, | |
| options: [.documentType : NSAttributedString.DocumentType.html, |
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
| # Updated for SwiftLint 0.29.2 | |
| # See all rules: https://github.com/realm/SwiftLint/blob/master/Rules.md | |
| opt_in_rules: | |
| # Opt-in (Default Disabled) | |
| - anyobject_protocol | |
| - array_init | |
| - attributes | |
| - closure_body_length | |
| - closure_spacing |
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 XCTest | |
| class NotificationTestCase: XCTestCase { | |
| func testTriggerNotification() { | |
| expectation(forNotification: .fooBar, | |
| object: nil, | |
| handler: nil) | |
| let notificationCenter = NotificationCenter.default |
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 Foundation | |
| import Gridicons | |
| import UIKit | |
| import WebKit | |
| class WebViewController: UIViewController { | |
| let webView = WKWebView() | |
| let progressView = WebProgressView() | |
| let toolbar = UIToolbar() | |
| let titleView = NavigationTitleView() |
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
| console.log(1); | |
| (_ => console.log(2))(); | |
| eval('console.log(3);'); | |
| console.log.call(null, 4); | |
| console.log.apply(null, [5]); | |
| new Function('console.log(6)')(); | |
| Reflect.apply(console.log, null, [7]) | |
| Reflect.construct(function(){console.log(8)}, []); | |
| Function.prototype.apply.call(console.log, null, [9]); | |
| Function.prototype.call.call(console.log, null, 10); |
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 Foundation | |
| // Extension allowing enum of Notification.Names. | |
| #if swift(>=3.0) | |
| extension Notification.Name: ExpressibleByStringLiteral { | |
| public init(stringLiteral value: String) { | |
| self.init(value) | |
| } |
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
| /* | |
| *** Academy Engraved LET *** | |
| AcademyEngravedLetPlain | |
| --------------------- | |
| *** Al Nile *** | |
| AlNile | |
| AlNile-Bold | |
| --------------------- | |
| *** American Typewriter *** | |
| AmericanTypewriter |
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 UIImage { | |
| // colorize image with given tint color | |
| // this is similar to Photoshop's "Color" layer blend mode | |
| // this is perfect for non-greyscale source images, and images that have both highlights and shadows that should be preserved | |
| // white will stay white and black will stay black as the lightness of the image is preserved | |
| func tint(tintColor: UIColor) -> 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
| import UIKit | |
| func randomColor(seed: String) -> UIColor { | |
| var total: Int = 0 | |
| for u in seed.unicodeScalars { | |
| total += Int(UInt32(u)) | |
| } | |