This file contains 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
# 1. Paste this into Script Editor, replace username and password; | |
# 2. Export as "Application", check "Stay open" and "Run-only"; | |
# 3. Add to Login Items in Settings/General to run automatically; | |
# 4. To hide the Dock icon, add to Content/Info.plist: | |
# <key>LSUIElement</key> | |
# <string>1</string> | |
on idle | |
set idleTime to (do shell script "ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print $NF/1000000000; exit}'") as integer | |
if idleTime is less than 58 then |
This file contains 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 | |
protocol ConfigurableCell: UICollectionViewCell { | |
associatedtype Item | |
func configure(with item: Item, for indexPath: IndexPath) | |
} | |
extension ConfigurableCell { | |
public static var provider: (UICollectionView, IndexPath, Item) -> Self { | |
let registration = registration() |
This file contains 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 hashCode() -> Int32 { | |
unicodeScalars.map { Int32($0.value) }.reduce(0) { 31 &* $0 &+ $1 } | |
} | |
} |
This file contains 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 RadarView: UIView { | |
private let waveShape = CAShapeLayer() | |
private let waveReplicator = CAReplicatorLayer() | |
override init(frame: CGRect = .zero) { | |
super.init(frame: frame) |
This file contains 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 Combine | |
import Foundation | |
@dynamicMemberLookup | |
public class ViewModel<Object> { | |
private var object: Object | |
init(_ object: Object) { | |
self.object = object | |
} |
This file contains 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 SwiftUI | |
class Item: ObservableObject, Identifiable { | |
let id = UUID() | |
@Published var name = "" | |
@Published var value = "" | |
} | |
struct ContentView: View { | |
@State private var items: [Item] = [] |
This file contains 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 | |
public protocol LayoutAnchor {} | |
extension NSLayoutAnchor: LayoutAnchor {} | |
public struct AnchorPair<T: AnyObject, U: AnyObject>: LayoutAnchor { | |
public var first: NSLayoutAnchor<T> | |
public var second: NSLayoutAnchor<U> | |
} |
This file contains 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 | |
public protocol Reusable: AnyObject { | |
static var reuseIdentifier: String { get } | |
} | |
extension Reusable { | |
public static var reuseIdentifier: String { | |
String(describing: self) | |
} |
This file contains 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 | |
open class AsyncOperation: Operation { | |
private enum State: String { | |
case ready = "isReady" | |
case executing = "isExecuting" | |
case finished = "isFinished" | |
} |
NewerOlder