Skip to content

Instantly share code, notes, and snippets.

@siracusa
siracusa / gist:bbc3bacb5bb0a40ade1bbda48d18269a
Created June 9, 2026 11:05
yt-dlp WWDC download failures
% yt-dlp -f 9639+audio-atmos-eac3-640-English https://events-delivery.apple.com/0601eknundukyswuegvjcidvurtztakr/vod_main_vdhwwrygnmzydhppixlrqwduiqffztdw/vod_main_vdhwwrygnmzydhppixlrqwduiqffztdw.m3u8
[generic] Extracting URL: https://events-delivery.apple.com/0601eknundukyswuegvjcidvurtztakr/vod_main_vdhwwrygnmzydhppixlrq...xlrqwduiqffztdw.m3u8
[generic] vod_main_vdhwwrygnmzydhppixlrqwduiqffztdw: Downloading webpage
[generic] vod_main_vdhwwrygnmzydhppixlrqwduiqffztdw: Downloading m3u8 information
[generic] vod_main_vdhwwrygnmzydhppixlrqwduiqffztdw: Checking m3u8 live status
[info] vod_main_vdhwwrygnmzydhppixlrqwduiqffztdw: Downloading 1 format(s): 9639+audio-atmos-eac3-640-English
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 762
[download] Destination: vod_main_vdhwwrygnmzydhppixlrqwduiqffztdw [vod_main_vdhwwrygnmzydhppixlrqwduiqffztdw].f9639.mp4
[download] 2.1% of ~ 7.08GiB at 28.42MiB/s ETA 03:32 (frag 17/762)[download] Got error: 1 bytes read, 9728499 more expected. Retrying (
@siracusa
siracusa / downie.log
Created June 8, 2026 19:27
WWDC 2026 Keynote download failure in Downie
Starting download [980dd516f7639fb5c4be333fac4c2ad5] for <XUHLSQuality>: [AAC English - audio-atmos-eac3-640] -> https://events-delivery.apple.com/0601eknundukyswuegvjcidvurtztakr/vod_main_vdhwwrygnmzydhppixlrqwduiqffztdw/audio_main_en_16ch_atmos_640/prog_index.m3u8:
- Number of chunks: 706 - 5 connections
- ["AAC", "English - audio-atmos-eac3-640"]
- direct file URL https://events-delivery.apple.com/0601eknundukyswuegvjcidvurtztakr/vod_main_vdhwwrygnmzydhppixlrqwduiqffztdw/audio_main_en_16ch_atmos_640/prog_index.m3u8
- request header fields ["Sec-Fetch-Dest": "video", "X-Playback-Session-Id": "C5B3F836-0C5C-48DF-A2BB-0623BB3FA7B3", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15", "Connection": "Keep-Alive", "Referer": "https://www.apple.com/apple-events/", "Origin": "https://www.apple.com", "Sec-Fetch-Site": "same-site", "Cookie": "s_fid=093903CAAEA2D914-011FDC14372ABDA6;s_sq=%5B%5BB%5D%5D;s_vi=[CS]v1|35138860052FA611-40001
@siracusa
siracusa / LoggerInterpolationMystery.swift
Created April 8, 2025 21:20
A Logger call with an interpolated value stops this code from compiling.
import OSLog
import Network
import Foundation
let logger = Logger(subsystem: "com.example.demo", category: "Default")
let connection = NWConnection(host: NWEndpoint.Host("time.apple.com"), port: 123, using: .udp)
// The line below fails to compile: Type of expression is ambiguous without a type annotation
connection.stateUpdateHandler = { state in
@siracusa
siracusa / TimeoutMe.swift
Created April 7, 2025 13:50
Adding a timeout to code like this is tricky…
// Assume Swift 6 language mode
import Network
import Foundation
print("Asking for the current time from an NTP server...")
do {
let now = try await currentTime()
print("Current time from NTP: \(now)")
@siracusa
siracusa / observer.swift
Last active June 17, 2024 16:47
Swift Concurrency Candidate
NSWorkspace.shared.notificationCenter.addObserver(
forName: NSWorkspace.didLaunchApplicationNotification,
object: nil, queue: nil, using: { [weak self] notification in
self?.doStuff()
})
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BreakpadProduct</key>
<string>VLC</string>
<key>BreakpadRequestComments</key>
<string>1</string>
<key>BreakpadURL</key>
<string>https://mac.crashes.videolan.org/reports</string>
@siracusa
siracusa / ObservableLazyWorkarounds.swift
Last active June 8, 2023 18:50
Possible workarounds for lazy properties in an @observable class
import Cocoa
import Observation
@Observable
class User {
@ObservationIgnored lazy var id : Int = {
return Int.random(in: 1...100)
}()
}
@siracusa
siracusa / ObservableLazy.swift
Created June 8, 2023 18:09
Lazy properties in an @observable class
import Cocoa
import Observation
//@Observable
class User {
// If @Observable is applied to this class, compilation
// of this property declaration fails with the error:
//
// 'lazy' cannot be used on a computed property
//
@siracusa
siracusa / SwiftUIIfModifier.swift
Created July 11, 2022 14:56
SwiftUI .if modifier
extension View {
@ViewBuilder
func `if`<Content: View>(_ conditional: Bool, @ViewBuilder content: (Self) -> Content) -> some View {
if conditional {
content(self)
}
else {
self
}
}

When creating and using a custom ButtonStyle for a SwiftUI button that changes its appearance based on the value of the configuration.isPressed property, that property sometimes get stuck with a "true" value, leaving the button to appear in its pressed state even when it is not being pressed. It stays stuck this way until the button is clicked again.

A sample project is attached. It's also in a public repo at https://github.com/siracusa/SwiftUIButtonIsPressedStateBug

To reproduce the bug:

  1. Build and launch the sample project. A window should appear showing a large button view with a green background and some white text that says "Hello".

  2. Click button view a few times and confirm that background color turns blue on mouse-down and switches back to green on mouse-up.