Skip to content

Instantly share code, notes, and snippets.


Alexis Bridoux ABridoux

View GitHub Profile
ABridoux / ReducedReplayAsyncStream.swift
Created Jan 29, 2022
An AsyncSequence that allows to be consumed several times. Returning the current state as specified in a reduce function
View ReducedReplayAsyncStream.swift
struct ReducedReplayAsyncStream<Element> {
typealias Reduce = (_ partialResult: inout Element, _ nextResult: Element) -> Void
private let storage: _Storage
private var originalStream: AsyncStream<Element>
bufferingPolicy limit: AsyncStream<Element>.Continuation.BufferingPolicy = .unbounded,
initialResult: Element,
ABridoux / EventService.swift
Last active Sep 21, 2022
A service to send events to restart, shutdown, put to sleep or logout the computer.
View EventService.swift
// Free to use
// Written by Alexis Bridoux -
import Foundation
/// Service to shut down, restart, or put the computer to sleep. Also log out the user.
/// ### Resources
/// - [Apple doc](
/// - Already in use in [SplashBuddy](
ABridoux / NotificationObserver.swift
Last active Aug 10, 2021
A handy class to observe notifications with automatic unsubscribing and friendly syntax.
View NotificationObserver.swift
// Free to use
// Written by Alexis Bridoux -
/// Observes a notification and executes the provided block upon reception
/// Unregister the stored observer upon deinitialization
final class NotificationObserver {
var name: Notification.Name
var observer: NSObjectProtocol
ABridoux / WindowPosition.swift
Last active Dec 17, 2022
Logic to easily set a NSWindow's origin horizontally and vertically in a screen (AppKit and SwiftUI)
View WindowPosition.swift
// Free to use
// Written by Alexis Bridoux -
import AppKit
#if canImport(SwiftUI)
import SwiftUI
// MARK: Model