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 Enable translation on Mastodon | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2026-05-06 | |
| // @description Remove 'notranslate' class from #mastodon | |
| // @match *://*/* | |
| // @grant none | |
| // ==/UserScript== | |
| (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
| /** | |
| * This is the same as Set but supports objects. | |
| * Like https://github.com/szikszail/object-set-type but fast. | |
| */ | |
| export class ObjectSet<T> { | |
| _set: Set<string> | |
| constructor(arr: T[] = []) { | |
| this._set = new Set(arr.map(x => JSON.stringify(x))) | |
| } |
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 | |
| /// https://gist.github.com/Amzd/c3171021488fc82d1b68cfd8e89ada7b | |
| extension UIStatusBarManager { | |
| public static var statusBarTappedNotification: Notification.Name = { | |
| if let originalMethod = class_getInstanceMethod(UIStatusBarManager.self, Selector(("handleTapAction:"))), | |
| let swizzledMethod = class_getInstanceMethod(UIStatusBarManager.self, #selector(_handleTapAction)), | |
| // Prevent crash in case an argument is added/removed in the future | |
| method_getNumberOfArguments(originalMethod) == method_getNumberOfArguments(swizzledMethod) { | |
| method_exchangeImplementations(originalMethod, swizzledMethod) |
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
| /// Switch statement helper to switch with function as input | |
| func ~= <T>(value: T, block: (T) -> Bool) -> Bool { | |
| block(value) | |
| } | |
| func ~= <T0, T1>(value: (T0, T1), block: (T0, T1) -> Bool) -> Bool { | |
| block(value.0, value.1) | |
| } | |
| func ~= <T0, T1, T2>(value: (T0, T1, T2), block: (T0, T1, T2) -> Bool) -> 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
| @objc public enum DarwinNotification: Int { | |
| case appRunningQuestion | |
| case appRunningConfirmation | |
| var name: CFString { | |
| switch self { | |
| case .appRunningQuestion: "com.example.app_running_question" as CFString | |
| case .appRunningConfirmation: "com.example.app_running_confirmation" as CFString | |
| } | |
| } |
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
| /// https://gist.github.com/Amzd/93f2e7b4712242ec4e17476146f528a2 | |
| public struct Version: Codable { | |
| public var major: UInt | |
| public var minor: UInt | |
| public var patch: UInt | |
| public var identifier: String? | |
| public var stringValue: String { | |
| "\(major).\(minor).\(patch)" + (identifier.flatMap { "-\($0)" } ?? "") | |
| } |
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? { | |
| /// This property is true on encountering one of "Y", "y", "T", "t", or a digit 1-9—the method ignores any trailing characters. | |
| /// This property is false if the receiver doesn’t begin with a valid decimal text representation of a number. | |
| /// | |
| /// The property assumes a decimal representation and skips whitespace at the beginning of the string. | |
| /// It also skips initial whitespace characters, or optional -/+ sign followed by zeroes. | |
| var yN: Bool { if let self { NSString(string: self).boolValue } else { false } } | |
| /// This property is true when it is empty (or nil) or when yN is true | |
| var Yn: Bool { (self?.isEmpty ?? true) || yN } | |
| } |
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 view that hides its content to a user's recording, broadcast or screenshot. | |
| /// https://gist.github.com/Amzd/2652bc98a6ae098701b342d710e45aa7 | |
| @available(iOS 12, *) | |
| @dynamicMemberLookup | |
| class PrivacySensitiveView<ContentView: UIView>: UIView { | |
| private var content: ContentView | |
| private var textField = { | |
| let textField = UITextField() |
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 | |
| /// https://gist.github.com/Amzd/223979ef5a06d98ef17d2d78dbd96e22 | |
| extension UIViewController { | |
| /// UIDocumentPickerViewController by itself does not return first responder to the view controller that presented it | |
| /// when the cancel button is pressed after the search field was used. This function fixes that by making the previous | |
| /// first responder, first responder again when the document picker is dismissed. | |
| /// Normally this is handled by the private `UIViewController._restoreInputViewsForPresentation` | |
| /// but for some reason the UIDocumentPickerViewController does not call that, and since it's closed source I don't | |
| /// know why. |
NewerOlder