Skip to content

Instantly share code, notes, and snippets.

View alekseypotapov-dev's full-sized avatar

Aleksey Potapov alekseypotapov-dev

View GitHub Profile
@alekseypotapov-dev
alekseypotapov-dev / UISegmentedControlSegmentPopover
Created February 27, 2014 08:45
UISegmentedControl show popover from according segment
CGRect frame = [segmentControl frame];
frame =CGRectMake((frame.size.width/No. of segments * [segmentControl selectedSegmentIndex]), 0, frame.size.width/No. of segments, segmentControl.bounds.size.height);
[m_PopOver presentPopoverFromRect:frame inView:segmentControl permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
@alekseypotapov-dev
alekseypotapov-dev / PlistReader.m
Last active August 29, 2015 13:56
Use this if you wonna to save .plist to Document directory and then wonna to edit this file
/*
Then just to use somehow like this (if array)
NSMutableArray *parsedPlist = [[NSMutableArray alloc] initWithContentsOfFile:[PlistReader copyFileToDocumentDirectory:%"filename.plist"]];
*/
+ (NSString *)copyFileToDocumentDirectory:(NSString *)fileName
{
NSError *error;
@alekseypotapov-dev
alekseypotapov-dev / CustomSegmentedControl.m
Created February 27, 2014 09:05
Make possibility to react segment on continious tap and stay highlighted in custom UISegmentedControl
+ (BOOL)isIOS7
{
static BOOL isIOS7 = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSInteger deviceSystemMajorVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] integerValue];
if (deviceSystemMajorVersion >= 7) {
isIOS7 = YES;
}
else {
@alekseypotapov-dev
alekseypotapov-dev / Constants
Last active August 21, 2017 13:02
Handy #define's
#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
//get ios verison
[[[UIDevice currentDevice] systemVersion] floatValue]
#define isIPAD UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad
// Logging
// DLog will output like NSLog only when the DEBUG variable is set
@alekseypotapov-dev
alekseypotapov-dev / AppDelegate+Blur.m
Last active April 18, 2021 10:03
Blurring sensitive data
#pragma mark - Security
- (void)applicationDidEnterBackground:(UIApplication *)application {
RootViewController *rootVC = (RootViewController *)self.window.rootViewController;
UIViewController *viewController = (UIViewController *)[rootVC.presentedViewControllers lastObject];
/**
If the last presented view controller is a SplashViewController we must not present the splash
screen again.
*/
if (![viewController isKindOfClass:[SplashViewController class]]) {
/**
@alekseypotapov-dev
alekseypotapov-dev / bash
Created August 5, 2014 10:14
Delete SVN files
Delete .svn files using bash
find . -name .svn -exec rm -rf '{}' \;
@alekseypotapov-dev
alekseypotapov-dev / PolygonInCircle.cpp
Last active August 29, 2015 14:07
This is a 4th example for the first OpenGL lesson
//
// main.cpp
// OpenGL-examples
//
// Created by Alexey Potapov on 27.09.14.
// Copyright (c) 2014 none. All rights reserved.
//
#include <stdlib.h>
#include <stdio.h>
DirectorySlash Off
Options +FollowSymlinks -Indexes -MultiViews
AddDefaultCharset utf-8
DirectoryIndex /public/index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
@alekseypotapov-dev
alekseypotapov-dev / FolderLocation.m
Last active April 18, 2021 10:02
Find the ios simulator's application folder documents on Mac
NSLog(@"Documents Directory: %@",
[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory
inDomains:NSUserDomainMask] lastObject]);
@alekseypotapov-dev
alekseypotapov-dev / saveImg.m
Created March 6, 2015 12:36
Save image to Documents folder
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:
[NSString stringWithFormat:@"savedImage%lu.png",arrayOfImages.count]];
NSData *imageData = UIImagePNGRepresentation(imageObject);
[imageData writeToFile:savedImagePath atomically:NO];