Skip to content

Instantly share code, notes, and snippets.

View Alexander-Ignition's full-sized avatar
🤖

Alexander Ignition Alexander-Ignition

🤖
View GitHub Profile
@kconner
kconner / macOS Internals.md
Last active July 7, 2024 19:42
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:

@Catfish-Man
Catfish-Man / manystrings.swift
Created July 12, 2022 03:00
How many different kinds of NSString can we generate with the same code?
import Foundation
func examine(_ str: String) {
print("\"\(str)\"")
print("bridges as: \(type(of: str as NSString))")
str.withCString {
print("inits an NSString as: \(type(of: NSString(cString: $0, encoding: String.Encoding.ascii.rawValue)!))")
}
print("\n")
}
@nikolay-n
nikolay-n / 00_only_vars.txt
Last active June 30, 2023 15:38
Dtrace of libsystem getenv
ACTIVITY_LOG_STDERR
AEConvertBookmarksToAliasesHack
AEDebugFull
AEDebugReceives
AEDebugSends
ALLOWED_GPU_IDS
APPLE_FRAMEWORKS_ROOT
ARCH
ASL_DISABLE
ASL_QUOTA_DISABLED
@ddddxxx
ddddxxx / KeyPath+fieldName.swift
Last active April 28, 2023 10:24
KeyPath Introspection
// This file is based largely on the Runtime package - https://github.com/wickwirew/Runtime
extension KeyPath {
var fieldName: String? {
guard let offset = MemoryLayout<Root>.offset(of: self) else {
return nil
}
let typePtr = unsafeBitCast(Root.self, to: UnsafeMutableRawPointer.self)
let metadata = typePtr.assumingMemoryBound(to: StructMetadata.self)
@cockscomb
cockscomb / swift-format.rb
Created December 18, 2019 22:17
Homebrew Formula of apple/swift-format
class SwiftFormat < Formula
desc "Formatting technology for Swift source code"
homepage "https://github.com/apple/swift-format"
url "https://github.com/apple/swift-format.git", :branch => "swift-5.1-branch"
head "https://github.com/apple/swift-format.git"
depends_on :xcode => ["11.0", :build]
def install
system "swift", "build", "--configuration", "release",
# Thanks to here https://stackoverflow.com/questions/13861658/is-it-possible-to-search-though-all-xcodes-logs
EXT=".xcactivitylog"
for LOG in *.xcactivitylog; do
NAME=`basename $LOG $EXT`
gunzip -c -S $EXT "${NAME}${EXT}" > "${NAME}.log"
done
@lattner
lattner / TaskConcurrencyManifesto.md
Last active July 25, 2024 20:23
Swift Concurrency Manifesto
@lattner
lattner / async_swift_proposal.md
Last active April 21, 2024 09:43 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

@regexident
regexident / AnyDiffable.swift
Created March 17, 2017 10:26 — forked from ollieatkinson/AnyDiffable.swift
Implementation of Paul Heckel's Diff Algorithm in Swift 3
public protocol Diffable: Hashable {
var primaryKeyValue: String { get }
}
public struct AnyDiffable: Diffable {
private let _primaryKeyValue: () -> String
@ravibhure
ravibhure / git_rebase.md
Last active July 26, 2024 08:21
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream