Skip to content

Instantly share code, notes, and snippets.

View fitomad's full-sized avatar
👋
Swift + ML & DL + Azure + AWS

Adolfo fitomad

👋
Swift + ML & DL + Azure + AWS
View GitHub Profile
@frozen public struct Castillo
{
/// La propietaria del castillo
public var moradora: Princesa
/// La superficie (habitable) del castillo
public var metrosCuadrados: Int
/**
Nuevo castillo para la princesa del universo Frozen
*/
let index = Int.random(in: 0 ..< Princesa.allCases.count)
switch Princesa.allCases[index]
{
case .elsa:
print("Elsa")
case .anna:
print("Anna")
}
@frozen public enum Princesa: CaseIterable
{
case elsa
case anna
}
public enum Princesa: CaseIterable
{
case elsa
case anna
case olivia
case valeria
}
let index = Int.random(in: 0 ..< Princesa.allCases.count)
switch Princesa.allCases[index]
{
case .elsa:
print("Elsa")
case .anna:
print("Anna")
@unknown default:
print("Por si hacen Frozen 3 y aparece una nueva princesa")
@fitomad
fitomad / SwiftUI_async_image_loading.swift
Last active April 22, 2020 02:49
A SwiftUI example about async image loading.
//
// ImageLoader.swift
// DubDubKit
//
// Created by Adolfo Vera Blasco on 27/06/2019.
// Copyright © 2019 Adolfo Vera Blasco. All rights reserved.
//
#if os(macOS)
import AppKit
@fitomad
fitomad / urlsession+combine_delay_retry.swift
Created June 21, 2019 07:09
Beta version of an URLSession + Combine that detected a 429 HTTP error (rate limit) then delay N seconds and retry.
/**
URL HTTP request to a server with a
3 request per 10 seconds rate limit.
Thanks to combine it's super easy detected
rate limit and retry after N seconds.
This is a *beta* version.
Things TO-DO...
@fitomad
fitomad / SwiftUI-flip-animation.swift
Last active October 13, 2020 20:14
A SwiftUI animation that represents a flip view to show Q&A cards.
//: A UIKit based Playground for presenting SwiftUI based user interface
// by @fitomad
import UIKit
import SwiftUI
import PlaygroundSupport
// MARK: - Contenedor Principal -
public struct Container: View
@fitomad
fitomad / swiftui_shadow_and_border.swift
Last active August 4, 2021 21:41
Testing SwiftUI. Adding shadow and corner radius to a View. Strange behavior depending on View background color
//: A UIKit based Playground for playing with SwiftUI
// @fitomad
import UIKit
import SwiftUI
import PlaygroundSupport
struct RoundedShadowView: View
{
var body: some View
extension Collection
{
/// Ask in a *positive way *
/// if a collection is **not** empty
var isFilled: Bool
{
return !self.isEmpty
}
}