Skip to content

Instantly share code, notes, and snippets.

View atierian's full-sized avatar

Ian Saultz atierian

  • Amazon Web Services
  • Charleston, SC
View GitHub Profile
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active July 22, 2024 12:48
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active July 12, 2024 03:33
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

@IanKeen
IanKeen / NestedKey.swift
Last active July 13, 2022 23:57
PropertyWrapper: NestedKey - deal with en/de-coding values within nested data
public protocol NestedCodingKey: CodingKey {
var nestedKeys: [String] { get }
}
@propertyWrapper
public struct NestedKey<T: Codable>: Codable {
public var wrappedValue: T
public init(wrappedValue: T) {
self.wrappedValue = wrappedValue
@ollieatkinson
ollieatkinson / SVG.swift
Last active June 24, 2024 11:37
Utilise the private CoreSVG framework in Swift
import Darwin
import Foundation
import UIKit
// https://github.com/xybp888/iOS-SDKs/blob/master/iPhoneOS17.1.sdk/System/Library/PrivateFrameworks/CoreSVG.framework/CoreSVG.tbd
// https://developer.limneos.net/index.php?ios=17.1&framework=UIKitCore.framework&header=UIImage.h
@objc
class CGSVGDocument: NSObject { }
@IanKeen
IanKeen / EnvironmentValues.swift
Last active January 5, 2024 08:49
SwiftUI: Peek at/extract hidden environment values
import Foundation
import SwiftUI
extension EnvironmentValues {
public func value<T>(_: T.Type = T.self, forKey key: String) -> T? {
guard let value = first(where: { name($0, equals: key) }) else {
print("No EnvironmentValue with key '\(key)' found.")
return nil
}
@dynamicMemberLookup
struct Partial<Wrapped> {
private struct AnyProperty {
let keyPath: PartialKeyPath<Wrapped>
let value: Any
let writer: (inout Wrapped, Any) -> Void
init<T>(keyPath: WritableKeyPath<Wrapped, T>, value: T) {
self.keyPath = keyPath
self.value = value
@brennanMKE
brennanMKE / README.md
Last active May 11, 2022 08:49
Xcode Purge

Xcode Purge

Sometimes you just have to purge. With Xcode, it helps to completely blow away the Derived Data and SPM Cache directories. These directories contain all of the build artifacts produced by Xcode and resolved Swift packages. When a clean action does not completely reset your build it is time to purge.

These 2 functions can be added to your shell so you can simply run xcpurge to send Derived Data and SPM Cache to your Trash. You can recover it if necessary.

Usage

You likely are now using zsh with macOS and so you can update ~/.zshrc to define these functions. What I recommend is creating a folder at ~/.shell and create a file named ~/.shell/functions in that folder. Add the functions below to this file. Make sure to also run chmod u+x ~/.shell/functions and then add source $HOME/.shell/functions to ~/.zshrc so your shell has these functions defined. You can then run xcpurge or trash like any other command. The first time you run it you will need to grant permission since i

@rain-1
rain-1 / LLM.md
Last active July 18, 2024 22:37
LLM Introduction: Learn Language Models

Purpose

Bootstrap knowledge of LLMs ASAP. With a bias/focus to GPT.

Avoid being a link dump. Try to provide only valuable well tuned information.

Prelude

Neural network links before starting with transformers.