Skip to content

Instantly share code, notes, and snippets.

View AndyQ's full-sized avatar

Andy Qua AndyQ

View GitHub Profile
@kbob
kbob / bubble_phi.pbsl.js
Last active June 17, 2025 19:38
Bubble Phi Pixelblaze shader
// Bubble Phi
// (Sounds like Boba Tea)
//
// Stream of rising bubbles with low discrepancy quasirandom hues
// https://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/#quasiperiodic_tiling
// Constants
// IPHI = (sqrt(5) - 1) / 2 // 1 / phi, the golden ratio
IPHI2 = [0.7548776662466927, 0.5698402909980532]
@twostraws
twostraws / SpriteKit-SwiftUI-Metaballs.swift
Created June 16, 2025 14:05
A 30-minute hack to recreate the "iBeer" effect using SpriteKit, SwiftUI, and metaballs.
//
// A 30-minute hack to recreate the "iBeer" effect using SpriteKit, SwiftUI, and metaballs.
// The effect is created by having hundreds of physics-enabled balls in a SpriteKit scene,
// all drawing nothing. These balls are then read back out by SwiftUI in a TimelineView, and
// drawn using blur and alpha threshold filters to make them appear to be a liquid.
// The SpriteKit scene then has its gravity changed dynamically using the accelerometer,
// meaning that the "liquid" splashes around as you tilt your phone.
//
// Created by Paul Hudson
// https://www.hackingwithswift.com/license
@samhenrigold
samhenrigold / _WWDC25 AI-ML Group Lab.md
Last active July 2, 2025 16:10
WWDC25 Machine Learning and AI Frameworks group lab

(Summary generated by ChatGPT based on the automatic transcription. Transcript is attached to this Gist)

Panelists:

  • Host: Shashank

  • Panelists: Michael, Erik, Richard, Ronan


Also, if you have a bug or a feature request, please go to bugreporter.apple.com. Today we want to focus on questions that will help the broader audience. So, please send us your questions using the Slido panel here in WebEx. Once our moderators approve the questions, they'll appear for everyone to up vote, so we can narrow in on the questions that are of most interest to all of you. So let's jump in. I'm going to claim moderator privilege and start with a couple of questions that I'm particularly interested in. So the first thing I would like to talk about to get the ball rolling is, I just want to ask each of you what your favorite new Swift UI API is this year. Summer, why don't you kick us off? All right, I'm gonna have to go with our new rich text editor. was a big labor of love for my team, and it was super fun, 'cause we got to work cross functionally with foundation, text kit, cortex, UAKit, app kit, everybody. Excellent. Nick, how about you? Uh, for me, this is definitely a safe area bar, kind of an
and definitely have the expertise to answer any questions that you have for us. So, to kick things off, in some of the design sessions, and keynote, and so, too, we were talking a little bit about the way in which liquid glass can really help with navigation, focus, in the UI, and there's some questions, just kind of, you know, can we expand on that? Can we elaborate a little bit on that notion? And I think maybe, Chabam, that might be a good one for you to take. Yeah, yeah, absolutely. So with liquid glass, you know, we really tried to clarify the navigation layer in our apps. So liquid glass introduces a single floating plane that acts as an navigation layer for your app. buttons in that floating pane sort of seamlessly morph in mitosis as you move between different sections of the app, and when you look at things like controls, controls can also temporarily lift into that glass steam. If you watch some of the design sessions, you know, we go into not overusing glass or not using glass on top of glass, but

(Summary generated by ChatGPT based on the automatic transcription. Transcript is attached to this Gist)

Q: What's the best approach to updating my app's UI for the new design?

A:

I think the best approach is to start from either the top down or the bottom up---however you perceive the hierarchy of your application. Focus on the big structural parts, since they tend to be most affected by the design and are often reflected in your code structure. Start there, then focus on the smaller elements.

Follow-up (Mohammed):

@samhenrigold
samhenrigold / q&a.md
Created June 11, 2025 02:07
WWDC25 Camera/Photos Group Lab Q&A

What’s the first class way to use PhotoKit to reimplement a high performance photo grid? We’ve been using a LazyVGrid and the photos caching manager, but are never able to hit the holy trinity (60hz, efficient memory footprint, minimal flashes of placeholder/empty cells)

A few things. It sounds like you're using the PHCachingImageManager already, which is definitely recommended.

One kind of specific note there—you want to use that to get media content delivered before you need to display it. So, for example, let's say you're showing a large grid of photos. You can be prefetching before and after, in expectation that the user's going to scroll. Or, if you're in a one-up situation, prefetching left and right so that you know the user is likely going to swipe, and you can quickly deliver those images to the screen and cache them.

Another thing you should really make sure you're doing is specifying the size you need for the grid size. For example, if your app supports showing a smaller grid

@ryanlintott
ryanlintott / View+ifAvailable.swift
Last active June 20, 2025 15:58
A conditional SwiftUI view extension that can be used to optionally apply view modifiers based on OS availability. Learn more about how it works here: https://youtu.be/mgplcrJh0K0?si=YNz0IVSiN-3myb08
import SwiftUI
extension View {
/// Applies the given transform or returns the untransformed view.
///
/// Useful for availability branching on view modifiers. Do not branch with any properties that may change during runtime as this will cause errors.
/// - Parameters:
/// - transform: The transform to apply to the source `View`.
/// - Returns: The view transformed by the transform.
@ViewBuilder
import SwiftUI
struct WaveformAnimation: View {
@State var waveformData: [CGFloat] = Array(repeating: 0, count: 40)
@State var startAnimation: Bool = false
@State var color: Color = Color(hex: "A28497")
var body: some View {
HStack(spacing: 4) {
ForEach(Array(waveformData.enumerated()), id: \.offset) { index, height in
@sophiateutschler
sophiateutschler / SmoothShadowModifier.swift
Created October 13, 2024 19:44
A SwiftUI view modifier to generate layered/smooth shadows
//
// MIT License
//
// Copyright (c) 2024 Sophiestication Software, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is