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 / 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 / .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 / 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 / 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 / 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 / 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 / remove_friend_msg.html.erb
Last active April 15, 2024 22:11
A mailer template for removing a friend as a Klingon would.
<p><%= @friend.full_name %>,</p>
<p>I had previously listed you as a friend; however, I am reminded of the old Klingon proverb:<br /><br />
QaghmeylIj tIchID, yIyoH <br />
<em>(Have the courage to admit your mistakes.)</em><br />
</p>
<p>Clearly it was a mistake to make you a friend. I admit this error in judgment and hereby remove you from my friend list.</p>
@profh
profh / new_friend_msg.text.erb
Last active April 15, 2024 22:12
For sending a friend message as a Klingon would.
nuqneH <%= @friend.nickname %>,
I've just listed you as one of my friends. I am sure you are deeply honored, as you should be.
Remember the Klingon proverb regarding friends:
may'Daq jaHDI' SuvwI' juppu'Daj lonbe'
(When a warrior goes to a battle, he does not abandon his friends.)
Don't forget about me when you go into battle -- I will not forget you.
@profh
profh / combine_exercise.swift
Last active November 5, 2023 13:13
Combine Exercise Solution
// One solution to the class exercise
import UIKit
import Combine
import PlaygroundSupport
// This playground will execute indefinetly in order to give our
// async operations enough time to execute.
PlaygroundPage.current.needsIndefiniteExecution = true
@profh
profh / combine_demo.swift
Created October 31, 2023 11:23
Combine Demo
// h/t to @JohnSundell (https://www.swiftbysundell.com/)
import UIKit
import Combine
import PlaygroundSupport
// This playground will execute indefinetly in order to give our
// async operations enough time to execute.
PlaygroundPage.current.needsIndefiniteExecution = true