Skip to content

Instantly share code, notes, and snippets.

View alikaragoz's full-sized avatar
🍉
Tap Tap Tap

Ali Karagoz alikaragoz

🍉
Tap Tap Tap
View GitHub Profile
import SwiftUI
// Remember to download FontSettings.swift
struct WWDC24AnimatedTextView: View {
var text = "Hello, World!"
var animation: Animation = .easeInOut
var targetFontSize: CGFloat = 40
var minimumFontSize: CGFloat = 30
var targetFontWeight: Font.Weight = .semibold
//
import UIKit
import UniformTypeIdentifiers
protocol TokenTextFieldDelegate: AnyObject {
func tokenizedTextField(_ sender: TokenTextField, didTapTokenView: UIView)
}
final class TokenTextField: UITextView {
@afsal-backer
afsal-backer / gist:5fca21b5661d5bdf4e6d1e93311589a8
Last active March 15, 2024 15:41
Add media to Photos app so that my XCUITest can pick it
#!/bin/sh
# add_video_to_photos.sh
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PARENT_DIR="$(dirname "$SCRIPT_DIR")"
# Set the log file path
LOG_FILE="${PARENT_DIR}/add_video.log"
import SwiftUI
struct ChatGPTTextField: View {
// MARK: - State
/// State to hold our `TextField` query.
@State private var queryMessage: String = ""
/// Focus state for our `TextField`.
@zats
zats / ContentView.swift
Last active February 17, 2024 10:23
Internal SF Symbols
struct ContentView: View {
var body: some View {
let names = [
["appstore.app.dashed", "buildings.3d", "emoji.chicken.face"],
["person.text.rectangle.and.nfc", "secure.element", "laugh.bubble.tapback.2.he"],
["apple.news", "apple.podcasts.square.stack", "apple.slice"],
]
VStack(spacing: 20) {
Grid(horizontalSpacing: 20, verticalSpacing: 20) {
ForEach(names, id: \.self) { nameRow in
extension UIColor {
/// Blends this color into the specified color, as if this color was overlaid on top of the other at the specified alpha, but our result will instead be opaque. For instance if self was green, and we passed white and 0.1 alpha/opacity, the result would be a light, faded green.
///
/// - Note: This process is also called alpha compositing.
func blend(intoColor otherColor: UIColor, atOpacity alpha: CGFloat) -> UIColor {
let sourceRGB = rgb
let otherRGB = otherColor.rgb
return UIColor(
red: (sourceRGB.red * alpha) + (otherRGB.red * (1.0 - alpha)),
@jasdev
jasdev / ScrimLoader.swift
Last active April 19, 2024 03:47
Rough sketch of Arc’s scrim loading view.
import SwiftUI
/**
### Exercises for the viewer
- Phase interrupt handling.
- Use Swift concurrency.
- Color scheme awareness.
- Rework animations to be more spring-like à la what shipped in `0.90.0`.
@miticollo
miticollo / How-to-build-frida-server-for-ios.md
Last active June 5, 2024 11:24
How to build frida server for iOS jailbroken devices

Here, I'll show you how to compile Frida for both rootfull and rootless jailbreaks.

TL;DR

On Dopamine/Fugu15 Max or palera1n you can add my repo (open the link in your favorite browser on your jailbroken iDevice).

The DEBs you will install are build using the following instructions.

Update 2024-02-29

@nicklockwood
nicklockwood / CodableVersioning.swift
Last active January 29, 2024 11:31
Example demonstrating how to use versioning for Codable structs
// This gist demonstrates how you can implement versioning for a Codable struct to support loading
// old serialized data after changing the structure. Notable features of this solution:
//
// * No need to make new properties optional, or to perform post-processing on the struct after
// loading in ordeer to populate missing values
// * No need to change the call site - from the outside this struct behaves just the same
// as if we had implemented codable directly in the normal way.
// * Versioning can be applied individually to parents or leaves in a larger tree of
// structs without affecting the other elements
// * This approach will work even if the original struct was not designed with versioning in mind
@prachigauriar
prachigauriar / Slider+LogarithmicScale.swift
Last active April 11, 2024 16:26
SwiftUI Slider with Logarithmic Scale
extension Binding where Value == Double {
/// Returns a new version of the binding that scales the value logarithmically using the specified base. That is,
/// when getting the value, `log_b(value)` is returned; when setting it, the new value is `pow(base, newValue)`.
///
/// - Parameter base: The base to use.
func logarithmic(base: Double = 10) -> Binding<Double> {
Binding(
get: {
log10(self.wrappedValue) / log10(base)
},