Skip to content

Instantly share code, notes, and snippets.

View profh's full-sized avatar

Larry Heimann (Prof. H) profh

  • Carnegie Mellon University
  • Pittsburgh, PA
  • X @profh
View GitHub Profile
@profh
profh / repos_async.swift
Created October 29, 2024 00:00
Repos_Async
import SwiftUI
import Foundation
struct Repositories: Decodable {
let repos: [Repository]
enum CodingKeys : String, CodingKey {
case repos = "items"
}
}
@profh
profh / repos_async_part_2.swift
Created October 29, 2024 01:13
Repos_Async_Part_2
import SwiftUI
import Foundation
struct Repository: Decodable {
let name: String
let htmlURL: String
enum CodingKeys : String, CodingKey {
case name
case htmlURL = "html_url"
@profh
profh / credit_card.rb
Created March 20, 2025 21:28
Credit Card Model
# where we do the main work of creating a credit card...
class CreditCard
VALID_TYPES = [
CreditCardType.new("AMEX", /^3(4|7)\d{13}$/),
CreditCardType.new("DCCB", /^30[0-5]\d{11}$/),
CreditCardType.new("DISC", /^6(011|5\d\d)\d{12}$/),
CreditCardType.new("MC", /^5[1-5]\d{14}$/),
CreditCardType.new("VISA", /^4\d{12}(\d{3})?$/)
]
@profh
profh / stopwatch_stub.ts
Created September 1, 2025 21:46
Stub for the React Native stopwatch app
import React, { useState, useRef } from 'react';
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
export default function App() {
// Set up useState and useRef here...
// Constants for formatting time here...
@profh
profh / .gitignore
Created September 18, 2025 00:13 — forked from aksamitsah/.gitignore
.gitignore File for Xcode 16 Projects with Comprehensive Comments
# ========================
# .gitignore for Xcode 16
# ========================
# Tags: Xcode, gitignore, Swift, iOS, macOS, Development
# A comprehensive .gitignore file tailored for Xcode 16 projects.
# Excludes auto-generated, system-specific, and unnecessary files.
# Suitable for Swift, Objective-C, CocoaPods, Carthage, and more.
# --- macOS Files ---
# Ignore system-generated files specific to macOS.
@profh
profh / combine_search_filter.swift
Created October 30, 2025 02:16
Combine_Movie_Search_Filter
import Combine
import Foundation
// MARK: - Movie Database
let movies = [
"The Matrix",
"The Godfather",
"The Dark Knight",
"Monty Python and the Holy Grail",
"Forrest Gump",
@profh
profh / balloonpop_solutions.swift
Created November 18, 2025 15:29
BalloonPop_Solutions
// TODO: TASK 1 - Handle user touches to detect balloon pops
/* Handle touch-down events during active gameplay
**Note**: This demonstrates several key concepts:
1. Converting touch coordinates between different coordinate systems
2. Hit-testing to find which nodes were touched
3. Filtering nodes by their 'name' property
4. Early exit patterns with guard statements
- Parameters: