Skip to content

Instantly share code, notes, and snippets.

View Codelaby's full-sized avatar

Codelaby Codelaby

View GitHub Profile
@Codelaby
Codelaby / CardStackView
Last active May 4, 2024 09:05
Card Deck
import SwiftUI
struct Card: Identifiable {
var id = UUID().uuidString
var name: String
var color: Color
}
var cards : [Card] = [
Card(name:"card 1", color: .red),
@Codelaby
Codelaby / AdaptiveLayout.swift
Created July 13, 2023 14:26
Adaptative Layout Swift
struct AdaptLayout: View {
var body: some View {
VStack {
sampleTitle("View That Fits")
Spacer()
@Codelaby
Codelaby / lightprice_dsd_001.md
Last active August 1, 2023 10:05
DSD - lighprice - darkmode

Documento de Diseño: Tema Seleccionable por el Usuario para iOS

Título y Personas

Título: Tema Seleccionable por el Usuario para iOS

App: Precio de la luz

Plataforma: IOS

Autor: Codelaby

@Codelaby
Codelaby / readme.md
Created August 24, 2023 09:53
Añadir petición consenso publicidad android

Documento de Diseño: Diálogo de Consenso de Publicidad para Anuncios Personalizados en Android

Título y Personas Título: Diálogo de Consenso de Publicidad para Anuncios Personalizados en Android

App: Nombre de la Aplicación

Plataforma: Android

Autor: Codelaby

@Codelaby
Codelaby / energy_parser.swift
Created August 31, 2023 10:33
Energy parser Swift
import Foundation
//https://www.omie.es/sites/default/files/dados/AGNO_2023/MES_07/TXT/INT_PBC_TECNOLOGIAS_H_1_17_07_2023_17_07_2023.TXT
let csvContent = """
Fecha;Hora;CARBÓN;FUEL-GAS;AUTOPRODUCTOR;NUCLEAR;HIDRÁULICA;CICLO COMBINADO;EÓLICA;SOLAR TÉRMICA;SOLAR FOTOVOLTAICA;COGENERACIÓN/RESIDUOS/MINI HIDRA;IMPORTACIÓN INTER.;IMPORTACIÓN INTER. SIN MIBEL;
17/07/2023;1;292,0;;;6.880,9;1.442,2;4.358,2;8.524,2;655,6;3,8;3.200,0;;1.821,7;
17/07/2023;2;291,0;;;6.893,9;945,2;3.319,2;8.966,1;647,4;3,8;3.141,7;;1.939,8;
17/07/2023;3;180,0;;;6.910,9;746,5;3.277,2;8.996,6;643,9;3,7;3.137,9;;2.419,9;
17/07/2023;4;;;;6.913,9;653,3;3.021,4;8.767,3;638,8;3,7;3.140,8;;2.913,0;
@Codelaby
Codelaby / applebuyguide.swift
Last active October 30, 2023 10:42
Apple buy guide
import Foundation
extension Calendar {
func numberOfDaysBetween(_ from: Date, and to: Date) -> Int {
let fromDate = startOfDay(for: from) // <1>
let toDate = startOfDay(for: to) // <2>
let numberOfDays = dateComponents([.day], from: fromDate, to: toDate) // <3>
return numberOfDays.day!
}
@Codelaby
Codelaby / RomanConverter.swift
Last active October 16, 2023 15:52
Roman number conversor
import Foundation
class RomanConverter {
func romanToInt(_ s: String) -> Int {
let romanValues: [Character: Int] = [
"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000
]
@Codelaby
Codelaby / MetaphoneSpanish.swift
Created November 22, 2023 15:38
Metaphone Spanish
import Foundation
class MetaphoneSpanish {
private class func stringAt(_ string: String, _ start: Int, _ length: Int, _ list: [String]) -> Bool {
if start < 0 || start >= string.count {
return false
}
let substring = string[string.index(string.startIndex, offsetBy: start)..<string.index(string.startIndex, offsetBy: start+length)]
@Codelaby
Codelaby / Demo_LicenseAgree.swift
Created December 14, 2023 20:03
Demo_LicenseAgree
import SwiftUI
struct ViewOffsetKey: PreferenceKey {
typealias Value = CGFloat
static var defaultValue = CGFloat.zero
static func reduce(value: inout Value, nextValue: () -> Value) {
value += nextValue()
}
}
@Codelaby
Codelaby / Grouped_dates.swift
Last active December 18, 2023 18:37
Grouped dates
import Foundation
// Array de fechas como strings
let dateStrings = [
"2023-01-01 08:00:00",
"2023-01-01 10:30:00",
"2023-01-01 12:45:00",
"2023-01-01 08:00:00",
"2023-01-01 18:00:00",
"2023-01-01 10:30:00",