Skip to content

Instantly share code, notes, and snippets.

View canaksoy's full-sized avatar
🎯
Focusing

Can Aksoy canaksoy

🎯
Focusing
View GitHub Profile
@canaksoy
canaksoy / encr.m
Created March 9, 2017 20:20
encrParameters
//parameters
NSMutableArray *keys = [[NSMutableArray alloc] init];
for (NSString * key in parameters)
{
[keys addObject:key];
}
[keys sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
NSMutableString * stringParams = [[NSMutableString alloc] initWithString:@""];
@canaksoy
canaksoy / encr.swift
Last active March 9, 2017 20:15
encryptAndReturnParameters
func encryptAndReturnParameters(parameters: [String : AnyObject]) -> [String: AnyObject] {
var sortedKeys = parameters.sorted{$0.0 < $1.0}
var paramString = ""
for (_, value) in sortedKeys {
paramString.addString(str: String(describing: value))
}
paramString.addString(str: "YOURSECRETKEY")
@canaksoy
canaksoy / typingLogic.m
Created July 23, 2016 11:06
shouldChangeTextInRange (user is typing logic)
@property int isTyping;
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
[self startTyping];
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(stopTyping) object:nil];
[self performSelector:@selector(stopTyping) withObject:nil afterDelay:0.5];
return YES;
@canaksoy
canaksoy / NavigationBarTitleWithSubtitleView.h
Last active July 23, 2016 11:07
NavigationBarTitleWithSubtitleView
#import <UIKit/UIKit.h>
@interface NavigationBarTitleWithSubtitleView : UIView
- (void) setTitleText: (NSString *) aTitleText;
- (void) setDetailText: (NSString *) aDetailText;
@end
@canaksoy
canaksoy / AppDelegate.m
Created April 8, 2016 23:15
UIApplicationShortcutItem
UIApplicationShortcutIcon * photoIcon = [UIApplicationShortcutIcon iconWithTemplateImageName: @"selfie-100.png"]; // your customize icon
UIApplicationShortcutItem * photoItem = [[UIApplicationShortcutItem alloc]initWithType: @"selfie" localizedTitle: @"take selfie" localizedSubtitle: nil icon: photoIcon userInfo: nil];
UIApplicationShortcutItem * videoItem = [[UIApplicationShortcutItem alloc]initWithType: @"video" localizedTitle: @"take video" localizedSubtitle: nil icon: [UIApplicationShortcutIcon iconWithType: UIApplicationShortcutIconTypeCaptureVideo] userInfo: nil];
[UIApplication sharedApplication].shortcutItems = @[photoItem,videoItem];
@canaksoy
canaksoy / AppDelegate.m
Last active March 30, 2022 11:09
sha256 hash objective-c ios xcode
-(NSString*)sha256HashFor:(NSString*)input
{
const char* str = [input UTF8String];
unsigned char result[CC_SHA256_DIGEST_LENGTH];
CC_SHA256(str, (CC_LONG)strlen(str), result);
NSMutableString *ret = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH*2];
for(int i = 0; i<CC_SHA256_DIGEST_LENGTH; i++)
{
[ret appendFormat:@"%02x",result[i]];
@canaksoy
canaksoy / AppDelegate.m
Created April 8, 2016 22:18
ios installed fonts list
for (NSString* family in [UIFont familyNames])
{
NSLog(@"%@", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family])
{
NSLog(@" %@", name);
}
}