Skip to content

Instantly share code, notes, and snippets.

View Obbut's full-sized avatar

Robbert Brandsma Obbut

  • Veldhoven, NL
  • 11:33 (UTC +02:00)
View GitHub Profile
// MARK: Usage example
let applicationMiddleware = buildMiddleware {
CatMiddleware()
DogMiddleware()
}
let routeSpecificMiddleware = applicationMiddleware.chain {
TokenMiddleware() // Removing this will cause compiler errors, because UserMiddleware depends on TokenMiddleware.Context
UserMiddleware()
import Dependencies
import SotoCore
struct AWSClientDependencyKey: DependencyKey {
typealias value = AWSClient
static var liveValue: AWSClient {
@Dependency(\.httpClient) var httpClient
return AWSClient(httpClientProvider: .shared(httpClient))
}
import Combine
import Foundation
@available(iOS 13.0, macOS 10.15, tvOS 13, watchOS 6, *)
public struct ObjectDidChangePublisher<ObjectWillChangePublisher: Publisher>: Publisher {
private let upstream: ObjectWillChangePublisher
public typealias Output = ObjectWillChangePublisher.Output
public typealias Failure = ObjectWillChangePublisher.Failure
fileprivate init(upstream: ObjectWillChangePublisher) {
import Combine
extension Publishers {
public struct CatchAssign<Upstream, Object>: Publisher where Upstream : Publisher {
public typealias Output = Upstream.Output
public typealias Failure = Never
/// The publisher from which this publisher receives elements.
let upstream: Upstream
@Obbut
Obbut / Adding a Physical Disk to Parallels.md
Last active January 23, 2024 08:06
Adding a second physical disk to Parallels

Adding a second physical disk to Parallels Desktop 14

I wanted my (NTFS) data disk to be accessible from my boot camp Parallels VM. Parallels provides no support for this, so I tried it myself.

I duplicated the disk file that Parallels created and started poking around, and after half an hour or so, had success. This is what you need to do.

My boot camp disk is at /dev/disk0. My data disk is at /dev/disk1.

These instructions are provided for educational use only and without guarantees. If you lose data because of this, blame yourself, and only follow them if you know what you are doing.

function setlang() {
if [ -z "$1" ]; then
echo "Sets the language to launch an application in"
echo "Usage: $0 [application name] [language]"
echo "Example: $0 Mail en-US"
return 1
fi
defaults write $(mdls -name kMDItemCFBundleIdentifier -raw /Applications/$1.app) AppleLanguages '("$2")'
echo "From now on, $1 will launch in $2"
@Obbut
Obbut / BSONCrash.swift
Last active April 4, 2018 12:36
BSON crash
import BSON
struct Henk : Codable {
struct Location : Codable {
var name = "JFdkljfds"
var street = "Harrieboblaan 1"
var postalCode = "1234 AB"
}
var _id = ObjectId()