Skip to content

Instantly share code, notes, and snippets.

View Vyazovoy's full-sized avatar

Andrey Vyazovoy Vyazovoy

  • Squarespace, Inc.
  • New York, US
View GitHub Profile
@Vyazovoy
Vyazovoy / FailedPlayground.swift
Created April 3, 2018 00:28
Xcode 9.3 protocol conformance bug
//: Playground - noun: a place where people can play
import UIKit
protocol ViewControllerProvider {
func createViewController() -> UIViewController
}
protocol HasProvider {
associatedtype Provider: ViewControllerProvider
@Vyazovoy
Vyazovoy / NSData+PSPDFFoundation.m
Created November 14, 2015 18:19 — forked from steipete/NSData+PSPDFFoundation.m
Haven't done much with dispatch_io yet so I'd appreciate a few more eyeballs on this. Am I closing things correctly in all error conditions? Are there other knobs I could change to make things even faster? (I know I've been lazy on the NSError's)
static NSData *PSPDFCalculateSHA256FromFileURL(NSURL *fileURL, CC_LONG dataLength, NSError **error) {
NSCParameterAssert(fileURL);
dispatch_queue_t shaQueue = dispatch_queue_create("com.pspdfkit.sha256-queue", DISPATCH_QUEUE_SERIAL);
__block dispatch_io_t readChannel;
void (^processIntError)(int intError) = ^(int intError) {
if (intError != 0) {
PSPDFLogWarning(@"Stream error: %d", intError);
if (error) *error = [NSError errorWithDomain:@"SHA256Error" code:100 userInfo:@{NSLocalizedDescriptionKey: @"failed to open file for calculating SHA256."}];
@Vyazovoy
Vyazovoy / .gitignore
Created September 1, 2014 12:38
.gitignore
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
@Vyazovoy
Vyazovoy / AppliftoWebAPI.md
Last active May 1, 2017 19:52
Description of Applifto Web API

Applifto Web API

Описание

Applifto Web API предсталяет собой RESTful интерфейс для получения/обновления данных и управления представлением этих данных на клиенте.

В качестве протокола передачи данных используется HTTPS (к сожалению мы пока не доросли до таких технологий и используем HTTP).
В качестве формата представления данных используется JSON.
Все даты в нулевой временной зоне (GMT) и имеют формат: YYYY-MM-DD HH:MM:SS (к сожалению мы пока привязаны к MSK).
Все языковые коды в формате ISO 639-1.
Все коды стран и территорий в формате ISO 3166-1 alpha-2.

@Vyazovoy
Vyazovoy / UIView+MyClass.m
Created July 15, 2013 20:05
Category with property.
#import <objc/runtime.h>
@interface UIView (MyClass)
@property (strong, nonatomic, readwrite, setter = my_setProperty:) NSObject *my_propery;
@end
static const char kProperty;
@Vyazovoy
Vyazovoy / gist:5858195
Created June 25, 2013 12:49
Right way to use references inside blocks
NSObject *someReferencedObject = [NSObject new];
__typeof(someReferencedObject) __weak weakSomeReferencedObject = someReferencedObject;
[someReferencedObject addBlock:^() {
__typeof(weakSomeReferencedObject) __strong strongSomeReferencedObject = weakSomeReferencedObject;
if (strongSomeReferencedObject) {
//do something with strongSomeReferencedObject
} else {
//appropriate reaction
}
}];