Skip to content

Instantly share code, notes, and snippets.

View onurhuseyincantay's full-sized avatar
🎯
Focusing

Onur Hüseyin Çantay onurhuseyincantay

🎯
Focusing
View GitHub Profile
import CoreGraphics
// MARK: - Function Documentation
/// Calculates the difference between given points
/// - Parameter pointA: first point
/// - Parameter pointB: second point
/// - Returns: Distance of 2 points as CGFloat
func calculateDistance(from pointA: CGPoint, to pointB: CGPoint) -> CGFloat? { nil }
// TODO: - Add more functions as sample
@onurhuseyincantay
onurhuseyincantay / syncm.sh
Created February 12, 2019 15:01 — forked from cwsaylor/syncm.sh
Merge master into current branch
#!/bin/sh -x
CURRENT=`git branch | grep "*" | awk '{print $2}'`
git checkout master
git fetch
git merge origin/master
git checkout ${CURRENT}
git merge master ${CURRENT}
- (void)askUserAQuestion{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle : @"Question Time"
message : @"What do you want to do ?"
delegate : self
cancelButtonTitle : @"Cancel"
otherButtonTitle : @"Continue",
nil];
[alert show];
}
@onurhuseyincantay
onurhuseyincantay / ClassClusterPattern.m
Created January 16, 2019 13:22
Class Cluster Pattern implementation example
typedef NS_ENUM (NSUInteger,PostType){
PostTypeVideo,
PostTypePhoto,
PostTypePlain,
};
@interface Post:NSObject
@property (copy) NSString *title;
@property NSDate *createdDate;
// helper for creating Post Object
+ (Post*) postWithType:(PostType)type;
@onurhuseyincantay
onurhuseyincantay / Equality.m
Last active January 16, 2019 14:17
Equality in objective-c
NSString *compareableString = @“This is a String”;
NSString *comparedString = @“This is a String”;
BOOL *isEqual = (*comparableString == *comparedString);
// this will return NO because it refers to two different objects
/*
So we have to use equality methods from their objects to compare them.
If we want to use our custom equality functions
we also should be sure that the function checks for the pointer equality as a first step of equality function.*/
if(self == object) return YES;
//we also should be sure to have a hash function to check the second equality step.
@onurhuseyincantay
onurhuseyincantay / Person.m
Created January 16, 2019 13:14
person object declaration example
@interface Person:NSObject{
@public
NSString *_firstName;
NSString *_lastName;
@private
NSString *_someInternalData;
}
@end
@onurhuseyincantay
onurhuseyincantay / Literals.m
Last active January 16, 2019 13:08
Basic Objective-C Declarations
// NSString
NSString *someAllocInitString = [[NSString alloc] initWthString: @“The String”];
NSString *someLiteralDeclaredString = @"The String";
// NSArray
NSArray *someAllocInitArray = [NSArray arrayWithObjects:@“firstObject”,@“secondObject”,@“thirdObject”];
NSArray *someLiteralDeclaredArray = @[@“firstObject”,@“secondObject”,@”thirdObject”];
// NSDictionary
NSDictionary *someAllocInitDictionary = [NSDictionary dictionaryWithObjectAndKeys : @“firstValue”,@“firstKey”
@onurhuseyincantay
onurhuseyincantay / iOS.8.3.txt
Created November 16, 2018 18:37
iOS UIFont names
UIFont: family Thonburi
UIFont: font Thonburi-Bold
UIFont: font Thonburi
UIFont: font Thonburi-Light
UIFont: family Khmer Sangam MN
UIFont: font KhmerSangamMN
UIFont: family Snell Roundhand
UIFont: font SnellRoundhand-Black
UIFont: font SnellRoundhand-Bold
UIFont: font SnellRoundhand
from bs4 import BeautifulSoup
import urllib.request
import os, ssl
import re
import pandas as pd
def getDataFromUrl(text,tagForData=None,idForData=None
,classForData=None,isSoup=False):
#this creates an SSL Cerificate
if (not os.environ.get('PYTHONHTTPSVERIFY', '') and
getattr(ssl, '_create_unverified_context', None)):
from bs4 import BeautifulSoup
import urllib.request
import os, ssl
import re
import pandas as pd
def getDataFromUrl(text,tagForData=None,idForData=None
,classForData=None,isSoup=False):
#this creates an SSL Cerificate
if (not os.environ.get('PYTHONHTTPSVERIFY', '') and
getattr(ssl, '_create_unverified_context', None)):