Skip to content

Instantly share code, notes, and snippets.

View adib's full-sized avatar

Sasmito Adibowo adib

View GitHub Profile
@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
@adib
adib / ViewController.swift
Created July 29, 2017 14:55
View Model app restoration setup
class ViewController : UIViewController {
override func decodeRestorableState(with coder: NSCoder) {
super.decodeRestorableState(with: coder)
// force class initialization for the sake of state restoration
ViewModel.classInit
viewModel = coder.decodeObject(of: ViewModel.self, forKey: "viewModel")
}
}
@adib
adib / gist:5341936
Last active July 7, 2016 07:02
Custom Cookie Storage, rev 2.
//
// BSHTTPCookieStorage.h
//
// Created by Sasmito Adibowo on 02-07-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
@adib
adib / BSAlertViewDelegateBlock.h
Created January 2, 2014 15:08
Generic UIAlertViewDelegate implementation that translates into a convenient block-based API. Go to http://cutecoder.org to read how to use this.
//
// BSAlertViewDelegateBlock.h
// SpeechTimer2
//
// Created by Sasmito Adibowo on 25-12-13.
// Copyright (c) 2013-2014 Basil Salad Software. All rights reserved.
//
// 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
@adib
adib / gist:4752376
Last active December 12, 2015 09:29
JSON parsing data type support
// JSONSupport.m
// Created by Sasmito Adibowo on 29-08-12.
// Copyright (c) 2012 Basil Salad Software. .
// 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
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
@adib
adib / gist:3811879
Created October 1, 2012 13:45
Method of the block that AppCode 1.6 couldn't refactor
+(void) refreshFeedWithType:(BSYammerFeedType) feedType
threadType:(BSYammerFeedThreadType) threadType
olderThan:(BSYammerMessage*) oldestMessage
newerThan:(BSYammerMessage*) latestMessage
associatedWith:(NSManagedObject<BSYammerEntity>*) associatedEntity
fromAccount:(BSYammerContext*) accountContext
limit:(int) maxMessages
toManagedObjectContext:(NSManagedObjectContext*) objectContext
completionHandler:(void(^)(NSArray* objectIDs,NSError* errorOrNil)) completionHandler
{
@adib
adib / BSManagedDocument.h
Created September 6, 2012 06:30
Asynchronous saving of Core Data document for Mac OS X
//
// BSManagedDocument.h
// Scuttlebutt
//
// Created by Sasmito Adibowo on 29-08-12.
// Copyright (c) 2012 Basil Salad Software. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@adib
adib / NSArray+FoundationAdditions.m
Created July 23, 2012 13:09
Sparse Array - FoundationAdditions
@implementation NSArray (FoundationAdditions)
-(id) objectAtCheckedIndex:(NSUInteger) index {
if(index >= self.count) {
return nil;
} else {
id result = [self objectAtIndex:index];
return result == [NSNull null] ? nil : result;
}
}
@adib
adib / gist:2020649
Created March 12, 2012 08:06
Perform Object After Delay
[[NSOperationQueue mainQueue] performSelector:@selector(addOperation:) withObject:^{
// do your stuff here
} afterDelay:3.0];
//
// BSGLView.h
// AirKill
//
// Created by Sasmito Adibowo on 07-06-14.
// Basil Salad Software, http://basilsalad.com
//
// This code is in the public domain.
#import "CCGLView.h"