Skip to content

Instantly share code, notes, and snippets.

View objectiveSee's full-sized avatar

Danny Ricciotti objectiveSee

  • Starship Studios
View GitHub Profile
/////// .h ///////
// Core Data MOM file: http://grab.by/jf4c
// NOTE: Some attributes excluded in the code below
@interface CDUserPhotos : NSManagedObject
@property (nonatomic, retain) NSData * data; // core data attribute
@property (nonatomic, readonly) NSArray* albums; // not an attribute. Calculate from self.data
// TODO: Use weak self to avoid retaining self for a long time (during long downloads)
SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadWithURL:imageURL
options:0
progress:nil
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
{
if ( [self.imageURL isEqual:imageURL] &&
image &&
!error )
Matchmaking.gameNear = function(user, location, callback) {
console.log('[DEBUG] [gameNear]');
Q.fcall(this.updateUserLocation.bind(this,user,location)) // TODO: why do we have to pass 'this' first in bind() params?
.then(this.findGamesNearby.bind(this,user,location))
.then(function(games_nearby) {
foo(games_nearby);
}).done();
};
/**
* question: how can I rewrite lines 8 & 9 to not use an intermediate function?
*
*
*/
Q.fcall(this.findGamesNearby.bind(this,user,location))
.then(function(games_nearby) {
return matchmaking.makeGameIfNeeded(games_nearby, user, location);
});
double delayInSeconds = 0.3;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
NSLog(@"!!!!!!! Go time !!!!!!");
EAForcedUpdateViewController *f = [[EAForcedUpdateViewController alloc] initWithNibName:nil bundle:nil];
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
window.rootViewController = f;
// [self.window resignKeyWindow];
// [self.window setHidden:YES];
// bootstrap!
require('../lib/globals.js');
(function() {
var HttpServer = require('../lib/http_server.js');
var SocketServer = require('../lib/socket_server.js');
var h = new HttpServer();
var s = new SocketServer();
shitFinder.findGamesPastDay()
.then(shitFinder.printShit())
.done(function (result) {
console.log('DONE! res=', result); // logs the result from findGamesPastDay instead of foo
process.exit(0)
}, function (error) {
process.exit(1);
});
printShit: function(result) {
/**
* NOTE: game.participants contains 3 objects.
GOAL: I would like each promise created in lines 31-43 to be executed in serial.
I do not want any line of code in drawAnswers() to be called before the previous promise is fulfilled.
BUG: The log in drawAnswers() shows me that drawAnswers() is being called 3 times before the
1st promise from drawAnswers() is fulfilled.
@objectiveSee
objectiveSee / gist:5968782
Created July 10, 2013 18:24
Right now drawAnswers() gets called before makeDeckIfNeeded() promise is fulfilled. How do I fix that? Does it involve bind()?
return Q.fcall(game.makeDeckIfNeeded.bind(game))
.then(game.deck.drawAnswers(participant, cardsToGet))
.then(function(newCards) {
// add newcards to hand
var newHand = _.union(h,newCards);
participant.hand = newHand;
return Q.fcall(function() { return game.update(); });
});
@objectiveSee
objectiveSee / gist:6023351
Created July 17, 2013 18:52
This is the output of running 'pod install'. i Dont recognize any of the pods in this list.
Analyzing dependencies
[!] Pod::Executable pull
Updating a1d1b07..de42d82
error: Your local changes to the following files would be overwritten by merge:
AFKissXMLRequestOperation/0.0.1/AFKissXMLRequestOperation.podspec
AdMob/6.4.2/AdMob.podspec