Skip to content

Instantly share code, notes, and snippets.

View cwalo's full-sized avatar

Corey Walo cwalo

View GitHub Profile
@shaps80
shaps80 / AVPlayer+Scrubbing.swift
Last active August 20, 2025 19:08
Enables smooth frame-by-frame scrubbing (in both directions) – similar to Apple's applications.
public enum Direction {
case forward
case backward
}
internal var player: AVPlayer?
private var isSeekInProgress = false
private var chaseTime = kCMTimeZero
private var preferredFrameRate: Float = 23.98
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active September 20, 2025 20:31
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

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

@cwalo
cwalo / things_you_should_know.md
Last active June 29, 2020 14:59
Things you should know, but might forget...

Things you should know, but might forget...

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.

--

Swift

--

The Swift Programming Language

Swift Forums

@AliSoftware
AliSoftware / Bindings.swift
Last active August 5, 2025 14:50
Re-implementation of @binding and @State (from SwiftUI) myself to better understand it
/*:
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
@knandersen
knandersen / morphagene_ableton.py
Last active July 19, 2025 19:49 — forked from ferrihydrite/morphagene_audacity.py
Allows you to use Ableton projects and exports as reels for the Make Noise Morphagene eurorack module. Since a few people have found the script not working or difficulty getting python to work, I have created a web-based tool: https://knandersen.github.io/morphaweb/
#!/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
@doroshenko
doroshenko / swiftlint.sh
Created February 22, 2020 22:50
An incremental linting script for SwiftLint
#!/bin/bash
START_DATE=$(date +"%s")
SWIFTLINT="${PODS_ROOT}/SwiftLint/swiftlint"
EXIT_CODE=0
# Usage description
function usage() {
if [ -n "$1" ]; then
@nurtugan
nurtugan / DiffableDataSource-DeleteItem.swift
Last active July 17, 2024 20:28
Example of Deleting Item from Diffable Data Source
@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)
@WunDaii
WunDaii / BarcodeScannerViewRepresentable.swift
Last active June 14, 2024 19:40
Barcode Scanner Camera View for SwiftUI
//
// BarcodeScannerViewRepresentable.swift
//
// Created by Daven Gomes on 28/08/2020.
//
import SwiftUI
import AVFoundation
import UIKit
@helje5
helje5 / servedocc.swift
Last active May 12, 2025 20:20
Small Swift Script to serve `.doccarchive`s to the browser
#!/usr/bin/swift sh
import MacroExpress // @Macro-swift
// MARK: - Parse Commandline Arguments & Usage
func usage() {
let tool = path.basename(process.argv.first ?? "servedocc")
print(
"""
@saagarjha
saagarjha / library_injector.cpp
Last active August 13, 2025 22:55
Load a library into newly spawned processes (using DYLD_INSERT_LIBRARIES and EndpointSecurity)
// 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>