This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// programmatic view controller | |
/* | |
usage: | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let newViewController = NewViewController(string: "Hello") | |
addChildViewController(newViewController, in: view) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// matrixmultiply.swift | |
// AISafety | |
// | |
// Created by Andrew Zheng (github.com/aheze) on 4/12/24. | |
// Copyright © 2024 Andrew Zheng. All rights reserved. | |
// | |
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Combine | |
import SwiftUI | |
class CoverFlowViewModel: ObservableObject { | |
@Published var items: [CoverFlowItem] = Theme.availableThemes.map { | |
CoverFlowItem( | |
id: $0.name, | |
title: $0.name, | |
color: $0.color, | |
needsPro: $0.needsPro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
let imageNames = ["A", "B", "C"] | |
var body: some View { | |
ScrollView { | |
VStack { | |
ForEach(imageNames, id: \.self) { imageName in | |
PostView(imageName: imageName) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TimeElapsed: CustomStringConvertible { | |
private let startTime: CFAbsoluteTime | |
private var endTime: CFAbsoluteTime? | |
init() { | |
startTime = CFAbsoluteTimeGetCurrent() | |
} | |
var description: String { | |
time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct GraphDomains { | |
public var xDomain: ClosedRange<Double> | |
public var yDomain: ClosedRange<Double> | |
} | |
func getStride(domains: GraphDomains) -> (xStride: [Double], yStride: [Double])? { | |
guard let boundsSize else { | |
return nil | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Testing function. | |
// Return true on success and false on fail. | |
bool testRender(int lineLength, const char input[], const char expectedOutput[], int expectedReturnValue) { | |
istringstream iss(input); | |
ostringstream oss; | |
ostringstream dummy; | |
streambuf *origCout = cout.rdbuf(dummy.rdbuf()); | |
int retval = render(lineLength, iss, oss); | |
cout.rdbuf(origCout); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I just finished interning at Apple so I wrote this up. It's kind of long, but I hope it clears some stuff up about LeetCode and Big Tech. I also posted this on Substack [with images](https://aheze.substack.com/p/getting-a-job-at-apple-without-going) if it's easier to read. Here goes! | |
- Learning To Code | |
- Prior Job Experience | |
- How Apple Found Me | |
- The Interview Process | |
- The Internship | |
- Big Tech | |
- College |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - SceneDelegate | |
class SceneDelegate: UIResponder, UIWindowSceneDelegate { | |
var window: UIWindow? | |
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
let navigationController = UINavigationController(navigationBarClass: NavigationBar.self, toolbarClass: nil) | |
(navigationController.navigationBar as! NavigationBar).preferredHeight = 88 | |
navigationController.setViewControllers([ViewController()], animated: false) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct OverflowLayout: Layout { | |
var spacing = CGFloat(10) | |
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize { | |
let containerWidth = proposal.replacingUnspecifiedDimensions().width | |
let sizes = subviews.map { $0.sizeThatFits(.unspecified) } | |
return layout(sizes: sizes, containerWidth: containerWidth).size | |
} | |
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) { |
NewerOlder