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
// | |
// NSApplication+NSResponderDebug.swift | |
// | |
// Created by Stephan Casas on 3/18/24. | |
// | |
import Cocoa; | |
extension NSApplication { | |
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
#!/usr/bin/env bash | |
<% for type in types.classes { -%> | |
<%_ if type.modifiers.map{ $0.name }.contains("final") || type.modifiers.map{ $0.name }.contains("open") || types.based[type.name].isEmpty == false { continue } -%> | |
<%_ _%>git grep -lz 'class <%= type.name %>' | xargs -0 perl -i'' -pE "s/class <%= type.name %>(?=\s|:)/final class <%= type.name %>/g" | |
<% } %> | |
// Run with Sourcery on your codebase and then execute generated code via bash :) |
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 | |
/// An Equatable container for storing and accessing just the attributes of an NSAttributedString without | |
/// caring about the string itself. | |
struct TextAttributes: Equatable { | |
private var storage = NSMutableAttributedString(string: "") | |
mutating func setAttributes(_ attributes: [NSAttributedString.Key: Any], range: NSRange) { | |
preserveUniqueReferenceToStorageIfNecessary() | |
extendStringRangeIfNecessary(range: range) |
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 | |
protocol Placeholding { | |
static func placeholder() -> Self | |
} | |
struct PlaceholderArray<Element: Placeholding>: RandomAccessCollection { | |
typealias SubSequence = Slice<Self> | |
var startIndex: Int { indices.lowerBound } |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>FILEHEADER</key> | |
<string> | |
// Copyright © ___YEAR___ ___ORGANIZATIONNAME___. | |
// All Rights Reserved. | |
</string> | |
<key>ORGANIZATIONNAME</key> |
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 SwiftUI | |
extension View { | |
public func focused<T>(file: StaticString = #file, _ state: FocusState<T>, equals value: T) -> some View { | |
modifier(FocusedModifier(state: state, id: value, file: file)) | |
} | |
} | |
@propertyWrapper |
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 ComposableArchitecture | |
import Difference | |
import Foundation | |
/// A container for storing action filters. | |
/// | |
/// The logic behind having this rather than a normal closure is that it allows us to namespace and gather action filters together in a consistent manner. | |
/// - Note: You should be adding extensions in your modules and exposing common filters you might want to use to focus your debugging work, e.g. | |
/// ```swift | |
/// extension ActionFilter where Action == AppAction { |
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
#!/bin/bash | |
# Dependency: requires macOCR | |
# Download: https://github.com/schappim/macOCR | |
# @raycast.schemaVersion 1 | |
# @raycast.title macOCR | |
# @raycast.mode silent | |
# @raycast.author Lim Chee Aun | |
# @raycast.authorURL https://github.com/cheeaun |
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 SKAction { | |
static func write<Root: AnyObject, Value>( | |
value: Value, | |
to keyPath: ReferenceWritableKeyPath<Root, Value>, | |
on object: Root | |
) -> SKAction { | |
SKAction.customAction(withDuration: 0) { [weak object] _, _ in | |
object?[keyPath: keyPath] = value | |
} |
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
struct Foo: Codable { | |
var name: String | |
@Ignore var foo: Int? | |
} | |
let model = Foo(name: "Ian", foo: 42) | |
let data = try! JSONEncoder().encode(model) | |
print(String(data: data, encoding: .utf8)!) // {"name":"Ian"} | |
NewerOlder