Skip to content

Instantly share code, notes, and snippets.

//
// CropView.swift
//
import MetalPetal
import SwiftUI
#if os(macOS)
import AppKit
#endif
@rdev
rdev / .clang-format
Last active April 26, 2025 15:27
Sensible Metal formatting
BasedOnStyle: WebKit # WebKit is the least deranged baseline
IndentWidth: 2 # 2-space indents
ContinuationIndentWidth: 2 # also 2-space for broken lines
AlignAfterOpenBracket: BlockIndent # indent blocks under open paren/bracket
NamespaceIndentation: All # always indent inside namespaces
IndentCaseLabels: true # pushes `case` one level in
IndentCaseBlocks: true # statements under the label get one more indent
BreakBeforeBraces: Custom # manually specify brace rules
import AVFoundation
import CoreImage
import SwiftUI
import UniformTypeIdentifiers
let context = CIContext()
struct ContentView: View {
@State var nsImage: NSImage?
@State var ciImage = CIImage(contentsOf: Bundle.main.url(forResource: "1080p", withExtension: "jpg")!)!
@rdev
rdev / Keyboard.swift
Last active October 9, 2022 00:43
SwiftUI modifier to handle customizable keyboard shortcuts anywhere in the app
import SwiftUI
class KeyboardHostingView<Content: View>: NSHostingView<Content> {
var actions: [UInt16: (_ modifiers: NSEvent.ModifierFlags) -> Void]
var monitors: [UInt16: Any?] = [:]
var isPassthrough: Bool
init(actions: [UInt16: (_ modifiers: NSEvent.ModifierFlags) -> Void], isPassthrough: Bool, content: () -> Content) {
self.actions = actions
@rdev
rdev / ClickOutside.swift
Created September 23, 2021 05:16
SwiftUI ClickOutside component
//
// ClickOutside.swift
// ClickOutside
//
// Created by Max Rovensky on 11/07/2021.
//
import SwiftUI
class ClickOutsideHostingView<Content: View>: NSHostingView<Content> {

Keybase proof

I hereby claim:

To claim this, I am signing this object:

{
"particles": {
"number": {
"value": 80,
"density": {
"enable": true,
"value_area": 800
}
},
"color": {
{"assets":[{"id":"comp_0","layers":[{"ddd":0,"ind":0,"ty":5,"nm":"Done!","ks":{"o":{"k":[{"i":{"x":[0.833],"y":[1]},"o":{"x":[1],"y":[0.021]},"n":["0p833_1_1_0p021"],"t":11,"s":[0],"e":[100]},{"t":20.0000008146167}]},"r":{"k":0},"p":{"k":[960,892,0]},"a":{"k":[0,0,0]},"s":{"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"n":["0p833_0p833_0p167_0p167","0p833_0p833_0p167_0p167","0p833_0p833_0p167_0p167"],"t":8,"s":[90,90,100],"e":[100,100,100]},{"t":17.0000006924242}]}},"ao":0,"t":{"d":{"k":[{"s":{"s":140,"f":"OpenSans","t":"Done!","j":2,"tr":0,"lh":168,"fc":[0.94,0.56,0.34]},"t":0}]},"p":{},"m":{"g":1,"a":{"k":[0,0]}},"a":[]},"ip":0,"op":60.0000024438501,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 3","ks":{"o":{"k":100},"r":{"k":130},"p":{"k":[948,626,0]},"a":{"k":[108.934,-59.615,0]},"s":{"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"n":["0p833_0p833_0p167_
{
"assets": [],
"layers": [{
"ddd": 0,
"ind": 1,
"ty": 4,
"nm": "Shape Layer 1",
"ks": {
"o": {
"k": 100
// Settings sync for Atom