Skip to content

Instantly share code, notes, and snippets.

@marcoarment
marcoarment / OCObservableKeyPaths.swift
Last active January 18, 2024 06:01
A Combine publisher for `@Observable` key-paths
// I think this works and doesn't create circular references?
/*
Usage: Add OCObservableKeyPaths conformance to the observed type. Then, e.g.
audioPlayer
.publisher(forObservableKeyPaths: [ \.timestamp, \.duration ])
.sink {
// respond to change
}
@velyan
velyan / StateMachine.swift
Last active March 4, 2020 18:31
Swift State Pattern
import Foundation
fileprivate protocol Statelike {
var stateMachine: StateMachine { get }
func logIn()
func logOut()
}
extension Statelike {
func logIn() {}
@msiedlarek
msiedlarek / Makefile
Created August 7, 2012 10:04
Telnet echo server based on libevent2
all: server
server: server.c
clang -Wall -Wextra -std=c99 -pedantic -g -levent -o server server.c
clean:
rm -rf server server.dSYM