Skip to content

Instantly share code, notes, and snippets.

View helje5's full-sized avatar

Helge Heß helje5

View GitHub Profile
@Enie
Enie / BrushedMetalDemoApp.swift
Last active August 19, 2024 14:28
Brushed Metal shader effect for SwiftUI
import SwiftUI
@main
struct BrushedMetalDemoApp: App {
var body: some Scene {
WindowGroup {
BrushedMetalView {
ContentView()
}
}
@peterkos
peterkos / VariadicViewHelpers.swift
Last active May 25, 2024 23:09
Helpers for setting traits when using _VariadicView
// Generic version of https://gist.github.com/chriseidhof/5ff6ef8786f5635c18b20304ab9d9b01
extension View {
/// Convenience for setting a `_ViewTraitKey`
func withTrait<Trait, Value>(_: Trait.Type, value: Value) -> some View
where Trait: _ViewTraitKey, Value == Trait.Value
{
_trait(Trait.self, value)
}
}
@KhaosT
KhaosT / HDMI on Apple Vision Pro.md
Last active February 24, 2025 14:25
Guide for using Apple Vision Pro as HDMI display

Displaying HDMI sources on Apple Vision Pro

While it's possible to stream most content to Apple Vision Pro directly over the internet, having the ability to use Apple Vision Pro as an HDMI display can still be useful.

Since Apple Vision Pro does not support connecting to an HDMI input directly or using an HDMI capture card, we have to be a little creative to make this work. NDI provides the ability to stream HDMI content over a local network with really low latency, and it works great with Apple Vision Pro.

This page shows the setup I’m using.

@cwalo
cwalo / IndentScrollView
Last active July 9, 2024 21:36
IndentScrollView - A paging ScrollView that tracks the target content view
import SwiftUI
struct IndentScrollView: View {
let min = 0.5
let max = 3.5
let increment = 0.1
@State
var multiplier = 0.5
@gboyegadada
gboyegadada / TransferableItem.swift
Last active June 30, 2024 22:13
[Mac OS] Custom Copy / Paste with Swift UI Transferable + support for NSPasteboard (NSPasteboardWriting, NSPasteboardReading) and drag / drop
//
// TransferableItem.swift
//
// Created by Gboyega Dada on 22/11/2023.
//
// @see https://stackoverflow.com/a/57648296/1661299
// @see https://exploringswift.com/blog/creating-a-nsitemprovider-for-custom-model-class-drag-drop-api
// @see https://stackoverflow.com/a/66169874/1661299
//
@helje5
helje5 / CompareAnySwift57.swift
Created August 2, 2023 16:20
Compare Any w/ Swift 5.7
func isEqual(_ lhs: Any, _ rhs: Any) -> Bool {
guard let lhs = lhs as? any Equatable else { return false }
func isEqual<T: Equatable>(lhs: T, rhs: Any) -> Bool {
guard let rhs = rhs as? T else { return false }
return lhs == rhs
}
return isEqual(lhs: lhs, rhs: rhs)
}
@JustinFincher
JustinFincher / Table.swift
Created July 28, 2023 02:55
Recursive Outline Table
import SwiftUI
struct TestModel: Identifiable {
let id = UUID()
var children: [TestModel]? {
(0..<5).map { _ in
TestModel()
}
}
}
@phranck
phranck / TassenGugelhupf.swift
Last active March 21, 2023 07:53
Backanleitung fuer einen Tassen-Gugelhupf
// TassenGugelhupf.swift
// Created by Frank Gregor on 18.03.23.
//
// This code compiles perfectly. Just paste it into a Playground and...
// "Let it go"
//
// You nay ask: "Why so complicated?"
// Well, the initial impulse came from this Mastodon thread:
// https://swiftdev.space/@phranck/110045414485613046
//
@finestructure
finestructure / Charting.swift
Last active October 23, 2023 20:22
Swift playground example to create charts with a PDF export button
import SwiftUI
import Charts
import PlaygroundSupport
let spiData: [(package: String, fileCount: Int, mbSize: Int)] = [
(package: "swift-markdown-ui", fileCount: 3796, mbSize: 44),
(package: "Microya", fileCount: 414, mbSize: 4),
(package: "swift-url-routing", fileCount: 9430, mbSize: 101),