Skip to content

Instantly share code, notes, and snippets.

View Adlai-Holler's full-sized avatar

Adlai Holler Adlai-Holler

  • Chattanooga, TN
View GitHub Profile
@Adlai-Holler
Adlai-Holler / ASCache.m
Created May 19, 2018 19:37
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.
//
// 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
//
// http://www.apache.org/licenses/LICENSE-2.0
@Adlai-Holler
Adlai-Holler / gist:6432083
Created September 4, 2013 02:19
clear DB
// Cancel network requests
// Delete all managed objects
NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
NSManagedObjectContext *managedObjectContext = [RKManagedObjectStore defaultStore].persistentStoreManagedObjectContext;
[managedObjectContext performBlockAndWait:^{
NSError *error = nil;
for (NSEntityDescription *entity in [RKManagedObjectStore defaultStore].managedObjectModel) {
NSFetchRequest *fetchRequest = [NSFetchRequest new];
[fetchRequest setEntity:entity];
[fetchRequest setIncludesSubentities:NO];
@Adlai-Holler
Adlai-Holler / CATransactionObserving.mm
Last active June 12, 2023 06:23
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: https://user-images.githubusercontent.com/2466893/27601666-f65159f0-5b24-11e7-969d-fe86103c21de.png
*/
/**
* This is real, private CA API. Valid as of iOS 10.
*/
typedef enum {
@Adlai-Holler
Adlai-Holler / AHDeadlockDetector.m
Last active April 23, 2024 08:48
A simple UIKit deadlock detector, written in Objective-C.
#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