Skip to content

Instantly share code, notes, and snippets.

View Fiser12's full-sized avatar
🎯
Focusing

Rubén García Fiser12

🎯
Focusing
View GitHub Profile
@propertyWrapper
public struct AnyProxy<EnclosingSelf, Value> {
private let keyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>
public init(_ keyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>) {
self.keyPath = keyPath
}
@available(*, unavailable, message: "The wrapped value must be accessed from the enclosing instance property.")
public var wrappedValue: Value {
@Fiser12
Fiser12 / KeychainWrapper.swift
Last active February 21, 2023 17:19
I have created a simplified version of KeychainAccess that allows you to just mark a property of a class like @KeychainWrapper("tag"), to store it under a tag as long as it implements Codable. This makes it very easy to make use of the Keychain.
// I got inspiration in this repository https://github.com/kishikawakatsumi/KeychainAccess
// This is a great library that is backward compatible with very old versions of iOS and macOS and gives you a very complete wrapper of the Keychain
// But it was too much for me, since I didn't need neither that backward compatibility nor so many features, I just wanted to keep Codable secrets in the Keychain.
// So I have made my own version, also implementing a Property Wrapper to make it agnostic to use.
// I have thus reduced the 3000 lines of KeychainAccess to less than 200 and I have made its use for the functions I was interested in much more agile and integrated with SwiftUI,
// KeychainWrapper.swift
// SyncTion (macOS)
//
// Created by Rubén on 20/2/23.
//
@Fiser12
Fiser12 / SwiftUIExtension.swift
Created January 20, 2023 12:13
SwiftUI if else modifiers
extension View {
@ViewBuilder func `if`<Content: View>(_ condition: Bool, transform: (Self) -> Content) -> some View {
if condition {
transform(self)
} else {
self
}
}
@ViewBuilder func `if`<Content: View, ContentElse: View>(
import SwiftUI
struct DatePickerNullable: View {
let title: String
@Binding var selected: Date?
let defaultDate: Date
var body: some View {
HStack {
if let date = Binding($selected) {
@Fiser12
Fiser12 / NOTION_POWERSHELL_INBOX_SHORTCUT.md
Last active April 13, 2022 14:46
How to create a fast inbox that send your notes to the notion API

How to configure the script?

You should add a shortcut that points to the file location

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File C:\Users\USER\Desktop\notion-inbox.ps1

import Combine
import ComposableArchitecture
import KeyboardShortcuts
public struct KeyboardShortcutManager {
public enum Action: Equatable {
case onKeyDown(UUID)
case onKeyUp(UUID)
}