Skip to content

Instantly share code, notes, and snippets.

View pitt500's full-sized avatar

Pedro Rojas pitt500

View GitHub Profile
@pitt500
pitt500 / CustomRandomNumberGenerator.swift
Created March 6, 2025 15:05
CustomRandomNumberGenerator created for my video https://youtu.be/Z4NeyjUTqgg
import Foundation
struct CustomRandomNumberGenerator: RandomNumberGenerator {
private var state: UInt64 = 0
private let multiplier: UInt64 = 6364136223846793005
private let increment: UInt64 = 1442695040888963407
private let modulus: UInt64 = UInt64.max // 2^64 - 1
init(seed: UInt64) {
state = seed
import Foundation
func benchmarkStringConversion() {
let dynamicString: String = "This is a string"
let iterations = 100_000
var dynamicResult = 0
let startDynamic = CFAbsoluteTimeGetCurrent()
for _ in 0..<iterations {
let utf8Data = Array(dynamicString.utf8)
import SwiftUI
import SensitiveContentAnalysis
struct ContentView: View {
enum AnalysisState {
case notStarted
case analyzing
case isSensitive
case notSensitive
import SwiftUI
struct ContentView: View {
@State private var sliderValue: Double = 0.0
@State private var backgroundColor: Color = .red
let colors: [Color] = [.red, .orange, .yellow, .green, .blue, .purple, .pink, .mint, .indigo, .teal, .cyan, .brown, .black]
var body: some View {
ZStack {
@pitt500
pitt500 / ResultBuilderDemo.swift
Last active February 27, 2024 03:01
Demo explaining Result Builders, check out this link for more context: https://youtu.be/kZ7JPFUVv1w
// Created by Pedro Rojas (aka Pitt)
// Link to learn more about this code: https://youtu.be/kZ7JPFUVv1w
import SwiftUI
import WebKit
@resultBuilder
struct HtmlBuilder {
static func buildBlock() -> [HtmlTag] {
[]
import UIKit
// 1. Import SwiftUI
import SwiftUI
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// 2. Initialize SwiftUI View
@pitt500
pitt500 / TCA_CounterDemo.swift
Created September 17, 2022 22:00
More context about this demo here: https://youtu.be/SfFDj6qT-xg
import SwiftUI
import ComposableArchitecture
struct State: Equatable {
var counter = 0
}
enum Action: Equatable {
case increaseCounter
//
// ContentView.swift
// DemoSheet
//
// Created by Pedro Rojas on 20/08/22.
//
import SwiftUI
struct ContentView: View {
@pitt500
pitt500 / TCA_README_ES.md
Last active March 5, 2024 14:55
An Spanish translation of The Composable Architecture's README.md

The Composable Architecture

CI

The Composable Architecture (o simplemente TCA) es una librería para construir aplicaciones de una manera consistente y entendible, teniendo en mente composición, pruebas y ergonomía. Puede ser utilizada en SwiftUI, UIKit, y en cualquier plataforma de Apple (iOS, macOS, tvOS, y watchOS).

  • [¿Qué es *The Composable A
@pitt500
pitt500 / TodoList+FixedSorting.swift
Last active August 3, 2022 14:46
For more context about this algorithm, check out this video: https://youtu.be/M3eJIo9h0fg
import SwiftUI
struct Todo: Identifiable {
let id: UUID
var title = "Untitled"
var isComplete = false
static var sample: [Todo] {
[