This is a curated list of reference material that anyone who develops in the Apple domain will hopefully find helpful. Most items are things I have used and can vouch for.
--
--
import Foundation | |
struct ShellCommand { | |
@discardableResult | |
static func stream(_ command: String) -> Int32 { | |
let outputPipe = Pipe() | |
let task = self.createProcess([command], outputPipe) | |
outputPipe.fileHandleForReading.readabilityHandler = { fileHandle in self.streamOutput(outputPipe, fileHandle) } | |
do { |
// MARK: - TCAView | |
public protocol TCAView: View where Body == WithViewStore<ScopedState, ScopedAction, Content> { | |
associatedtype ViewState | |
associatedtype ViewAction | |
associatedtype ScopedState | |
associatedtype ScopedAction | |
associatedtype Content | |
/// A type-erased task that you can store in a collection | |
/// to allow you to cancel at a later date. | |
/// | |
/// Upon deinit of the task, the task will be cancelled | |
/// automatically. Similar to Combine's AnyCancellable. | |
final class AnyTask { | |
/// Call this cancellation block to cancel the task manually. | |
let cancel: () -> Void | |
/// Checks whether the task is cancelled. |
// To compile: clang++ -arch x86_64 -arch arm64 -std=c++20 library_injector.cpp -lbsm -lEndpointSecurity -o library_injector, | |
// then codesign with com.apple.developer.endpoint-security.client and run the | |
// program as root. | |
#include <EndpointSecurity/EndpointSecurity.h> | |
#include <algorithm> | |
#include <array> | |
#include <bsm/libbsm.h> | |
#include <cstddef> | |
#include <cstdint> |
// | |
// BarcodeScannerViewRepresentable.swift | |
// | |
// Created by Daven Gomes on 28/08/2020. | |
// | |
import SwiftUI | |
import AVFoundation | |
import UIKit |
@objc | |
private func handleGet(_ sender: UIButton) { | |
var superview = sender.superview | |
while superview != nil { | |
if let cell = superview as? UICollectionViewCell { | |
guard let indexPath = collectionView.indexPath(for: cell), | |
let objectIClickedOnto = diffableDataSource.itemIdentifier(for: indexPath) else { return } | |
var snapshot = diffableDataSource.snapshot() | |
snapshot.deleteItems([objectIClickedOnto]) | |
diffableDataSource.apply(snapshot) |
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
""" | |
USAGE: | |
morphagene_ableton.py -w <inputwavfile> -l <inputlabels> -o <outputfile>' | |
Instructions in Ableton: | |
Insert locators as splice markers in your project (Create > Add Locator) | |
Export Audio/Video with | |
Sample Rate: 48000 Hz |
/*: | |
This is a concept re-implementation of the @Binding and @State property wrappers from SwiftUI | |
The only purpose of this code is to implement those wrappers myself | |
just to understand how they work internally and why they are needed, | |
⚠️ This is not supposed to be a reference implementation nor cover all | |
subtleties of the real Binding and State types. | |
The only purpose of this playground is to show how re-implementing | |
them myself has helped me understand the whole thing better |
This is a curated list of reference material that anyone who develops in the Apple domain will hopefully find helpful. Most items are things I have used and can vouch for.
--
--
The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).
My take-aways are:
You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.
Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse