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 AppKit | |
| struct ScreenshotManager { | |
| /// Matches macOS' screenshot filename format. | |
| private static let filenameFormatter: DateFormatter = { | |
| let formatter = DateFormatter() | |
| formatter.dateFormat = "'Screen Shot' yyyy-MM-dd 'at' HH.mm.ss" | |
| return formatter | |
| }() |
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 | |
| class URLSchemeHandler { | |
| private let urlHandler: (URL) -> Void | |
| init(urlHandler: @escaping (URL) -> Void) { | |
| self.urlHandler = urlHandler | |
| NSAppleEventManager.shared().setEventHandler( |
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 | |
| struct SparkleCleanup { | |
| private static let oldDownloadAge: TimeInterval = 86400 // 24 hours | |
| /// The location where Sparkle caches file downloads. | |
| private static var cacheURL: URL { | |
| guard let bundleIdentifier = Bundle.main.bundleIdentifier else { | |
| fatalError("Unable to get bundle identifier.") |
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 | |
| let homeDirectory: String = { | |
| let home = getpwuid(getuid()).pointee.pw_dir! | |
| return FileManager.default.string(withFileSystemRepresentation: home, length: Int(strlen(home))) | |
| }() |
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 AppKit | |
| class EventMonitor { | |
| private let handler: (NSEvent) -> Void | |
| private let mask: NSEvent.EventTypeMask | |
| private var monitor: Any? | |
| init(mask: NSEvent.EventTypeMask, handler: @escaping (NSEvent) -> Void) { | |
| self.handler = handler |
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 AppKit | |
| class PreferencesViewController: NSTabViewController { | |
| private lazy var tabViewSizes: [NSTabViewItem: NSSize] = [:] | |
| override func tabView(_ tabView: NSTabView, didSelect tabViewItem: NSTabViewItem?) { | |
| super.tabView(tabView, didSelect: tabViewItem) | |
| if let tabViewItem = tabViewItem { |
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
| // NSNotificationCenter isn't thread-safe, so this ensures that notifications are posted on the main thread. | |
| func postMainThreadNotification(notification: Notification) { | |
| DispatchQueue.main.async { NotificationCenter.default.post(notification) } | |
| } |
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
| """An example of a cache decorator.""" | |
| import json | |
| from functools import wraps | |
| from redis import StrictRedis | |
| redis = StrictRedis() | |
| def cached(func): |
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
| """ | |
| Connection adapter for Requests that allows it to talk with raw UNIX sockets. | |
| Adapted from requests-unixsocket, which itself was adapted from docker-py. | |
| https://github.com/msabramo/requests-unixsocket | |
| https://github.com/docker/docker-py/blob/master/docker/unixconn/unixconn.py | |
| """ | |
| import socket | |
| from urllib.parse import unquote, urlparse |
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
| git log --graph --all --oneline --decorate |