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 | |
| /// A UILabel subclass that can hold attributes and apply them to text | |
| @IBDesignable | |
| final class Label: UILabel { | |
| convenience init(attributes: [NSAttributedStringKey: Any]) { | |
| self.init() | |
| self.attributes = attributes | |
| } | |
| // MARK: Properties |
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 | |
| func setupCodeFrom(uri: String) -> String { | |
| let startIndex = uri.index(uri.startIndex, offsetBy: "X-HM://".count) | |
| let endIndex = uri.index(uri.endIndex, offsetBy: -4) | |
| var actualString = uri[startIndex..<endIndex] | |
| let number = UInt(actualString, radix: 36)! | |
| var code = String(format: "%08u", number & 0x7ffffff) |
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 | |
| class UILabelCopyable: UILabel { | |
| override func copy(_ sender: Any?) { | |
| UIPasteboard.general.string = text | |
| } | |
| override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { |
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 { | |
| func filter<T: Equatable>(where keyPath: KeyPath<Element, T>, equals compareValue: T) -> [Element] { | |
| return filter { $0[keyPath: keyPath] == compareValue } | |
| } | |
| } |
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 { | |
| func sorted<T: Comparable>(by keyPath: KeyPath<Element, T>, ordered areInIncreasingOrder: (T, T) -> Bool = (<) ) -> Array<Element> { | |
| return self.sorted(by: { | |
| areInIncreasingOrder($0[keyPath: keyPath], $1[keyPath: keyPath]) | |
| }) | |
| } | |
| } |
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 | |
| internal extension Sequence { | |
| func grouped<T>(by keyPath: KeyPath<Element, T>) -> [T: [Element]] { | |
| var groups = [T: [Element]]() | |
| for element in self { | |
| let key = element[keyPath: keyPath] | |
| if !groups.keys.contains(key) { | |
| groups[key] = [Element]() | |
| } |
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/bash | |
| IP=$(dig +short $1 | sed -n 1p) | |
| whois -h whois.ripe.net -- "-T route ${IP}" |
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 UIFont { | |
| /// Returns the font in the specified size and weight. Default weight is `regular` | |
| open class func font(ofSize fontSize: CGFloat, weight: FontWeight = .regular) -> UIFont { | |
| let fontName = "UniversNextPro-\(weight.rawValue)" | |
| guard let font = UIFont(name: fontName, size: fontSize) else { | |
| fatalError("\(fontName) not found") | |
| } | |
| return font |
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 | |
| /// Custom FontWeights to be used with the .font UIFont class functions | |
| public enum FontWeight: String { | |
| case regular = "Regular" | |
| case medium = "Medium" | |
| case black = "Black" | |
| case light = "Light" | |
| case thin = "Thin" | |
| case bold = "Bold" |
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/bash | |
| set -e | |
| SCALEWAY='scw --region="ams1"' | |
| ARCH=X64 | |
| COMM_TYPE=$ARCH-2GB | |
| IMAGE=xenial | |
| TRANSFERS=7 | |
| TG_TOKEN=<BOT_TOKEN> |