Skip to content

Instantly share code, notes, and snippets.

View anthonycastelli's full-sized avatar

Anthony anthonycastelli

View GitHub Profile
//
// VolumePopupView.swift
//
// Created by Alex Rosenberg on 1/24/24.
//
import SwiftUI
import AVFoundation
import MediaPlayer
@KhaosT
KhaosT / HDMI on Apple Vision Pro.md
Last active April 21, 2024 03:49
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.

@IanKeen
IanKeen / Storage.swift
Last active April 8, 2024 12:24
PropertyWrapper: Storage to extend support for more types using `@AppStorage`
@propertyWrapper
struct Storage<T: AppStorageConvertible>: RawRepresentable {
var rawValue: String { wrappedValue.storedValue }
var wrappedValue: T
init?(rawValue: String) {
guard let value = T.init(rawValue) else { return nil }
self.wrappedValue = value
}
init(wrappedValue: T) {
@daweido
daweido / user.controller.ts
Last active April 19, 2023 20:03
SMS OTP - Partial User authentification
import { Controller, Get, Res, HttpStatus, Body, Post } from '@nestjs/common';
import { User } from './interfaces/user.interface';
import { UserService } from './user.service';
@Controller('user')
export class UserController {
constructor(private userService: UserService) {}
@Post('/login')
async loginUser(
@propertyWrapper
public final class LayoutInvalidating<Value> where Value: Equatable {
public static subscript<EnclosingSelf>(
_enclosingInstance observed: EnclosingSelf,
wrapped wrappedKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>,
storage storageKeyPath: ReferenceWritableKeyPath<EnclosingSelf, LayoutInvalidating>
) -> Value where EnclosingSelf: UIView {
get {
return observed[keyPath: storageKeyPath].stored
@frankfka
frankfka / iOSCustomSegmentedControlSwiftUI.swift
Created May 17, 2020 16:47
Custom Segmented Picker / Segmented Control in SwiftUI
import SwiftUI
extension View {
func eraseToAnyView() -> AnyView {
AnyView(self)
}
}
struct SizePreferenceKey: PreferenceKey {
typealias Value = CGSize
@propertyWrapper
public struct AnyProxy<EnclosingSelf, Value> {
private let keyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>
public init(_ keyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>) {
self.keyPath = keyPath
}
@available(*, unavailable, message: "The wrapped value must be accessed from the enclosing instance property.")
public var wrappedValue: Value {
import Foundation
extension Character {
var isEmoji: Bool {
return unicodeScalars.allSatisfy { $0.properties.isEmoji }
}
}
func recentlyUsedEmoji() -> [Character]? {
#if os(iOS)
@samalone
samalone / Database+transaction.swift
Last active September 6, 2019 21:25
Transactions for Vapor 4 alpha 3
import FluentPostgresDriver
import FluentSQLiteDriver
// This extension adds transaction support to the Database protocol.
// It has to be specialized for each Database type used by your application,
// since the Database protocol does not support the raw() method.
extension Database {
func transaction(callback: @escaping (Database) -> EventLoopFuture<Void>) -> EventLoopFuture<Void> {
return self.withConnection { (db) -> EventLoopFuture<Void> in
@bardonadam
bardonadam / DynamicColor.swift
Last active August 20, 2021 03:22
DynamicColor property wrapper type to remove boilerplate code when defining dynamic colors to adopt dark mode on iOS 13
@DynamicColor(lightVariant: .black, darkVariant: .white)
static var dynamicLabelColor: UIColor
@propertyWrapper
struct DynamicColor {
let lightVariant: UIColor
let darkVariant: UIColor
var wrappedValue: UIColor {
get {