Skip to content

Instantly share code, notes, and snippets.

Adlai Holler Adlai-Holler

Block or report user

Report or block Adlai-Holler

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Adlai-Holler / ASCache.m
Created May 19, 2018
A cache that coalesces operations for the same key. We currently don't do enough concurrent duplicate requests for this to be useful but I think it's neat.
View ASCache.m
// ASCache.m
// Texture
// Copyright (c) 2018-present, Pinterest, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Adlai-Holler /
Last active Jul 2, 2019
How to observe CoreAnimation transaction commits as activities. Covers run-loop commits and UIKit-direct-flush commits, but not CADisplayLink scroll view commits.
* Don't use this in production!
* Screenshot of it working:
* This is real, private CA API. Valid as of iOS 10.
typedef enum {
Adlai-Holler / PINForEach.h
Last active Apr 23, 2017
Fast enumeration with index in Objective-C
View PINForEach.h
* Performs fast enumeration and keeps track of the enumeration index for you.
* If you don't need the index, you can use for-in directly, or pass `_` for the index name.
* Fast enumeration is _much_ faster than block enumeration, mostly due to the removal
* of many calls to -retain/-release. The only case where block enumeration is justified
* is in NSDictionary (if you need both key&value) and NSIndexSet.
* Example:
* PINForEach(NSString *str, self.titles, row, ({
* NSLog(@"Title %zd: %@", row, str);
Adlai-Holler / AHDeadlockDetector.m
Last active Apr 20, 2017
A simple UIKit deadlock detector, written in Objective-C.
View AHDeadlockDetector.m
#import <Foundation/Foundation.h>
#import <pthread.h>
#import <stdatomic.h>
@interface AHDeadlockDetector ()
* The current detection thread, if one is running. We store this weakly because
* if the thread has exited, why keep it around? In practice however, we nil
Adlai-Holler /
Last active Apr 19, 2017
An analysis of the implementations of Objective-C atomic properties.

Objective-C Synthesized Atomic Properties

Summary at bottom.

// iOS, Xcode 8.3.2 stock, ARM, release build


char -[MYObject boolProp](void * self, void * _cmd) {
    r0 = sign_extend_32(self->_boolProp);
Adlai-Holler / NSCacheTest.m
Created Nov 17, 2016
A test to ensure that NSCache doesn't give up after multiple memory warnings.
View NSCacheTest.m
- (void)testThatNSCacheDoesntGiveUp
NSCache *cache = [[NSCache alloc] init];
for (NSInteger i = 0; i < 5; i++) {
// Add a couple entries for good measure
[cache setObject:(id)kCFNull forKey:[NSUUID UUID]];
[cache setObject:(id)kCFNull forKey:[NSUUID UUID]];
[self expectationForNotification:UIApplicationDidReceiveMemoryWarningNotification object:nil handler:nil];
NSLog(@"Awaiting memory warning…");
Adlai-Holler / ASXCTExtensions.h
Last active Aug 27, 2016
XCTest extensions for CGGeometry
View ASXCTExtensions.h
* XCTest extensions for CGGeometry.
* Prefer these to XCTAssert(CGRectEqualToRect(...)) because you get output
* that tells you what went wrong.
* Could use NSValue, but using strings makes the description messages shorter.
#import <XCTest/XCTestAssertionsImpl.h>
View LockingTests.swift
// LockingTests.swift
// LockingTests
// Created by Adlai Holler on 1/18/16.
// Copyright © 2016 Adlai Holler. All rights reserved.
Results in iOS 9.2 simulator (iPhone 6) on my iMac:
'-[LockingTests.LockingTests testDispatchSemaphore]' measured [Time, seconds] average: 1.012, relative standard deviation: 6.997%, values: [1.090330, 1.071983, 1.048037, 0.911319, 1.042073, 0.920707, 1.079228, 0.962281, 0.919077, 1.076169],, baselineName: "", baselineAverage: , maxPercentRegression: 10.000%, maxPercentRelativeStandardDeviation: 10.000%, maxRegression: 0.100, maxStandardDeviation: 0.100
Adlai-Holler / UpdateCollectionViewOperation.swift
Created Sep 26, 2015
An operation to update an ASTableView/ASCollectionView from an NSFetchedResultsController changeset
View UpdateCollectionViewOperation.swift
Abstract: An operation the apply an FRC update to a table view/collection view.
import UIKit
struct CollectionUpdate {
// Note: These properties are listed in the order changes should be processed
Adlai-Holler / gist:ae321c3398d7db9a55c0
Created May 4, 2014
An early pod spec for ReactiveCocoa 3.0-dev
View gist:ae321c3398d7db9a55c0 do |s| = "ReactiveCocoa"
s.version = "3.0-dev"
s.summary = "A framework for composing and transforming streams of values."
s.homepage = "" = { "Josh Abernathy" => "" }
s.source = { :git => "", :branch => "3.0-development" }
s.license = 'MIT'
s.description = "ReactiveCocoa (RAC) is an Objective-C framework for Functional Reactive Programming. It provides APIs for composing and transforming streams of values."
You can’t perform that action at this time.