Skip to content

Instantly share code, notes, and snippets.

View sstadelman's full-sized avatar
🚀

Stan Stadelman sstadelman

🚀
View GitHub Profile
@sstadelman
sstadelman / ScheduleRequest with completionHandler.m
Last active August 29, 2015 14:06
ScheduleRequest with completionHandler
- (void) scheduleRequest:(id<SODataRequestParam>)request completionHandler:(void(^)(NSArray *entities, id<SODataRequestExecution>requestExecution, NSError *error))completion
NSString *finishedSubscription = [NSString stringWithFormat:@"%@.%@", kRequestDelegateFinished, request];
[[NSNotificationCenter defaultCenter] addObserverForName:finishedSubscription
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *note) {
id<SODataRequestExecution>requestExecution = note.object;
@sstadelman
sstadelman / createEntityInterface.m
Last active August 29, 2015 14:06
createEntityInterface
-(void)createEntity:(id<SODataEntity>) entity withCompletion:(void(^)(BOOL success))completion;
@sstadelman
sstadelman / DataController declaration.h
Created September 17, 2014 20:37
DataController.h declaration
#import "ODataStore.h"
#import "SODataStore.h"
#import "SODataStoreSync.h"
#import "SODataStoreAsync.h"
#import "Framework-Constants.h"
@interface DataController : NSObject
@property (nonatomic, assign) WorkingModes workingMode;
@sstadelman
sstadelman / StoreForRequestResourcePath.m
Last active August 29, 2015 14:06
StoreForRequestResourcePath
-(id<ODataStore>)storeForRequestToResourcePath:(NSString *)resourcePath
{
/*
First, test if mode is online- or offline-only anyway.
*/
if (self.workingMode == WorkingModeOnline) {
return self.networkStore;
} else if (self.workingMode == WorkingModeOffline) {
@sstadelman
sstadelman / programmatic filter.m
Created November 5, 2014 21:27
[online] filtering entities when $filter not supported by back end
-(void)fetchContactsWithCompletion:(void(^)(NSArray *entities))completion {
NSString *resourcePath = @"ContactCollection;
[self scheduleRequestForResource:resourcePath withMode:SODataRequestModeRead withEntity:nil withCompletion:^(NSArray *entities, id<SODataRequestExecution> requestExecution, NSError *error) {
if (entities) {
NSMutableArray *completeEntities = [[NSMutableArray alloc] init];
@sstadelman
sstadelman / odata API $filter.m
Created November 5, 2014 21:29
[offline] filtering entities from the database
-(void)fetchContactsWithCompletion:(void(^)(NSArray *entities))completion {
NSString *resourcePath = @"ContactCollection?$filter=length(company) gt 0 and length(function) gt 0";
[self scheduleRequestForResource:resourcePath withMode:SODataRequestModeRead withEntity:nil withCompletion:^(NSArray *entities, id<SODataRequestExecution> requestExecution, NSError *error) {
if (entities) {
completion(entities);
@sstadelman
sstadelman / case.json
Last active August 29, 2015 14:22 — forked from d3noob/.block
{
"links" : [
{"source": "5530bcc5298d000e396ff280", "target": "5530bd47298d000e396ff281"},
{"source": "5530bd47298d000e396ff281", "target": "5530bd83298d000e396ff282"},
{"source": "5530bd47298d000e396ff281", "target": "5530bdcb298d000e396ff283"},
{"source": "5530bd83298d000e396ff282", "target": "5530be68298d000e396ff285"},
{"source": "5530bdcb298d000e396ff283", "target": "5530bd83298d000e396ff282"},
{"source": "5530bdcb298d000e396ff283", "target": "5530be28298d000e396ff284"},
{"source": "5530be28298d000e396ff284", "target": "5530bd83298d000e396ff282"},
{"source": "5530be28298d000e396ff284", "target": "5530be93298d000e396ff286"}
@sstadelman
sstadelman / gist:130a3e13cc39c478e8c0
Created June 29, 2015 22:13
Switch to older version of node, and to current
# Switch to older version (e.g.: v0.10.39)
sudo n 0.10.39
# install : node-v0.10.39
# mkdir : /usr/local/n/versions/node/0.10.39
# fetch : https://nodejs.org/dist/v0.10.39/node-v0.10.39-darwin-x64.tar.gz
# installed : v0.10.39
# Switch to current version
sudo n stable
# install : node-v0.12.5
@sstadelman
sstadelman / gist:50cd4bb27915d06df6072a078a0be82d
Last active November 22, 2016 00:40
UIEdgeOffsets for iOS devices in regular horizontal mode
iPhoneSE: portrait UIEdgeInsets(top: 0.0, left: 16.0, bottom: 0.0, right: 16.0) // compact
iPhoneSE: landscape UIEdgeInsets(top: 0.0, left: 20.0, bottom: 0.0, right: 20.0) // compact
iPhone6s: portrait UIEdgeInsets(top: 0.0, left: 16.0, bottom: 0.0, right: 16.0) // compact
iPhone6s: landscape UIEdgeInsets(top: 0.0, left: 20.0, bottom: 0.0, right: 20.0) // compact
iPhone6sPlus: portrait UIEdgeInsets(top: 0.0, left: 20.0, bottom: 0.0, right: 20.0) // compact
iPhone6sPlus: landscape UIEdgeInsets(top: 0.0, left: 32.0, bottom: 0.0, right: 32.0) // regular
iPhone7: portrait UIEdgeInsets(top: 0.0, left: 16.0, bottom: 0.0, right: 16.0) // compact
iPhone7: landscape UIEdgeInsets(top: 0.0, left: 20.0, bottom: 0.0, right: 20.0) // compact
iPhone7Plus: portrait UIEdgeInsets(top: 0.0, left: 20.0, bottom: 0.0, right: 20.0) // compact
iPhone7Plus: landscape UIEdgeInsets(top: 0.0, left: 32.0, bottom: 0.0, right: 32.0) // regular
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
<edmx:DataServices>
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Microsoft.OData.SampleService.Models.TripPin">
<EnumType Name="PersonGender">
<Member Name="Male" Value="0"/>
<Member Name="Female" Value="1"/>
<Member Name="Unknown" Value="2"/>
</EnumType>
<ComplexType Name="City">