Skip to content

Instantly share code, notes, and snippets.

View bradhowes's full-sized avatar
🏠
Working from home

Brad Howes bradhowes

🏠
Working from home
View GitHub Profile
@bradhowes
bradhowes / gist:e4db684fa782f913d0454750bb103c72
Last active January 21, 2024 12:02
Using msmtp on macOS with iCloud
  • Install msmtp using brew install msmtp
  • Configure msmtp using the following:
# Set default values for all the accounts.
defaults
auth on
logfile ~/.maildir/msmtp.log
port 587
protocol smtp
@bradhowes
bradhowes / AUv3Controls-coverage.json
Last active March 30, 2024 13:34
AUv3Controls Coverage
{"schemaVersion":1,"label":"Coverage","message":"92.62%","color":"success"}
@bradhowes
bradhowes / Makefile
Created October 20, 2022 17:23
Code Coverage from Xcode via Make
# XCode scheme to build and test
SCHEME = Searching
# The sim to use when running tests
PLATFORM_IOS = iOS Simulator,name=iPhone SE (3rd generation)
# Coomand line options for xcodebuild that incorporate the above values
DEST = -project Searching.xcodeproj -scheme "$(SCHEME)" -destination platform="$(PLATFORM_IOS)"
# The pattern to use when matching lines from xcov output. The coverage total will be the average
@bradhowes
bradhowes / ghstatus.py
Last active December 19, 2023 17:26
Simple repo workflow status
#!/usr/bin/env python
import concurrent.futures
from dataclasses import dataclass
from github import Github
from termcolor import colored
from functools import partial
@dataclass
@bradhowes
bradhowes / SwiftPMBundleHandling.m
Last active March 18, 2022 12:17
Workarounds for Swift PM Bundle Handling
// When working properly, SWIFTPM_MODULE_BUNDLE is defined. At least on Xcode 13.2, this is not always the case with
// packages, especially when running tests. The code below was pulled from my SF2Lib Swift package. This package is
// used in my SoundFonts application. The workaround below handles two situations where SWIFTPM_MODULE_BUNDLE is not
// working right:
//
// 1. SWIFTPM_MODULE_BUNDLE not defined -- seems to be limited to unit tests in the SF2Lib package
// 2. SWIFTPM_MODULE_BUNDLE defined but throws exception -- seems to be limited to unit tests of a package that depends
// on SF2Lib package
//
@bradhowes
bradhowes / post-build.sh
Last active January 27, 2022 15:39
Simple script that is useful as a Build post-action to remove bogus embedded frameworks due to Swift packages.
#!/bin/bash
set -eu
echo "-- BEGIN post-build.sh"
function process # TOP EMBED
{
local TOP="${1}" EMBED="${2}"
cd "${CODESIGNING_FOLDER_PATH}/${TOP}"
@bradhowes
bradhowes / code_coverage.md
Created December 21, 2021 18:00
Github Action for Swift Code Coverage
  1. Create a Github action for your SwiftPM project.
  2. Add a step to build: swift build
  3. Add a step to run tests: swift test --enable-code-coverage
  4. Fetch coverage value (see below)
  5. Write coverage value to gist and generate badge from it

For step #4, we need to do some sleuthing and digging around into artifacts created by the Swift toolchain. First, we need to find the location of the XCTest bundle that step #3 generated and save it in an environment variable:

@bradhowes
bradhowes / Arithmetic.swift
Created November 24, 2021 22:07
Math expression parsing using Point-Free's swift-parsing library. Expands on code found in the infix-operator branch.
import Parsing
import XCTest
import Foundation
#if canImport(Darwin)
import Darwin.C
#elseif canImport(Glibc)
import Glibc
#endif
@bradhowes
bradhowes / sawsbuck.swift
Last active November 18, 2021 15:55
Swift Expression Parsing
// Demo using https://github.com/nicklockwood/Expression to parse
// https://www.wolframalpha.com/input/?i=Sawsbuck+Winter+Form%E2%80%90like+curve
import Foundation
import Expression
let Xt = "((-2/9 * sin(11/7 - 4 * t) + 78/11 * sin(t + 11/7) + 2/7 * sin(2 * t + 8/5) + 5/16 * sin(3 * t + 11/7) + 641/20) * θ(107 * π - t) * θ(t - 103 * π) + (-1/40 * sin(10/7 - 48 * t) - 1/20 * sin(32/21 - 47 * t) - 1/75 * sin(9/7 - 44 * t) - 1/10 * sin(35/23 - 41 * t) - 1/8 * sin(23/15 - 33 * t) - 1/13 * sin(38/25 - 30 * t) - 2/11 * sin(23/15 - 27 * t) - 1/7 * sin(14/9 - 23 * t) - 3/14 * sin(20/13 - 22 * t) - 1/5 * sin(17/11 - 19 * t) - 1/9 * sin(38/25 - 18 * t) - 1/13 * sin(14/9 - 13 * t) - 9/8 * sin(17/11 - 12 * t) - 3/10 * sin(11/7 - 11 * t) - 5/7 * sin(14/9 - 9 * t) - 6/7 * sin(17/11 - 6 * t) - 5/7 * sin(11/7 - 5 * t) - 131/15 * sin(11/7 - 3 * t) + 166/11 * sin(t + 11/7) + 82/13 * sin(2 * t + 11/7) + 5/4 * sin(4 * t + 11/7) + 7/15 * sin(7 * t + 33/7) + 23/22 * sin(8 * t + 11/7) + 7/5 * sin(10 * t + 19/12) + 1/2 * sin(14
@bradhowes
bradhowes / RepeatButton.playground
Last active January 16, 2021 11:53
Xcode playground showing SwiftUI custom button that repeatedly fires an action while touched
import SwiftUI
import PlaygroundSupport
class Model: ObservableObject {
@Published var value: Double = 5.0
}
struct RepeatButton: View {
private let title: String
private let systemImage: String