Skip to content

Instantly share code, notes, and snippets.

View onmyway133's full-sized avatar
😇
What you don't know is what you haven't learned

Khoa onmyway133

😇
What you don't know is what you haven't learned
View GitHub Profile
@RuiAAPeres
RuiAAPeres / gist:11190505
Created April 22, 2014 18:59
Swizzling valueForKey: and objectForKey:
#import <objc/runtime.h>
@implementation NSDictionary (Swizzled)
static void swizzInstance(Class class, SEL originalSel, SEL newSel)
{
Method origMethod = class_getInstanceMethod(class, originalSel);
Method newMethod = class_getInstanceMethod(class, newSel);
method_exchangeImplementations(origMethod, newMethod);
@khanlou
khanlou / SKValueObject.h
Last active August 29, 2015 14:01
SKValueObject
//
// SKValueObject.h
// TinyType
//
// Created by Soroush Khanlou on 5/15/14.
// Copyright (c) 2014 Soroush Khanlou. All rights reserved.
//
#import <Foundation/Foundation.h>
@k0nserv
k0nserv / 2015.m
Last active August 29, 2015 14:12
2014 and 2015
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"YYYY";
NSDate *date = [NSDate dateWithTimeIntervalSince1970:1419872056];
NSLog (@"%@", [dateFormatter stringFromDate:date]); // 2015
@onmyway133
onmyway133 / SimpleCache.m
Last active September 26, 2015 19:47
SimpleCache.m
// CacheItem.h
@interface CacheItem : RLMObject
@property NSString *key;
@property NSData *value;
@end
// CacheItem.m
@implementation CacheItem
@chriseidhof
chriseidhof / presentation.md
Created June 28, 2014 13:00
MobileOptimized Presentation

[fit] Functional Programming in

[fit] Swift

Chris Eidhof - objc.io - June 28, Minsk



@aryaxt
aryaxt / Multiple Storyboard Usage.txt
Last active December 17, 2015 02:05
Multiple Storyboard Usage
@interface UIStoryboard (Additions)
- (id __nullable)tryInstantiateViewControllerWithIdentifier:(NSString * __nonnull)identifier;
@end
@implementation UIStoryboard (Additions)
- (id)tryInstantiateViewControllerWithIdentifier:(NSString *)identifier {
@try {
return [self instantiateViewControllerWithIdentifier:identifier];
}
@catch (NSException *exception) {
@hjue
hjue / UAMacros.h
Created December 8, 2013 09:04
UAMacros.h
#define UA_isIPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define UA_isIPhone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define UA_isRetinaDevice ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] >= 2)
#define UA_isMultiTaskingSupported ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)] && [[UIDevice currentDevice] isMultitaskingSupported])
#define UA_runOnMainThread if (![NSThread isMainThread]) { dispatch_sync(dispatch_get_main_queue(), ^{ [self performSelector:_cmd]; }); return; };
@vinhnx
vinhnx / iOS 9 App Transport Security.md
Last active January 8, 2016 11:33
iOS 9 App Transport Security

iOS 9 App Transport Security

Starting from iOS 9, App Transport Security enforces to use secure HTTPS requests by default.

App Transport Security

App Transport Security (ATS) enforces best practices in the secure connections between an app and its back end. ATS prevents accidental disclosure, provides secure default behavior, and is easy to adopt; it is also on by default in iOS 9 and OS X v10.11. You should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one.

If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you

@joshaber
joshaber / gist:4238342
Created December 8, 2012 02:54
ReactiveCocoa stopwatch with reset
self.startButton.rac_command = [RACCommand command];
self.stopButton.rac_command = [RACCommand command];
self.resetButton.rac_command = [RACCommand command];
static const CGFloat interval = 0.01;
__unsafe_unretained id weakSelf = self;
// Signal id -> Signal Signal Number
// Map each click of the start button to a signal that fires at our interval
// and stops when the stop button's clicked.
id<RACSignal> start = [self.startButton.rac_command map:^(id _) {
@ColinEberhardt
ColinEberhardt / gist:b4bf4e4566ffa88afcda
Created March 20, 2015 08:14
Pipe forward operator and curried free functions = fluent interface
// meet Stringy - a simple string type with a fluent interface
struct Stringy {
let content: String
init(_ content: String) {
self.content = content
}
func append(appendage: Stringy) -> Stringy {