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
// | |
// Created by Sami Samhuri on 2024-06-26. | |
// | |
import Foundation | |
final class SendableWrapper<T>: @unchecked Sendable { | |
private var unsafeValue: T | |
private let lock = NSLock() |
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 AVFoundation | |
/* | |
* In Swift 6 it’s not currently possible to directly load tracks from an AVAsset using a method like | |
* AVAsset.loadTracks(withMediaType:) from an actor-isolated context, because AVAssetTrack isn’t Sendable. Given | |
* that many AVFoundation types are not sendable / thread-safe it’s tempting to use an actor to work with | |
* compositions and that currently requires some work-arounds that shouldn’t be necessary and may not be obvious | |
* to everyone. | |
*/ |
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
final class SendableWrapper<T>: @unchecked Sendable { | |
private var unsafeValue: T | |
private let lock = NSLock() | |
var value: T { | |
get { | |
lock.withLock { unsafeValue } | |
} | |
set { |
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 AVFoundation | |
/** | |
* AVAssetExportSession is initialized with an AVComposition, and that composition and all of its constituent | |
* components are not sendable. Because `composition` is isolated to the main actor here, the call to the | |
* non-isolated method `export(to:as:)` sends it across an isolation region and that is unsafe. | |
*/ | |
@MainActor | |
class UnsafeMovieExporter { | |
let composition = AVMutableComposition() |
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 AVFoundation | |
import Combine | |
import OSLog | |
private let log = Logger.forType(MovieExportSession.self) | |
actor MovieExportSession { | |
let composition: AVComposition | |
let audioMix: AVAudioMix? |
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 'json' | |
require 'logger' | |
require 'net/http' | |
require 'stringio' | |
require 'zlib' | |
module Pronto | |
# Logs messages to Honeybadger's events API (Insights). The logger buffers messages and sends | |
# them to the API in batches. The logs are currently not structured and are sent as plain text, | |
# but if/when we actually move off of Papertrail then we can consider sending structured logs as |
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 Anonymizer | |
include ActiveSupport::Benchmarkable | |
attr_reader :factory_names, :callbacks | |
def initialize(factory_names = nil, callbacks = {}) | |
raise ArgumentError.new("You must be in development to use the anonymizer") unless Rails.env.development? | |
require Rails.root.join("spec/factories") unless FactoryBot.factories.count > 0 | |
@factory_names = [*factory_names].compact.map(&:to_sym) |
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 EventKit | |
import Foundation | |
import ObjectiveC.runtime | |
func logIvarList(obj: NSObject) { | |
var count: UInt32 = 0 | |
if let ivars = class_copyIvarList(type(of: obj), &count) { | |
for i in 0..<Int(count) { | |
let ivar = ivars[i] | |
let name = ivar_getName(ivar).map(String.init(cString:)) ?? "Unknown" |
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
// | |
// AssetFetcher.swift | |
// DailyDrip | |
// | |
// Created by Sami Samhuri on 2022-11-06. | |
// | |
import Foundation | |
import Photos |