This file contains hidden or 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
private var duration: CMTime? { | |
guard let timeComponents = rssEpisode.iTunes.duration?.split(separator: ":").reversed(), | |
timeComponents.count <= 3 | |
else { return CMTime.zero } | |
var seconds = 0 | |
for (position, value) in timeComponents.enumerated() { | |
guard let value = Int(value) else { return CMTime.zero } | |
var multiplier = 1 | |
for _ in 0..<position { multiplier *= 60 } |
This file contains hidden or 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 GRDB | |
import Testing | |
@testable import PodHaven | |
@Suite("of Queue repo tests") | |
actor QueueTests { | |
private let repo: Repo | |
private let podcast: Podcast |
This file contains hidden or 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
// MARK: - Queue Management | |
func dequeue(_ episodeID: Int64) async throws { | |
try await appDB.db.write { db in | |
guard let oldPosition = try _fetchOldPosition(db, for: episodeID) else { | |
return | |
} | |
try _moveInQueue(db, episodeID: episodeID, from: oldPosition, to: Int.max) | |
try Episode.filter(id: episodeID) |
This file contains hidden or 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
protocol StatusObservable: NSObject, Sendable { | |
associatedtype Status: Equatable, Sendable | |
var status: Status { get } | |
var error: Error? { get } | |
} | |
extension AVPlayer: @retroactive Sendable {} | |
extension AVPlayer: StatusObservable { | |
typealias Status = AVPlayer.Status | |
} |
This file contains hidden or 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 HTMLText: View { | |
let html: String | |
var customColor: Color = .primary | |
var font: Font = .body | |
var body: some View { | |
if let data = html.data(using: .utf8), | |
let nsAttributedString = try? NSMutableAttributedString( |
This file contains hidden or 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
// Copyright Justin Bishop, 2024 | |
import Foundation | |
import Testing | |
public actor Fulfillment { | |
private var _fulfilled: Bool = false | |
public func callAsFunction() { | |
_fulfilled = true | |
} |
This file contains hidden or 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 Fulfillment { | |
var count: Int = 0 | |
func callAsFunction(count: Int = 1) { | |
self.count += 1 | |
} | |
} | |
func expectation( | |
_ comment: Comment, | |
timeout: TimeInterval = 0.1, |
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'set' | |
def parse(filename) | |
if filename.start_with?('clip') | |
return filename.match(/^clip-(\d+)-(\d+)-(\d+)\s+(\d+);(\d+);(\d+)/).captures | |
else | |
return filename.match(/^(\d+)-(\d+)-(\d+)\s+(\d+)\.(\d+)\.(\d+)/).captures | |
end |
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'set' | |
files = Dir.glob('**/*.ARW') + Dir.glob('**/*.RAF') | |
files.each { |old_file| | |
new_file = "#{File.join(File.dirname(old_file), File.basename(old_file, File.extname(old_file)))}.heic" | |
if File.exist?(new_file) | |
puts "Deleting #{old_file}" | |
File.delete(old_file) |
This file contains hidden or 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
require 'sinatra' | |
get '/long_process' do | |
child_pid = Process.fork do | |
# hard work is done here... | |
sleep 10 | |
Process.exit | |
end | |
NewerOlder