Skip to content

Instantly share code, notes, and snippets.

View etolstoy's full-sized avatar
🥦

Egor Tolstoy etolstoy

🥦
View GitHub Profile
- (void)testThatAuthOperationBlocksGeneralOperations {
// given
XCTestExpectation *expectation = [self expectationWithDescription:@"Last operation fired"];
NSMutableArray *operationNames = [NSMutableArray array];
NSString *const kAuthOperationName = @"AuthOperation";
NSString *const kInitialOperationName = @"InitialOperation";
NSString *const kGeneralOperationName = @"GeneralOperation";
NSUInteger const kGeneralOperationsCount = 5;
__block NSNumber *operationCounter = @0;
@etolstoy
etolstoy / 1
Last active November 15, 2015 14:41
Typhoon-Initial-Assemblies-Collector
@implementation RamblerAppDelegate
- (NSArray *)initialAssemblies {
return @[[MyAssembly class]];
}
@end
@etolstoy
etolstoy / Class.m
Created November 2, 2015 20:59
Typhoon-and-Storyboards
TyphoonStoryboard *storyboard = [TyphoonStoryboard storyboardWithName:name
factory:factory
bundle:bundle];
@etolstoy
etolstoy / RCTAssemblyTestsBase.h
Created June 30, 2015 19:26
RCTAssemblyTestsBase
//
// RCTAssemblyTestsBase.h
// Базовый класс для тестов Assembly
//
// Created by Egor Tolstoy on 15/05/15.
// Copyright (c) 2015 Rambler. All rights reserved.
//
#import <XCTest/XCTest.h>
@etolstoy
etolstoy / ViewController.m
Created February 18, 2015 07:05
IDTMessaging Test
// 7. Briefly discuss pixelmap image rotation algorithms and their execution times (O(*)). If you would write an image rotation algorithm, do you find anything useful in the iOS Accelerate framework?
- (UIImage *)rotateImage:(UIImage *)sourceImage withDegrees:(CGFloat)degrees {
vImage_Buffer sourceBuffer = [self bufferFromImage:sourceImage];
vImage_Buffer destinationBuffer = [self newBufferForBuffer:sourceBuffer];
CGFloat radians = [self radiansFromDegrees:degrees];
Pixel_8 backColor = 0;
vImageRotate_Planar8(&sourceBuffer, &destinationBuffer, NULL, radians, backColor, 0);
@etolstoy
etolstoy / ViewController.m
Created February 17, 2015 20:15
IDTMessaging Test
- (void)prepareToRecordAudio {
self.lowpassResults = 0.0f;
NSError *error;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];
// Setup default settings for the recorder
self.recorder = [[AVAudioRecorder alloc] initWithURL:[self applicationDocumentsDirectory]
settings:@{
AVFormatIDKey : @(kAudioFormatMPEG4AAC),
@etolstoy
etolstoy / ApiClient.m
Last active August 29, 2015 14:15
IDTMessaging Test
// 4. Write a class which does HTTP request to a service in address www.idtmessaging.com and extracts the html code inside tags <head> </head> - Discuss error handling.
- (void)makeRequest {
NSString *requestUrl = @"http://www.idtmessaging.com";
NSURL *url = [NSURL URLWithString:requestUrl];
[NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:url] queue:[NSOperationQueue new] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (data && !connectionError) {
NSString *htmlString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString *headString = [self obtainHeadFromHtml:htmlString];
@etolstoy
etolstoy / UIViewController.m
Created February 17, 2015 18:21
IDTMessaging Test
// 3. As a part of a ToDo -list application, write the implementation for method tableView:cellForRowAtIndexPath: constructing a UITableViewCell with a text label and disclosure indicator
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier forIndexPath:indexPath];
cell = [self configureCell:cell atIndexPath:indexPath];
return cell;
}
@etolstoy
etolstoy / YDLinkedList.h
Created February 17, 2015 18:14
IDTMessaging Test
// 2. Implement a class for linked lists. At least implement methods for add and remove.
#import <Foundation/Foundation.h>
typedef struct YDLinkedListNode YDLinkedListNode;
// Helper method for handy list nodes creating
YDLinkedListNode * YDLinkedListNodeMake(id object, YDLinkedListNode *previousNode, YDLinkedListNode *nextNode);
struct YDLinkedListNode {
@etolstoy
etolstoy / RevertString.m
Last active August 29, 2015 14:15
IDTMessaging Test
// 1. Write a function which takes a string as an argument and returns the string reversed. For example, "abcdef" becomes "fedcba"
- (NSString *)revertString:(NSString *)initialString {
NSMutableString *revertedString = [[NSMutableString alloc] initWithString:@""];
for (NSInteger i = initialString.length - 1; i >= 0; i--) {
char currentChar = [initialString characterAtIndex:i];
[revertedString appendString:[NSString stringWithFormat:@"%c", currentChar]];
}
return revertedString;
}