Skip to content

Instantly share code, notes, and snippets.

View shmidt's full-sized avatar

Dima Shmidt shmidt

View GitHub Profile
@prabirshrestha
prabirshrestha / TextFieldChanges.m
Created August 2, 2012 13:53
Reactive Cocoa examples
@synthesize firstName = _firstName;
@synthesize txtFirstName = _txtFirstName;
[RACAbleSelf(self.firstName) subscribeNext:^(id x) { [self firstNameChanged:x]; }];
[self rac_bind:RAC_KEYPATH_SELF(self.firstName) to:self.txtFirstName.rac_textSubscribable];
- (void) firstNameChanged:(id)firstName {
NSLog(@"changed: %@", firstName);
}
@adib
adib / BSManagedDocument.h
Created September 11, 2012 06:07
An NSDocument subclass that supports asynchronous Core Data operations
//
// BSManagedDocument.h
//
// Created by Sasmito Adibowo on 29-08-12.
// Copyright (c) 2012 Basil Salad Software. All rights reserved.
// http://basilsalad.com
//
// Licensed under the BSD License <http://www.opensource.org/licenses/bsd-license>
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@xslim
xslim / AppDelegate.m
Created October 8, 2012 22:41
AFIncrementalStore with If-Modified-Since hack
// Connecting AFIncrementalStore & MagicRecord
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
PDDebugger *debugger = [PDDebugger defaultInstance];
[debugger connectToURL:[NSURL URLWithString:@"ws://localhost:9000/device"]];
[debugger enableNetworkTrafficDebugging];
[debugger forwardAllNetworkTraffic];
[debugger enableCoreDataDebugging];
@hlung
hlung / ActiveSupport_to_iOS_timezones.plist
Last active June 2, 2016 07:06
Map Rails ActiveSupport timezones to iOS readable timezone IDs.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Information</key>
<dict>
<key>Description</key>
<string>Map Rails ActiveSupport timezones to iOS readable timezone IDs.</string>
<key>Version</key>
<string>1.0</string>
@mrtj
mrtj / TJIntegerArray.h
Last active July 18, 2018 19:47
Simple Objective C wrapper around a C integer array. Supports fast enumeration via NSNumber objects. #integer #array #objective-c License: BSD
// Author: [email protected]
// License: BSD
#import <Foundation/Foundation.h>
@interface TJIntegerArray : NSObject <NSFastEnumeration>
{
NSInteger* _array;
}
@martinsik
martinsik / MyCalendar.h
Created March 8, 2013 09:47
Example of using EventKit on iOS 6+
#import <Foundation/Foundation.h>
@interface MyCalendar : NSObject
+ (void)requestAccess:(void (^)(BOOL granted, NSError *error))success;
+ (BOOL)addEventAt:(NSDate*)eventDate withTitle:(NSString*)title inLocation:(NSString*)location;
@end
NSMutableArray *abEmailAddresses = [NSMutableArray array];
NSMutableArray *abPhoneNumbers = [NSMutableArray array];
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(addressBook);
for (CFIndex i = 0; i < CFArrayGetCount(people); ++i) {
ABRecordRef aRecord = CFArrayGetValueAtIndex(people, i);
// phone numbers
ABMutableMultiValueRef phones = ABRecordCopyValue(aRecord, kABPersonPhoneProperty);
@nuthatch
nuthatch / NSManagedObject+Serialization.h
Last active May 8, 2019 11:25 — forked from pkclsoft/NSManagedObject+Serialization.h
Fixes for Peter Easdown's category 1. don't assume each Entity name matches the Class name. 2. strip DATE_ATTR_PREFIX when deserializing dates back into NSManagedObject 3. add support for NSOrderedSet 4. use set to keep traversal history, and allow classes to opt-out with serializationObjectsToSkip
@interface NSManagedObject (Serialization)
- (NSDictionary*) toDictionary;
- (void) populateFromDictionary:(NSDictionary*)dict;
+ (NSManagedObject*) createManagedObjectFromDictionary:(NSDictionary*)dict
inContext:(NSManagedObjectContext*)context;
@end
@pixnbit
pixnbit / CIFaceFeature+UIImageOrientation.h
Last active May 3, 2018 01:59
Category on CIFaceFeature to convert CGPoint and CGRect with respect to UIImageOrientation, also with handy helpers to convert locations inside of a given UIView size.
//
// CIFaceFeature+UIImageOrientation.h
//
//
// Created by Xiaochao Yang on 6/9/13.
// Copyright (c) 2013 Xiaochao Yang. All rights reserved.
//
#import <CoreImage/CoreImage.h>
@aegzorz
aegzorz / CGRect+Additions.h
Created June 17, 2013 14:35
Some functions for dealing with CGRects
static __inline__ CGRect CGRectFromCGSize( CGSize size ) {
return CGRectMake( 0, 0, size.width, size.height );
};
static __inline__ CGRect CGRectMakeWithCenterAndSize( CGPoint center, CGSize size ) {
return CGRectMake( center.x - size.width * 0.5, center.y - size.height * 0.5, size.width, size.height );
};
static __inline__ CGRect CGRectMakeWithOriginAndSize( CGPoint origin, CGSize size ) {
return CGRectMake( origin.x, origin.y, size.width, size.height );