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 / dynss-2
Created January 26, 2014 11:54
Dynamic String Search - 2
+ (NSArray *) findHotspot: (NSString *)partOfTitle
{
SBHotspotData *item;
NSMutableArray *result = [NSMutableArray array];
NSString *path = [self getDatabasePath];
FMDatabase *database;
database = [FMDatabase databaseWithPath:path];
[database open];
NSString *query = [NSString stringWithFormat:@"select * from hotspots where TitleLow like '%%%@%%'", [partOfTitle lowercaseString]];
FMResultSet *results = [database executeQuery:query];
@etolstoy
etolstoy / dynss-1
Created January 26, 2014 11:52
Dynamic String Search
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
_data = [SBHotspotData findHotspot:searchText];
[self.searchResultsTableView reloadData];
}
@etolstoy
etolstoy / dynss-3
Created January 26, 2014 11:55
Dynamic String Search - 3
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:item.hotspotTitle];
NSRange range = [item.hotspotTitle rangeOfString:_searchHotspotBar.text];
[attributedString addAttribute:NSBackgroundColorAttributeName value:[UIColor colorWithRed:216/255.0f green:87/255.0f blue:23/255.0f alpha:1.0f] range:range];
cell.cellLabel.attributedText = attributedString;
@etolstoy
etolstoy / linechart-usage
Created January 25, 2014 19:06
[ios-linechart] Usage
_chartView = [[LineChartView alloc] initWithFrame:CGRectMake(0, 210, 300, 220)];
if (d.itemCount <= 5)
_chartView.drawsDataPoints = YES;
else
_chartView.drawsDataPoints = NO;
_chartView.yMin = 0;
_chartView.yMax = [PVPVerbData getOverallVerbsQuantity];
_chartView.ySteps = @[@"0",
[NSString stringWithFormat:@"%.f", _chartView.yMax / 8],
[NSString stringWithFormat:@"%.f", _chartView.yMax / 4],
@etolstoy
etolstoy / linechart-setup2
Created January 25, 2014 19:05
[ios-linechart] Additional Setup
NSMutableArray *days = [NSMutableArray new];
NSMutableArray *verbs = [NSMutableArray new];
for(NSUInteger i = 0; i < d.itemCount; ++i)
{
PVPDayStat *item = [[PVPDayStat alloc] init];
item = [daysStatistics objectAtIndex:i];
[days addObject:@([item.day intValue])];
[verbs addObject:@([item.verbs intValue])];
}
@etolstoy
etolstoy / linechart-setup
Created January 25, 2014 19:04
[ios-linechart] Setup
LineChartData *d = [LineChartData new];
d.xMin = 1;
d.xMax = [daysStatistics count];
d.title = @"The title for the legend";
d.color = [UIColor colorWithRed:0/255.0f green:179/255.0f blue:219/255.0f alpha:1.0f];
d.itemCount = [daysStatistics count];
@etolstoy
etolstoy / gist:8621330
Created January 25, 2014 18:44
2.23 App Store Review Guidelines
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);
NSError *error = nil;
BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES]
forKey: NSURLIsExcludedFromBackupKey error: &error];
if(!success){
NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
}
@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];