Skip to content

Instantly share code, notes, and snippets.

@fgarcia
fgarcia / gist:3968236
Created October 28, 2012 10:13
Base Podfile template for projects targeting OSX and iOS
# vim:ft=Ruby
#
# Base Podfile template for projects targeting OSX and iOS
#
# Author: Francisco Garcia <public@francisco-garcia.net>
# https://github.com/fgarcia
#
# Last Update: 2012-11-28
@fgarcia
fgarcia / gist:3983738
Created October 30, 2012 23:20
unit testing with coredata
{
Entity *_this;
}
- (void)setUp
{
[MagicalRecord setupCoreDataStackWithInMemoryStore];
_this = [Entity MR_createEntity];
}
@fgarcia
fgarcia / gist:3985726
Created October 31, 2012 07:58
test notification posting with #ocmock
- (void)testNotificationWhenEditingNonTodayStat
{
// given
id mock = [OCMockObject observerMock];
[[NSNotificationCenter defaultCenter] addMockObserver:mock name:FGNPastStatWasUpgraded object:nil];
[[mock expect] notificationWithName:FGNPastStatWasUpgraded object:nil];
_this.date = [DLCommon dateFromString:@"2010-04-01"];
// when
_this.reviewedValue++;
@fgarcia
fgarcia / gist:3986458
Created October 31, 2012 11:01
issue report #template
// problem
SourceTree does not behave as Git when adding and committing a folder with ignored parts
// given
User has a global Git ignore file with the pattern "xcuserdata"
// when
User add an Xcode project file like MyApp.xcodeproj/
User commit changes
@fgarcia
fgarcia / gist:4011699
Created November 4, 2012 12:27
Open file and run a #core-data query with all #lowlevel details shown
id error;
NSManagedObjectModel *mom = [NSManagedObjectModel mergedModelFromBundles:nil];
NSPersistentStoreCoordinator *psc = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom];
NSURL *file_url = [NSURL URLWithString:@"file://localhost/private/tmp/store.sqlite"];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
NSPersistentStore *store_dil = [psc addPersistentStoreWithType:NSSQLiteStoreType
@fgarcia
fgarcia / gist:4086172
Created November 16, 2012 10:14
list of #git branches sorted by last commit date
for C in $(git for-each-ref --sort=committerdate refs/heads --format='%(refname)' | sort )
do
git show -s --format="%ci $C" "$C"
done
@fgarcia
fgarcia / gist:4134768
Created November 23, 2012 09:38
#post Surviving Core Data 1
- (void)awakeFromInsert
{
[super awakeFromInsert];
self.todayStats = [Stats MR_createInContext:[self managedObjectContext]];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSManagedObjectID *self_id = [self objectID];
[nc postNotificationName:FGN_NEW_CONTENT_NOTIFICATION object:self_id];
}
@fgarcia
fgarcia / gist:4134806
Created November 23, 2012 09:46
#post Surviving Core Data 2
- (void)awakeFromInsert
{
[super awakeFromInsert];
if (self.initialized) {
self.todayStats = [Stats MR_createInContext:[self managedObjectContext]];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSManagedObjectID *self_id = [self objectID];
[nc postNotificationName:FGN_NEW_CONTENT_NOTIFICATION object:self_id];
@fgarcia
fgarcia / gist:4134870
Created November 23, 2012 10:07
#post Surviving Core Data 3
- (void)awakeFromInsert
{
[super awakeFromInsert];
BOOL in_main_context = self.managedObjectContext == MAIN_CONTEXT;
if (! in_main_context) return;
if (self.initialized) return;
self.todayStats = [Stats MR_createInContext:[self managedObjectContext]];
@fgarcia
fgarcia / gist:4169456
Created November 29, 2012 14:32
podspec for an internal static library
Pod::Spec.new do |s|
s.name = "CocoYAML"
s.version = "0.0.1"
s.author = { "Francisco Garcia" => "public@francisco-garcia.net" }
s.summary = "libyaml wrapper"
s.homepage = "http://www.francisco-garcia.net"
s.license = { :type => 'MIT' }
s.platform = :osx
s.source = { :git => 'git@home:cocoyaml', :branch => 'master' }