Skip to content

Instantly share code, notes, and snippets.

View amine2233's full-sized avatar

Amine Bensalah amine2233

View GitHub Profile
//
// 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
import XCTest
public enum TestWaitResult {
case wait, success
}
public enum WaitTimeoutCondition {
case fail, skip
}
@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
// 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) -> ())
//
// main.swift
// RoutingApproaches
//
// Created by Chris Eidhof on 01.08.18.
// Copyright © 2018 objc.io. All rights reserved.
//
import Foundation
/// 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
//
// ContentView.swift
// Store
//
// Created by Chris Eidhof on 05.02.20.
// Copyright © 2020 Chris Eidhof. All rights reserved.
//
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
@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 / RenameGitBranch.md
Created May 19, 2024 08:25 — forked from danieldogeanu/RenameGitBranch.md
How to rename your Git master branch to main.

To rename your Git master branch to main, you must do the following steps:

  1. Navigate to your repository in the command line and issue the following commands: - git branch -m master main - git push -u origin main

  2. Change your default branch on GitHub by going to your GitHub repository in your browser, and navigate to Settings > Branches and click on the dropdown and switch from master to main and click Update (this will only show if you have two or more branches). The main branch is now your default branch.

  3. Update the tracking of the branch from your command line with the following command: - git branch -u origin/main main