Skip to content

Instantly share code, notes, and snippets.

View sgoodwin's full-sized avatar

Samuel Goodwin sgoodwin

View GitHub Profile
> [email protected] install /usr/local/lib/node_modules/levelmeup/node_modules/level/node_modules/leveldown
> node-gyp rebuild
/usr/local/lib/node_modules/npm/bin/node-gyp-bin/node-gyp: line 2: node: command not found
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the leveldown package,
npm ERR! not with npm itself.
@sgoodwin
sgoodwin / gist:6686053
Created September 24, 2013 15:00
How not to use NSFetchedResultsController
- (NSArray *)dataSource
{
return [[[self fetchedResultsController] fetchedObjects] copy];
}
@sgoodwin
sgoodwin / gist:4113536
Created November 19, 2012 20:06
Switch free controller.
@implementation RWSViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
RWSStaticSection *section1 = [[RWSStaticSection alloc] init];
RWSStaticSection *section2 = [[RWSStaticSection alloc] init];
_sections = @[section1, section2];
}
@sgoodwin
sgoodwin / gist:4113451
Created November 19, 2012 19:57
A new object emerges!
@protocol RWSSection
- (NSUInteger)numberOfObjects;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRow:(NSInteger)row;
@end
@interface RWSStaticSection : NSObject<RWSSection>
@property(nonatomic, readonly) NSArray *items;
@end
@sgoodwin
sgoodwin / gist:4113332
Created November 19, 2012 19:48
NSFetchedResultsController's switchless version.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if<NSFetchedResultsSectionInfo> section = [self.resultsController sections][indexPath.section];
return [section numberOfObjects];
}
@sgoodwin
sgoodwin / gist:4113105
Created November 19, 2012 19:28
Moving the junk into it's own method at least.
typedef enum {
RWSSectionInfo,
RWSSectionDynamic,
RWSSectionCount
}RWSSection;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
RWSSection section = indexPath.section;
switch(section){
@sgoodwin
sgoodwin / gist:4113057
Created November 19, 2012 19:22
UITableViewDataSource method with switches, but with symbols.
typedef enum {
RWSSectionInfo,
RWSSectionDynamic,
RWSSectionCount
}RWSSection;
const NSInteger kNumberOfInfoRows = 2;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
@sgoodwin
sgoodwin / gist:4112991
Created November 19, 2012 19:15
UITableViewDataSource method with switches.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
switch(section){
case 0:
return 2;
break;
case 1:
return [self.items count];
break;
}
var target = UIATarget.localTarget();
var app = target.frontMostApp();
var window = app.mainWindow();
var testName = "Dummy Test";
function dummyTest(){
UIALogger.logStart(testName);
var button = window.buttons()["Go"];
@sgoodwin
sgoodwin / gist:3880208
Created October 12, 2012 16:50
Saving data downloaded off the inter webs
NSString *dataPath = [weakOperation tmpFilePath];
NSManagedObjectContext *context = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
[context setParentContext:mainContext];
[context performBlock:^{
NSError *findingError = nil;
GOFeedItem *thisItem = (GOFeedItem *)[context existingObjectWithID:objectID error:&findingError];
if(!thisItem){
NSLog(@"Error finding item %@: %@", [feedItem title], [findingError userInfo]);
}