Skip to content

Instantly share code, notes, and snippets.

View bachand's full-sized avatar

Michael Bachand bachand

View GitHub Profile
@bachand
bachand / main.tf
Created May 9, 2023 23:45
[Airbnb Tech Blog] Example invocation of Terraform module to create CI environment
module "ios-ci-arm-xcode-14-2" {
source = "../modules/ios-platform"
instance_type = "mac2.metal"
launch_template_version = 23
ami_filter = "ios-ci-xcode_14_2_0-*"
max_num_instances = # redacted
max_num_instances_weekends = # redacted
buildkite_tags = {
@bachand
bachand / ami-creation-shell
Last active May 9, 2023 23:42
[Airbnb Tech Blog] Example invocation of AMI creation utility
$ time ./make_ami.rb \
--instance-type mac2.metal \
--source-ami macos_arm_autologin_enabled \
--xcode-version 'Xcode 14.2.0 (14C18)'
# real 60m21.652s
# user 0m41.418s
# sys 0m32.152s
@bachand
bachand / MasteringFocusExample9.swift
Last active September 10, 2015 21:44
Requesting Focus from Two Focus Environments Simultaneously
// animalsViewController.preferredFocusedView => catButton
// animalsViewController.view.preferredFocusedView => pigButton
animalsViewController.setNeedsFocusUpdate()
animalsViewController.view.setNeedsFocusUpdate()
animalsViewController.view.updateFocusIfNeeded()
// UIScreen.mainScreen().focusedView => catButton
@bachand
bachand / MasteringFocusExample8.swift
Created September 10, 2015 20:53
Requesting Focus Update from Within Focus Hierarchy
// animalsViewController.preferredFocusedView => catButton
animalsViewController.setNeedsFocusUpdate()
animalsViewController.updateFocusIfNeeded()
// UIScreen.mainScreen().focusedView => catButton
@bachand
bachand / MasteringFocusExample7.swift
Created September 10, 2015 20:51
Requesting Focus Update from Outside Focus Hierarchy
// catButton.preferredFocusedView => catButton
catButton.setNeedsFocusUpdate()
catButton.updateFocusIfNeeded()
// UIScreen.mainScreen().focusedView => dogButton
@bachand
bachand / MasteringFocusExample6.swift
Created September 10, 2015 20:49
AnimalsViewController
class AnimalsViewController: UIViewController {
let dogButton: UIButton
let catButton: UIButton
let pigButton: UIButton
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(dogButton)
view.addSubview(catButton)
@bachand
bachand / MasteringFocusExample5.swift
Created September 10, 2015 20:46
Horizontally Centering Focused UIButton
class ActionHeroesView: UIView {
let stalloneButton: UIButton
let vanDammeButton: UIButton
// ...
override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
super.didUpdateFocusInContext(context, withAnimationCoordinator: coordinator)
// we'll center Stallone when neither is in focus since he's a bigger deal
@bachand
bachand / MasteringFocusExample4.swift
Created September 10, 2015 20:45
Disabling Focus in UICollectionView
func collectionView(collectionView: UICollectionView, shouldUpdateFocusInContext context: UICollectionViewFocusUpdateContext) -> Bool {
guard let indexPaths = collectionView.indexPathsForSelectedItems() else { return true }
return indexPaths.isEmpty
}
func collectionView(collectionView: UICollectionView, shouldSelectItemAtIndexPath indexPath: NSIndexPath) -> Bool {
if let indexPath = collectionView.indexPathsForSelectedItems()?.first {
collectionView.deselectItemAtIndexPath(indexPath, animated: true)
return false
}
@bachand
bachand / MasteringFocusExample3.swift
Created September 10, 2015 20:43
Querying Screen for Focused View
UIScreen.mainScreen().focusedView // possibly nil
@bachand
bachand / MasteringFocusExample2.swift
Created September 10, 2015 19:25
Query Whether UIButton is Focused
myButton.focused // true or false