Skip to content

Instantly share code, notes, and snippets.

View a2's full-sized avatar
🐼

Alex Akers a2

🐼
View GitHub Profile
@a2
a2 / resume.json
Last active June 1, 2024 02:39
$ curl -L ancv.io/a2
{
"$schema": "https://raw.githubusercontent.com/alexpovel/ancv/main/schema.json",
"basics": {
"name": "Alex Akers",
"label": "Senior Software Engineer, iOS",
"image": "https://gravatar.com/avatar/4b8ce4d6ede58e229706ca9f1db9bb5c2e2646f42121dc2347f88c871770b412?s=512",
"email": "me@a2.io",
"url": "https://a2.io",
"summary": "Seasoned iOS Engineer with over a decade of experience in developing innovative applications for high-profile companies such as Apple, Twitter, Microsoft, and Facebook. Highly skilled in both Swift and Objective-C, with a strong background in leading critical projects, enhancing user experiences, and mentoring junior engineers. Dedicated to continuous learning and community contributions through open-source projects, conference talks, and mentorship.",
"location": {
@a2
a2 / ScaledValue.swift
Created March 16, 2022 19:40
ScaledValue
import SwiftUI
import UIKit
@propertyWrapper
struct ScaledValue: DynamicProperty {
@Environment(\.dynamicTypeSize) private var dynamicTypeSize
private var lastDynamicTypeSize: DynamicTypeSize!
private(set) var wrappedValue: CGFloat
import SwiftUI
struct LocationTapGesture: Gesture {
enum Value {
case recognized(CGPoint)
case failed
}
var coordinateSpace: CoordinateSpace

This works, but unnecessarily exposes T in Unwrap's generic parameters.

import SwiftUI

struct Unwrap<T, Content>: View where Content: View {
    let body: Content

    init(value: T?, @ViewBuilder ifSome: (T) -> Content, @ViewBuilder ifNone: () -> Content) {
        if let value = value {
@a2
a2 / MyPlayground.swift
Last active August 23, 2019 06:28
Tibetan characters cause NSLayoutManager to return incorrect bounding rect (rdar://48745247)
let string = "If the Tibetan characters དོམ་ཁྲ are removed, then the function boundingRect(forGlyphRange:in:) returns the correct value. Note that the values are incorrect for any range in a paragraph containing these characters."
let textStorage = NSTextStorage(string: string)
textStorage.addAttribute(.font, value: UIFont.systemFont(ofSize: UIFont.labelFontSize), range: NSRange(0 ..< textStorage.length))
// Xcode in dark mode makes the text hard to read.
textStorage.addAttribute(.foregroundColor, value: UIColor.white, range: NSRange(0 ..< textStorage.length))
let textContainer = NSTextContainer(size: CGSize(width: 300, height: 300))
let layoutManager = NSLayoutManager()
layoutManager.addTextContainer(textContainer)
@a2
a2 / install_booted.sh
Last active September 25, 2018 12:11
Installs app at argument path to all booted simulators and launches them
#!/bin/sh
if [ "$#" -ne 1 ]; then
echo "$0 <path>"
exit 1
fi
APP_PATH=$1
BUNDLE_ID=`/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$APP_PATH/Info.plist"`
for DEVICE in $(xcrun simctl list -j devices | jq --raw-output ".devices[][] | select(.state == \"Booted\") | .udid"); do
@a2
a2 / Workaround42199059.swift
Created July 14, 2018 18:59
Workaround for rdar://42199059
extension NSLayoutManager {
func invalidateLayout() {
let characterRange: NSRange
if let textStorage = textStorage {
// fast path
characterRange = NSRange(0 ..< textStorage.length)
} else {
characterRange = self.characterRange(forGlyphRange: NSRange(0 ..< numberOfGlyphs), actualGlyphRange: nil)
}
import UIKit
extension UIView {
var superviews: UnfoldFirstSequence<UIView> {
return sequence(first: self) { view in view.superview }
}
func enclosingView(where predicate: (UIView) -> Bool) -> UIView? {
return superviews.first(where: predicate)
}
Verifying my Blockstack ID is secured with the address 1PLiBanbTudwosuxUjb8ifCsufcx2AHkiY https://explorer.blockstack.org/address/1PLiBanbTudwosuxUjb8ifCsufcx2AHkiY
struct Person {
let firstName: String
let lastName: String
}
let names = """
Sandy Maynez
Kelli Ragland
Tracee Santucci
Bella Burts