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 PhotosUI | |
import SwiftUI | |
// Attempt to replicate the behaviour of the photos picker with the text input field and keyboard area in the iOS 18 Messages app. | |
struct MessagesPhotosPickerView: View { | |
@State private var text: String = "" | |
@State private var showPhotosPicker: Bool = false | |
@State private var photoItem: PhotosPickerItem? | |
var body: some 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
// | |
// MatrixEffect.swift | |
// | |
// Created by J.T on 9/8/24. | |
// | |
import SwiftUI | |
import Combine | |
class MatrixEffectModel: ObservableObject { |
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
addEventListener('fetch', (event) => { | |
event.respondWith(handleRequest(event.request)); | |
}); | |
async function handleRequest(request) { | |
const url = new URL(request.url); | |
const { pathname, search } = url; | |
var newPathname = pathname; | |
if (pathname.startsWith('/docs')) { | |
newPathname = pathname.replace('/docs', ''); |
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
// swift-tools-version: 5.7 | |
import PackageDescription | |
let package = Package( | |
name: "ratioapp", | |
platforms: [ | |
.iOS("16.6") | |
], | |
products: [ |
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 Foundation | |
import XCTest | |
// 1. mocking url session with URLProtocol | |
// this approach allows us to intercept the network request. | |
// Steps: | |
// i. subclass URLProtocol | |
// ii. implement these methods from the prototol canInit, canonicalRequest, startLoading, stopLoading. | |
// iii. add implementation to startLoading based on a requestHandler closure. | |
// iv. send received response to the client: URLProtocolClient |
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 | |
import SensitiveContentAnalysis | |
struct ContentView: View { | |
enum AnalysisState { | |
case notStarted | |
case analyzing | |
case isSensitive | |
case notSensitive |
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
// Define a Category object type that has a name and a color | |
class Category() : RealmObject { | |
@PrimaryKey | |
var _id: ObjectId = ObjectId.create() | |
var name: String | |
var color: String | |
constructor(name: String, color: String) : this() { | |
this.name = name | |
this.color = color | |
} |
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 ComposableArchitecture | |
import SwiftUI | |
let appReducer: Reducer<AppState, AppAction, AppEnvironment> = Reducer.combine( | |
onboardingReducer | |
.optional() | |
.pullback( | |
state: \AppState.onboarding, | |
action: /AppAction.onboarding, | |
environment: { _ in OnboardingEnvironment() } |
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 OverviewView: View { | |
private let threshold: CGFloat = 100.0 | |
@State private var showModal = false | |
var body: some View { | |
GeometryReader { geometry in | |
ScrollView(showsIndicators: false) { | |
VStack { |
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 pandas as pd | |
from sklearn.tree import DecisionTreeClassifier | |
music_data = pd.read_csv('music.csv') | |
X = music_data.drop(columns=['genre']) | |
y = music_data['genre'] | |
model = DecisionTreeClassifier() | |
model.fit(X, y) |
NewerOlder