Skip to content

Instantly share code, notes, and snippets.

View canaksoy's full-sized avatar
🎯
Focusing

Can Aksoy canaksoy

🎯
Focusing
View GitHub Profile
@a7madgamal
a7madgamal / dark.md
Last active July 14, 2023 04:00
Dark mode for Slack on MacOS
@z-rui
z-rui / 1.txt
Created March 31, 2017 15:41
通用规范汉字表 (2013)
@syky27
syky27 / APIWrapper+Generic.swift
Created February 28, 2017 14:58
Realm + API + Generics
//
// APIWrapper+Generic.swift
// OPTIFY
//
// Created by Tomas Sykora, jr. on 12/09/2016.
// Copyright © 2016 AJTY, s.r.o. All rights reserved.
//
import RealmSwift
import Alamofire
@syky27
syky27 / realm_generic_network.swift
Last active February 14, 2018 13:01
REALM Generic data fetch
protocol APIProtocol {
init(_ j: [String: Any])
}
extension APIWrapper {
func getAllObjectsOf<T: APIProtocol>(type: T.Type, request: URLRequestConvertible, _ completion: @escaping (_ result: (T.Type, ResultState)) -> Void) {
Alamofire.request(request).validate().response { response in
do {
if let data = response.data {
@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);
}
}
@timonus
timonus / UIWindow+AppSwitchScrollStopper.h
Last active January 6, 2017 19:01
AppSwitchScrollStopper
// UIWindow+AppSwitchScrollStopper.h
// Created by Tim Johnsen on 3/27/16.
#import <UIKit/UIKit.h>
@interface UIWindow (AppSwitchScrollStopper)
/// Call this early on in your app's lifecycle to avoid
/// scroll-related flashing when your app resumes from the background
- (void)installAppSwitchScrollStopper;