Skip to content

Instantly share code, notes, and snippets.

@Fiser12
Fiser12 / fuctional-programing-contramap-es.md
Created February 7, 2024 20:48
Swift y programación funcional: Contramap

Swift y programación funcional: Contramap

La programación funcional ha introducido varios conceptos poderosos que pueden mejorar significativamente la claridad, concisión y expresividad del código. Entre estos, los predicados y la función contramap ofrecen una manera elegante de construir lógica de validación y filtrado reutilizable y componible. En este artículo, exploraremos cómo estos conceptos pueden aplicarse en Swift para resolver problemas complejos de manera eficiente. Predicados y contramap: Una Introducción

Un Predicate<A> es una estructura que encapsula una condición que los elementos de tipo A deben cumplir. Esta condición se representa mediante un closure que toma un elemento de tipo A y devuelve un valor booleano, indicando si el elemento cumple o no con la condición especificada. La función contramap, por otro lado, permite transformar un Predicate<b> en un Predicate<a> , dada una función que convierte de A a B. Esto es particularmente útil cuando queremos aplicar un predi

@Fiser12
Fiser12 / semantic-commit-messages.md
Last active January 24, 2024 10:20 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@Fiser12
Fiser12 / AVLTree.swift
Created April 11, 2023 23:10
AVLTree in swift for store data in a efficient way
final class AVLTree<Element: Comparable> {
private var value: Element?
private var left: AVLTree<Element>?
private var right: AVLTree<Element>?
private var balanceFactor: Int8 = 0
private var height: Int
init() {
height = (value == nil) ? 0 : 1
//
// main.swift
// Philosofers problem with actors (monitors)
//
//
import Foundation
let TiempoDeComer: UInt64 = 2_000_000_000
let TiempoDePensar: UInt64 = 1_000_000_000
@Fiser12
Fiser12 / README.md
Created March 10, 2023 21:59 — forked from IsaacXen/README.md
(Almost) Every WWDC videos download links for aria2c.
@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