Skip to content

Instantly share code, notes, and snippets.

View mickeyl's full-sized avatar
🏠
Working from home

Dr. Mickey Lauer mickeyl

🏠
Working from home
View GitHub Profile
@groue
groue / ObservableState.swift
Last active April 26, 2024 09:28
WithBindable
import SwiftUI
/// Supplies an observable object to a view’s hierarchy.
///
/// The purpose of `WithBindable` is to make it possible to instantiate
/// observable objects from environment values, while keeping the object
/// alive as long as the view is rendered.
///
/// For example:
///
@marckleinebudde
marckleinebudde / gs_usb-protocol.rst
Last active February 22, 2024 08:11
gs_usb protocol definition
enum gs_usb_breq {
    GS_USB_BREQ_HOST_FORMAT = 0,
    GS_USB_BREQ_BITTIMING,
    GS_USB_BREQ_MODE,
    GS_USB_BREQ_BERR,
    GS_USB_BREQ_BT_CONST,
    GS_USB_BREQ_DEVICE_CONFIG,
    GS_USB_BREQ_TIMESTAMP,
@tcldr
tcldr / ConcurrencyUtilities.swift
Last active April 23, 2023 12:48
Swift Concurrency Utilities for managing Transactional Resources
// A simple serial queue. Every operation sent through the queue will be executed
// in first-in first-out order. Every operation will complete its execution fully,
// even if it includes suspension points, prior to the next operation commencing.
//
// TIP: If calling from a global actor like @MainActor annotate your closure to
// get better ergonomics: `queue.send { @MainActor in /* ... */ }`
public final class AsyncSerialQueue: Sendable {
import os
public struct Gate<T: Sendable>: Sendable {
struct Pass: Sendable {
var value: T
var continuaton: UnsafeContinuation<Void, Never>
}
struct Pending: Sendable {
var continuation: UnsafeContinuation<T, Never>
//
// BikeRRUITests.swift
// BikeRRUITests
//
// Created by Oliver Epper on 14.08.21.
//
// swiftlint:disable all
import XCTest
@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) {
@chriseidhof
chriseidhof / ContentView.swift
Last active March 27, 2024 19:14
Variadic Views
import SwiftUI
struct MyValue: _ViewTraitKey {
static var defaultValue: Int = 0
}
extension View {
func myValue(_ value: Int) -> some View {
_trait(MyValue.self, value)
}
@dattasaurabh82
dattasaurabh82 / CH340N_linux_fix.md
Last active March 19, 2024 11:41
Fix Driver issues for CH340N usb serial chip in Linux (Ubuntu 22.04)

Tested on Ubuntu 20, 21 earlier and they were not working. So upgraded Ubutbu to latest 22 version.

The issue is: The built in Kernals of Ubuntu and many Linux Kernals (between ) have the CH340 drivers broken / have bugs and not fixed (from kernal 5.4.0-87 and above)

Note: I didn't try on linux kernal 5.4.0-86 my self. I though I will see how is the situation in the latest linux kernal (as of 16/05/2022)

Instructions for Ubuntu 22.04 LTS x86_64

@LilithWittmann
LilithWittmann / autobahn.md
Last active October 26, 2023 12:11
autobahn.md
@simonbs
simonbs / childForStatusBarStyle.swift
Last active September 25, 2023 14:49
It seems that -childForStatusBarStyle: isn’t called on a UIViewController that is presented from a SwiftUI view using UIViewControllerRepresentable. Or am I doing something wrong? I came up with this *ugly* workaround that swizzles -childForStatusBarStyle: to return an associated object when present and uses the default implementation as fallback.
// We'll store a UIViewController as an associated object and don't want to store a strong reference to it.
private final class WeakBoxedValue<T: AnyObject>: NSObject {
private(set) weak var value: T?
init(_ value: T?) {
self.value = value
}
}
// Use associated objects to a UIViewController that should determine the status bar appearance.