Skip to content

Instantly share code, notes, and snippets.


Alexander Grebenyuk kean

View GitHub Profile
kean / gist:ae2b051225208ec4d871
Created Mar 2, 2015
DFImageActivityItemProvider draft
View gist:ae2b051225208ec4d871
@interface DFImageActivityItemProvider : UIActivityItemProvider
- (instancetype)initWithPlaceholderItem:(id)placeholderItem request:(DFImageRequest *)request;
@implementation DFImageActivityItemProvider {
DFImageRequest *_request;
DFImageRequestID *_requestID;
kean / DFCompositeImageTask
Last active Sep 11, 2015
Compose DFImageTask objects
View DFCompositeImageTask
// DFCompositeImageTask.h
#import "DFImageManagerDefines.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@class DFCompositeImageTask;
@class DFImageRequest;
@class DFImageTask;
@protocol DFImageManaging;
kean / DFProxyImageManager
Created Sep 11, 2015
Extend DFImageManaging API
View DFProxyImageManager
// DFProxyImageManager.h
#import "DFImageManaging.h"
#import "DFImageRequest.h"
#import <Foundation/Foundation.h>
/*! The DFProxyRequestTransforming protocol defines an interface for transforming application-specific classes or protocols to the resources supported by the DFImageManager.
@protocol DFProxyRequestTransforming <NSObject>
kean / gist:511d247fad4d6f76254a
Created Nov 17, 2015
UIViewController Keyboard Management
View gist:511d247fad4d6f76254a
@interface ViewController : UIViewController
@property (nonatomic, readonly, nullable) UIView *keyboardAnchorView;
@property (nonatomic, readonly, nullable) NSLayoutConstraint *keyboardAnchorViewHeightConstraint;
View CustomImageLoadingView.m
@import DFImageManager;
@interface CustomImageLoadingView
- (void)prepareForReuse;
- (void)setImageWithRequest:(nonnull DFImageRequest *)request;
@implementation CustomImageLoadingView {
View XCTestCaseExtensions.swift
// The MIT License (MIT)
// Copyright (c) 2015 Alexander Grebenyuk (
import XCTest
import Foundation
extension XCTestCase {
public func expect(block: (fulfill: (Void) -> Void) -> Void) {
let expectation = self.expectation()
View nuke_01.swift
var request = ImageRequest(URLRequest: <#NSURLRequest#>)
request.targetSize = CGSize(width: 200, height: 200) // Resize image
request.processor = <#ImageProcessing#> // Apply image filters
Nuke.taskWithRequest(request) { response in
let image = response.image
View GMAutoRetryControlleExampler.m
- (void)_fetchSomethingOrDieWithCompletion:(void (^)(id something))completion {
_autoRetryController = [[[GMURLAutoRetryController alloc] initWithBlock:^(GMAutoRetryController * _Nonnull controller) {
[/* start request with */ completion:^(id __nullable something, NSError * __nullable error) {
if (error) {
[controller scheduleAutoRetryWithError:error];
} else {
}] resume];
View GMAutoRetryController.m
#import "GMAutoRetryController.h"
#import "NSTimer+GMBlocks.h"
#import "NSError+Fitmeup.h"
#import "GMNetworkReachability.h"
#import "GMRepository.h"
typedef NS_ENUM(NSInteger, _GMARCState) {
_GMARCStateSuspended, // initial state
View GMAutoRetryController.h
#import <Foundation/Foundation.h>
static const NSInteger GMAutoRetryControllerInfiniteAttemptCount = INT_MAX;
/*! Auto retry with progressive delay. Thread safe.
@interface GMAutoRetryController : NSObject
@property (nullable, nonatomic, copy) void (^block)(GMAutoRetryController *__nonnull autoRetryController);