Skip to content

Instantly share code, notes, and snippets.

View iltercengiz's full-sized avatar

Ilter Cengiz iltercengiz

View GitHub Profile
@iltercengiz
iltercengiz / gist:9619712
Last active August 29, 2015 13:57
keybase.md
### Keybase proof
I hereby claim:
* I am iltercengiz on github.
* I am iltercengiz (https://keybase.io/iltercengiz) on keybase.
* I have a public key whose fingerprint is 6408 B427 DFBB 67BC 40EA 89A8 131F 8EC7 BB43 223B
To claim this, I am signing this object:
@iltercengiz
iltercengiz / gist:eb0dabe34463e3509286
Last active August 29, 2015 14:08
Generate 1x1 sized UIImage from UIColor
+ (UIImage *)imageFromColor:(UIColor *)color {
UIImage *image = ({
CGRect rect = CGRectMake(0.0, 0.0, 1.0, 1.0);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
image;
// Playground - noun: a place where people can play
import UIKit
import Foundation
let timeInterval = NSDate().timeIntervalSince1970
let date = NSDate(timeIntervalSince1970: timeInterval)
let dateFormatter = NSDateFormatter()
@iltercengiz
iltercengiz / Transliterate.m
Last active August 29, 2015 14:13
Get rid of accented characters
NSString *string = [@"Fıstıkçı Şahap" stringByFoldingWithOptions:NSDiacriticInsensitiveSearch
locale:[NSLocale localeWithLocaleIdentifier:@"en"]];
@iltercengiz
iltercengiz / ValidPhoneNumber.m
Created February 10, 2015 08:47
Checks validation of a given phone number
- (BOOL)isValidPhoneNumber:(NSString *)phoneNumberString {
NSError *error = nil;
NBPhoneNumber *phoneNumber = [self.util parse:phoneNumberString defaultRegion:self.region error:&error];
if (error) {
return NO;
} else {
return [self.util isValidNumber:phoneNumber];
@iltercengiz
iltercengiz / alternative_button_layout.m
Last active December 16, 2016 05:06
Alternative Button
self.imageView.frame = (CGRect){.origin = (CGPoint){.x = margin, .y = margin}, .size = (CGSize){.width = imageViewWidth, .height = imageViewWidth}};
self.imageView.center = (CGPoint){.x = CGRectGetWidth(self.frame) / 2.0, .y = imageViewWidth / 2.0 + margin};
[self.titleLabel sizeToFit];
self.titleLabel.frame = (CGRect){.origin = (CGPoint){.x = margin, .y = imageViewWidth + 2 * margin}, .size = self.titleLabel.frame.size};
self.titleLabel.center = (CGPoint){.x = CGRectGetWidth(self.frame) / 2.0, .y = CGRectGetHeight(self.frame) - CGRectGetHeight(self.titleLabel.frame) / 2.0 - margin};
import Foundation
import UIKit
let date = NSDate(timeIntervalSince1970:1426003200)
let dateFormatter = NSDateFormatter()
dateFormatter.dateStyle = .MediumStyle
dateFormatter.stringFromDate(date)
import Foundation
import UIKit
let date = NSDate(timeIntervalSince1970:1426003200)
let dateFormatter = NSDateFormatter()
dateFormatter.dateStyle = .MediumStyle
dateFormatter.stringFromDate(date)
@iltercengiz
iltercengiz / editing_changed.m
Last active December 16, 2016 05:12
Editing Changed
[self.textField addTarget:self action:@selector(textFieldDidChangeText:) forControlEvents:UIControlEventEditingChanged];
- (IBAction)textFieldDidChangeText:(UITextField *)textField {
NSLog(@"Updated text: %@", textField.text);
}