Skip to content

Instantly share code, notes, and snippets.

View Viveron's full-sized avatar
🔨

Viktor Shabanov Viveron

🔨
  • London, UK
  • 15:00 (UTC +01:00)
View GitHub Profile
//необходимо реализовать функцию позволяющую делать сдвиг массива
//@param swift - любое целочисленное число
//@param arr - любой целочисленный массив
//func arrayShift(_ arr: [Int], swift: Int) -> [Int]
//пример 1
//arrayShift([1,2,3,4,5], shift: 1)
//result : [5,1,2,3,4]
//пример 2
//arrayShift([1,2,3,4,5], shift: 2)
//result : [4,5,1,2,3]
public typealias Closure<Value, Result> = (Value) -> Result
public typealias ValueClosure<Value> = Closure<Value, Void>
public typealias ResultClosure<Result> = () -> Result
public typealias VoidClosure = ResultClosure<Void>
public typealias ThrowsClosure<Value, Result> = (Value) throws -> Result
public typealias ThrowsValueClosure<Value> = ThrowsClosure<Value, Void>
public typealias ThrowsResultClosure<Result> = () throws -> Result
public typealias ThrowsVoidClosure = ThrowsResultClosure<Void>
import UIKit
import LeadKit
import RxSwift
import RxCocoa
typealias TapTrait = Void
typealias TapRelay = PublishRelay<TapTrait>
typealias TapDriver = Driver<TapTrait>
extension PublishRelay where Element == TapTrait {
@Viveron
Viveron / example.swift
Last active May 22, 2019 19:10
Class design agreement
```swift
import UIKit
/*
Проектируемый класс условно делится на области:
1. Свойства
2. Иницализаторы
3. Методы
Правила для всех областей:
@Viveron
Viveron / UIImage+Blur.h
Created August 10, 2018 09:00
UIImage box blur creation category
#import <UIKit/UIKit.h>
@interface UIImage (Blur)
- (UIImage *)boxBlur:(CGFloat)blurLevel depth:(NSUInteger)blurDepth;
@end
@Viveron
Viveron / Prefix.pch
Created August 10, 2018 08:44
Helpful Obj-C macroses
#define IS_IPHONE UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone
#define IS_IPAD UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad
#define SYSTEM_VERSION_COMPARE(v) [[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch]
#define IS_OS_EQUAL(v) (SYSTEM_VERSION_COMPARE(v) == NSOrderedSame)
#define IS_OS_GREATER(v) (SYSTEM_VERSION_COMPARE(v) == NSOrderedDescending)
#define IS_OS_GREATER_OR_EQUAL(v) (SYSTEM_VERSION_COMPARE(v) != NSOrderedAscending)
#define IS_OS_LESS(v) (SYSTEM_VERSION_COMPARE(v) == NSOrderedAscending)
#define IS_OS_LESS_OR_EQUAL(v) (SYSTEM_VERSION_COMPARE(v) != NSOrderedDescending)
@Viveron
Viveron / NSManagedObjectContext+AsyncExecute.h
Created August 10, 2018 08:40
NSManagedObjectContext helpful additions for async request execution
#import <CoreData/CoreData.h>
@interface NSManagedObjectContext (AsyncExecute)
- (void)asyncExecuteFetchRequest:(NSFetchRequest *)request
completion:(void (^)(NSArray *objects, NSError *error))completion;
- (void)asyncCountForFetchRequest:(NSFetchRequest *)request
completion:(void (^)(NSInteger count, NSError *error))completion;
@Viveron
Viveron / NSData+Hash.h
Created August 10, 2018 08:38
NSData SHA256 hash category
#import <Foundation/Foundation.h>
@interface NSData (Hash)
- (NSData *)SHA256;
- (NSString *)stringSHA256;
@end
@Viveron
Viveron / NSManagedObject+Additions.h
Last active August 10, 2018 08:22
NSManagedObject helpful additions
#import <CoreData/CoreData.h>
@interface NSManagedObject (Additions)
#pragma mark - Life cycle management
+ (id)createInContext:(NSManagedObjectContext *)context;
- (void)deleteInContext:(NSManagedObjectContext *)context;