Skip to content

Instantly share code, notes, and snippets.

@nmbr73
nmbr73 / TobiType.swift
Last active November 2, 2022 00:04
A nice text effect implemented in SwiftUI by Tobias @Dunkeeel Dunkel.
//
// TobiType.swift
//
// https://twitter.com/dunkeeel/status/1587206501004939264?s=61&t=B4d_UGPw9A9ZN3A894q5yQ
import SwiftUI
struct TobiType: View {
struct SingleLetter: View {
@nmbr73
nmbr73 / 100DaysOfSwitfUI - Day 35 - Edutainment App.swift
Created October 5, 2022 13:42
This is the 'Education' part only - it's a mess already and so I did not go down the 'Entertainment' route.
//
// ContentView.swift
// Edut(r)ainMe - Day35
//
// Created by mbr73 on 04.10.22.
//
import SwiftUI
struct Question {
@nmbr73
nmbr73 / 100DaysOfSwitfUI - Day 25.swift
Created September 17, 2022 23:52
This code is a total disaster ... preserved here as a cautionary example - hope to be able to create a way better solution soon.
//
// ContentView.swift
// RockPaperScissors
//
// Created by nmbr73 on 17.09.22.
//
import SwiftUI
//
// ContentView.swift
// Conversion
//
// Created by nmbr73 on 07.09.22.
//
import SwiftUI
struct ContentView: View {
enum IntegerSqrtError : Error {
case outOfBounds, noRoot
}
func isqrt(_ n: Int) throws -> Int {
if n < 1 || n > 10_000 {
throw IntegerSqrtError.outOfBounds
}
@nmbr73
nmbr73 / 100DaysOfSwitfUI - Day 14 - Checkpoint 9.swift
Last active September 28, 2022 09:10
Day 14, Checkpoint 9 of #100DaysOfSwiftUI ... where @twostraws provided some excellent content again! #HACKINGWITHSWIFT https://www.hackingwithswift.com/quick-start/beginners/checkpoint-9
func f(_ array: [Int]? ) -> Int {
return array?.randomElement() ?? Int.random(in: 1...100)
}
f(nil)
f([Int]())
f([-1,-2,-3])
@nmbr73
nmbr73 / 100DaysOfSwiftUI - Day 14 - Optionals.swift
Last active October 5, 2022 09:19
Accessing optionals ... or: What happens when you want to avoid `if (...!=NULL)` in your language 😜
// --------------------------------------------------------------------------
// Summary of the (as always) excelent content
// of https://www.hackingwithswift.com/100/swiftui/14
// by #HACKINGWITHSWIFT's Paul @twostraws Hudson.
// --------------------------------------------------------------------------
enum BadCaptain : Error {
case noGood
}
@nmbr73
nmbr73 / 100DaysOfSwitfUI - Day 13 - Checkpoint 8.swift
Last active September 28, 2022 09:11
Day 13, Checkpoint 8 of #100DaysOfSwiftUI ... thanks @twostraws - I really enjoy the course so far!
/// Any kind of building on the estate market.
///
protocol Building {
/// Number of rooms the building has.
///
/// Note that the numebr of rooms can't change heavy construction work.
var rooms: Int { get }
@nmbr73
nmbr73 / 100DaysOfSwitfUI - Day 12 - Checkpoint 7.swift
Last active September 28, 2022 09:12
Day 12, Checkpoint 7 of #100DaysOfSwiftUI ... nothing special here, I think ... ?!?
class Animal {
let legs = 4
}
class Dog: Animal {
func speak() {
@nmbr73
nmbr73 / 100DaysOfSwitfUI - Day 6 - Checkpoint 3.swift
Last active December 7, 2022 22:41
Wanted to make use of what we learned about switch statements and arrays and such in #100DaysOfSwiftUI. So here to come my 6 solutions for 'Checkpoint 3' ...
// Solution 1: Straightforward, I guess this is the standard way to tackle the task?!?
// Note: The order in which the conditions are checked is crucial - you see why?!?
for i in 1...100 {
if i.isMultiple(of: 3) && i.isMultiple(of: 5) {
print("FizzBuzz")
} else if i.isMultiple(of: 3) {
print("Fizz")