Skip to content

Instantly share code, notes, and snippets.

View pitt500's full-sized avatar

Pedro Rojas pitt500

View GitHub Profile
import UIKit
// 1. Import SwiftUI
import SwiftUI
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// 2. Initialize SwiftUI View
@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 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 {
import SwiftUI
import SensitiveContentAnalysis
struct ContentView: View {
enum AnalysisState {
case notStarted
case analyzing
case isSensitive
case notSensitive
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)
@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