Skip to content

Instantly share code, notes, and snippets.

View tkersey's full-sized avatar
👹

Tim Kersey tkersey

👹
View GitHub Profile
@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.

@Alex-Ozun
Alex-Ozun / typestate-tesla-car.swift
Last active March 22, 2024 10:03
Typestate in Swift
enum Parked {}
enum Driving {}
enum Gaming {}
private class EngineSystem {
static var shared = EngineSystem()
private init() {}
func start() {/**/}
func accelerate() { /* Uses gas pedal input to accelerate the real car */ }
@saagarjha
saagarjha / file_drain.c
Created November 11, 2023 10:01
"Drain" files while they are processed to reduce free disk space requirements
// Sometimes you have a large file on a small disk and would like to "transform"
// it in some way: for example, by decompressing it. However, you might not have
// enough space on disk to keep both the the compressed file and the
// decompressed results. If the process can be done in a streaming fashion, it
// would be nice if the file could be "drained"; that is, the file would be
// sequentially deleted as it is consumed. At the start you'd have 100% of the
// original file, somewhere in the middle you'd have about half of the original
// file and half of your output, and by the end the original file will be gone
// and you'll be left with just the results. If you do it this way, you might
// be able to do the entire operation without extra space!
@zanzix
zanzix / SOAT.idr
Created October 29, 2023 18:09
Second-Order Algebraic Theories
-- Our data-type for signatures
data Signature a = Sig (List a) a
-- Synonym for first-order signatures
infix 4 |-
(|-) : List a -> a -> Signature a
(|-) = Sig
-- Synonym for second-order signatures
infix 4 ||-
-- Yoneda --------------------------------------------------------------
newtype Yoneda f a = Yoneda { runYoneda :: forall b. ((a -> b) -> f b) }
instance Functor (Yoneda f) where
fmap f y = Yoneda (\ab -> runYoneda y (ab . f))
toYoneda :: Functor f => f a -> Yoneda f a
toYoneda fa = Yoneda (\f -> fmap f fa)
fromYoneda :: Yoneda f a -> f a
@zanzix
zanzix / CartCata.idr
Last active October 27, 2023 07:39
Free Cartesian Categories using Recursion Schemes
infixr 5 ~~> -- Morphisms of graphs
-- | Boilerplate for recursion schemes
-- Objects are graphs
Graph : Type -> Type
Graph o = o -> o -> Type
-- Morphisms are vertex-preserving transformations between graphs
@zanzix
zanzix / ProfBicat.idr
Last active September 30, 2023 02:56
Bicategory of Profunctors
-- Profunctor composition
data CompP : (k1 -> k2 -> Type) -> (k2 -> k3 -> Type) -> k1 -> k3 -> Type where
InComp : {k1, k2, k3 : Type} -> {a : k1} -> {b : k2} -> {c : k3} -> {p : k1 -> k2 -> Type} -> {q : k2 -> k3 -> Type}
-> p a b -> q b c -> CompP p q a c
-- Natural transformations over profunctors
Nt : {k1, k2 : Type} -> {arr : t -> t -> Type} -> (k1 -> k2 -> t) -> (k1 -> k2 -> t) -> Type
Nt f g = {a : k1} -> {b : k2} -> arr (f a b) (g a b)
-- Category of idris functions
@zanzix
zanzix / MonoidalTricategory.idr
Last active October 23, 2023 20:07
From monoid to monoidal tricategory
infixr 5 +++
infixr 5 ***
-- A list over a type
-- data List : Type -> Type where
-- Nil : List a
-- (::) : a -> List a -> List a
Graph : Type -> Type
Graph obj = obj -> obj -> Type
@tkersey
tkersey / pas.ts
Created September 24, 2023 17:27
TypeScript Proposition as Types
// https://www.typescriptlang.org/play?#code/PTAEDMEMBsGcFNQAcBOB7JbYEsAu20A7UQUqIAoXATyUQBUUBXRAXlAcIGtC0B3QgbjJkQoXI0SoMWPAWKASogrVEAMRgJQrQvABu8FIOFgAItlgArdgGN8RUAEFQgCiJQAIUU1QAeRQAeOwBpXAD4NUDJQUAAfUABvUUgAcwAuUAAiaHhwXFT+UG0YJhSHAF8wiOi43ESU1JRsBIALbNz86ELXUGKDMnArG2IMrL8ggApW9rsAShTvP0CtXRQQmPDQFHhcBhRiSuq0wezA8cQusmKhXsJrWTX6pp8XUeOUl2mvXwW9QMfY1fXN7axeLJNJ1RqHPIFE6Cc49Po3eB4Bp6OauQIAYVGqzQKBmvgCwX82MIABlMrgUiNIEVJhoQuiiREiAAlO4U0AjABGL1pzHpRLe6N+fw2W2II1WTJQADoqgkNMxWOlyakyhF1QB+UBEMlZEY46XHWmS9UpFls-Uyo2rSYwoSGUDoogWK79eygQDkRK53Ig7IQACaon6sADaBJcAF1uiIAJIAWyQ0GwlkgbocAFoQm4qB540ggyFWFSaXTXAYRABRACODGwrXgV19oB8fO9OcQMfA4ALoRDeYLgX7LkCdiCUaEIgAcvAEqmbgBCOw+0CTtC4YahEYADxLrc++ntImU2BQsFwoFTuHgCfPuDQyHQ-oYlkQkBXM7nulESjhrpuUGwDJ-QAfS0BJgMva8kFwEZaRWVZLmuWxwBxHQUVHYt7Dgk1-jFCBUMWKlbVWUohAids0HAfD1kWVYRHVAA9DV7QiRC3X9NAGE5DJQJnYYRi7SkU2gaBOUgSwOEpaksNLfdeRCOSil+dVQBAE02JuHhIDwYCUJovRMKmFJ92UlS1lFQEtJ0vS0JQIjBBU2EVNwwEuxGKzcF0gi9GIiJznIpRKNADiuJ4sC6LARjmIiejsEQVd1wS4YgjI0AMnPaTCAYONOT0UIQu4+BeISEYOFLDgRg
@steventroughtonsmith
steventroughtonsmith / VisionViewPlaygroundApp.swift
Created September 21, 2023 19:22
Trivial visionOS non-rectangular window content layout example
//
// VisionViewPlaygroundApp.swift
// VisionViewPlayground
//
// Created by Steven Troughton-Smith on 21/09/2023.
//
import SwiftUI
@main