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 SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
VStack { | |
Image(systemName: "globe") | |
.imageScale(.large) | |
.foregroundStyle(.tint) | |
Text("Hello, world!") |
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 { | |
var body: some View { | |
VStack { | |
Text("Hello, world!") | |
.frame(maxWidth: .infinity, maxHeight: .infinity) | |
ResizableTextView() | |
.border(.red) | |
} |
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 SWBShared2 | |
import Metal | |
import AppKit | |
import CoreImage | |
import CoreGraphics | |
import QuartzCore | |
@globalActor | |
public struct CALayerToMetalRendererActor { |
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); | |
NewerOlder