Skip to content

Instantly share code, notes, and snippets.

View amine2233's full-sized avatar

Amine Bensalah amine2233

View GitHub Profile
@amine2233
amine2233 / PillButtons.swift
Created June 11, 2024 18:24 — forked from metasidd/PillButtons.swift
Pill Buttons - Mail App iOS 18 - SwiftUI
//
// PillButtons.swift
//
// Created by Siddhant Mehta on 6/11/24
// Twitter: @metasidd
//
// Feel free to reuse, or remix.
import SwiftUI
@amine2233
amine2233 / enable-touch-id-for-sudo.md
Created August 2, 2024 13:20 — forked from windyinsc/enable-touch-id-for-sudo.md
macOS - Enable Touch ID for sudo

Enable Touch ID for sudo

Thanks to this awesome Six Colors post: Quick Tip: Enable Touch ID for sudo

The short of it:

  1. In your terminal go to cd /etc/pam.d/.
  2. Now open the sudo file with your favorite command-line/GUI text editor.
    • Note that if you open it via the command-line, you’ll need to use sudo itself to do so, since the file is (understandably) protected.
  3. With the sudo file open, add the following command below below the first line. auth sufficient pam_tid.so
//
// ContentView.swift
// Store
//
// Created by Chris Eidhof on 05.02.20.
// Copyright © 2020 Chris Eidhof. All rights reserved.
//
import SwiftUI
/// Similar to a `Binding`, but this is also observable/dynamic.
@propertyDelegate
@dynamicMemberLookup
final class Derived<A>: BindableObject {
let didChange = PassthroughSubject<A, Never>()
fileprivate var cancellables: [AnyCancellable] = []
private let get: () -> (A)
private let mutate: ((inout A) -> ()) -> ()
init(get: @escaping () -> A, mutate: @escaping ((inout A) -> ()) -> ()) {
self.get = get
//
// main.swift
// RoutingApproaches
//
// Created by Chris Eidhof on 01.08.18.
// Copyright © 2018 objc.io. All rights reserved.
//
import Foundation
// effect Choice {
// operation decide() -> Bool
// }
// This is not polymorphic over the `Result`,
protocol Choice {
associatedtype Result
associatedtype State
func decide(_ k: (Bool, @escaping (State) -> ()) -> (), next: @escaping (Result) -> ())
@amine2233
amine2233 / with.swift
Created October 30, 2024 20:04 — forked from steipete/with.swift
with and then for UIKit and SwiftUI
/// Perform an immediate mutation of `subject`. The `transform` function may
/// just mutate the given `subject` or replace it entirely.
///
/// - Parameters:
/// - subject: A value to be transformed.
/// - transform: A closure that mutates or replaces the `subject`.
@inlinable func with<T>(_ subject: T, _ transform: (_ subject: inout T) throws -> Void) rethrows -> T {
var subject = subject
try transform(&subject)
return subject
import XCTest
public enum TestWaitResult {
case wait, success
}
public enum WaitTimeoutCondition {
case fail, skip
}
//
// Created by Eric Firestone on 3/22/16.
// Copyright © 2016 Square, Inc. All rights reserved.
// Released under the Apache v2 License.
//
// Adapted from https://gist.github.com/blakemerryman/76312e1cbf8aec248167
import Foundation