Skip to content

Instantly share code, notes, and snippets.

@kconner
kconner / macOS Internals.md
Last active May 18, 2024 17:55
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@chockenberry
chockenberry / AttributedString.swift
Created June 1, 2022 21:08
A playground that shows how to use Swift's AttributedString with Markdown
import UIKit
import Foundation
// NOTE: This playground shows how to use Swift's AttributedString with Markdown.
//
// This code was used to display Markdown content in the Tot iOS Widget <https://tot.rocks>
// MARK: - Helpful Links
// NOTE: The following links helped me figure this stuff out.

Useful resources that were used to build the memory graph application. This is also a set of interesting materials which are related to memory understanding.

Source code

  1. The Memory Graph Project builds the memory graph of the application
  2. Python implementation of searching object's references and other interesting features via (lldb) script import lldb.macosx.heap
  3. C++ implementation of searching object's references
  4. FLEX set of in-app debugging and exploration tools for iOS development

Materials and media

  1. WWDC 2018 session iOS Memory Deep Dive
@AliSoftware
AliSoftware / git-groom
Last active December 7, 2021 15:46
Sync git working copies' trunk and develop branches and prune local and remote deleted/orphan branches
#!/bin/bash -euo pipefail
#
# Author: O.Halligon
# Jan 2021
#
# Help
if [ "${1:-}" == "-h" -o "${1:-}" == "--help" ]; then
BASENAME=${0##*/}
import CloudKit
import Combine
/// Fetches the user's CloudKit Account status.
///
/// - Parameter container: The container to check the status in.
///
/// - Returns: A deferred future that resolves to the user's CloudKit Account status.
func getAccountStatus(for container: CKContainer) -> AnyPublisher<CKAccountStatus, Error> {
Deferred {
@UnderscoreDavidSmith
UnderscoreDavidSmith / interviews.md
Last active July 19, 2020 17:59
Apple public interviews relating to WWDC 2020
import SwiftUI
enum ScalableFont {
case system(size: CGFloat, weight: Font.Weight = .regular, design: Font.Design = .default)
case custom(_ name: String, size: CGFloat)
var size: CGFloat {
switch self {
@IanKeen
IanKeen / Default.swift
Last active April 24, 2020 17:21
PropertyWrapper: Decode default values. when they are `null`
import Foundation
public protocol DefaultValue {
associatedtype Value: Codable
static var value: Value { get }
}
@propertyWrapper
public struct Default<Default: DefaultValue>: Codable {
template <class _Ty>
_NODISCARD /* constexpr */ _Ty _Common_lerp(const _Ty _ArgA, const _Ty _ArgB, const _Ty _ArgT) noexcept {
// on a line intersecting {(0.0, _ArgA), (1.0, _ArgB)}, return the Y value for X == _ArgT
const int _Finite_mask = (int{isfinite(_ArgA)} << 2) | (int{isfinite(_ArgB)} << 1) | int{isfinite(_ArgT)};
if (_Finite_mask == 0b111) {
// 99% case, put it first; this block comes from P0811R3
if ((_ArgA <= 0 && _ArgB >= 0) || (_ArgA >= 0 && _ArgB <= 0)) {
// exact, monotonic, bounded, determinate, and (for _ArgA == _ArgB == 0) consistent:
return _ArgT * _ArgB + (1 - _ArgT) * _ArgA;
// Copyright (c) 2019–20 Adam Sharp and thoughtbot, inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in