Skip to content

Instantly share code, notes, and snippets.

View erwinmaza's full-sized avatar

Erwin Mazariegos erwinmaza

View GitHub Profile
@erwinmaza
erwinmaza / gist:5ef34726de9809290596477dafe5f7e3
Created January 17, 2023 14:02
Xcode playground code sample showing how to batch and de-dupe inflight network calls using Swift concurrency
import Foundation
func threadNumberForThread() -> String {
let array1 = Thread.current.description.components(separatedBy: ">")
if array1.count > 1 {
let array2 = array1[1].trimmingCharacters(in: CharacterSet(charactersIn: "{}")).components(separatedBy: ",")
for pair in array2 {
let array3 = pair.components(separatedBy: "=")
if array3.count > 1 {
if array3[0].contains("number") {
@erwinmaza
erwinmaza / gist:5000828
Last active March 9, 2016 11:01
Fix for centering thumb image when rotating UISlider 90 degrees to a vertical orientation
/*
UISlider controls can be rotated to a vertical orientation with this setting:
layer.transform.rotation.z = 1.570795 (type = String)
in IB under User Defined Runtime Attibutes for the UISlider.
However, this makes it visually obvious that iOS does not draw the thumb image
over the center of the slider track, it is actually offset 1 point up (when horizontal).
@erwinmaza
erwinmaza / gist:4656200
Last active January 9, 2016 23:14
ABContactsHelper modification to remove linked contacts from "all contacts" list. Preliminary testing shows the end result mimics the list in the Contacts app. Note: I have not determined if the data returned for each ABContact includes data from linked records. I suspect it does not. Most likely, the data access methods will need to be modified…
/*
This modification extends Erica Sadun's ABContactsHelper.m
https://github.com/erica/ABContactHelper
Feedback and performance suggestions welcome!
Edit 1/29/13: refactor to avoid calling ABPersonCopyArrayOfAllLinkedPeople() multiple times for same person.
Testing shows 5% performance improvement (811 total records = 249 unlinked + 562 linked),
3 run average, looping through code 10 times each run, in simulator.