Skip to content

Instantly share code, notes, and snippets.

View vmanot's full-sized avatar

Vatsal Manot vmanot

View GitHub Profile
//
// Copyright (c) Vatsal Manot
//
import Foundation
import Swift
public func type<T>(x: T) -> T
{
return x

Keybase proof

I hereby claim:

  • I am vmanot on github.
  • I am vatsal_manot (https://keybase.io/vatsal_manot) on keybase.
  • I have a public key whose fingerprint is 72BD 9E2A DAC5 A7B7 C70B 6794 6F92 A47B 9BF7 C6CB

To claim this, I am signing this object:

//
// Copyright (c) Vatsal Manot
//
module CommonCrypto [system]
{
header "./CommonCrypto.h"
export *
}
@vmanot
vmanot / UIModernStackView.swift
Last active April 6, 2023 20:36
A Better `UIStackView`
//
// Copyright (c) Vatsal Manot
//
#if canImport(UIKit)
import Swift
import UIKit
///
@vmanot
vmanot / PresentationLink2.swift
Created July 7, 2019 09:55
PresentationLink bug workaround for SwiftUI (Xcode b3)
extension UIApplication {
/// The top most view controller
static var topMostViewController: UIViewController? {
return UIApplication.shared.keyWindow?.rootViewController?.visibleViewController
}
}
extension UIViewController {
/// The visible view controller from a given view controller
var visibleViewController: UIViewController? {
@vmanot
vmanot / AnySubject.swift
Created July 6, 2020 20:53
AnySubject - Type erasure for Combine's Subject protocol
import Combine
public final class AnySubject<Output, Failure: Error>: Subject {
public let base: Any
@usableFromInline
let _baseAsAnyPublisher: AnyPublisher<Output, Failure>
@usableFromInline
let _sendImpl: (Output) -> ()
@usableFromInline
@vmanot
vmanot / NavigationView-Compatibility.swift
Created December 5, 2023 03:23
Suppress NavigationView warnings on iOS 17.0/macOS 14.0
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *)
@frozen
public struct _NavigationView<Content: View>: View {
private let content: Content
public init(@ViewBuilder content: () -> Content) {
self.content = content()
}
public var body: some View {