This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* promise object | |
*/ | |
function getUserWithId(id) { | |
return new Promise((resolve, reject) => { | |
// Look for a user with id in the database | |
User.find({_id: id}, (user, err) => { | |
if(err) return reject(err); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This function returns a promise to fetch a user by id | |
*/ | |
function getUserWithId(id) { | |
return new Promise((resolve, reject) => { | |
// Look for a user with id in the database | |
User.find({_id: id}, (user, err) => { | |
if(err) return reject(err); | |
// on success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* promise object | |
*/ | |
function getUserWithId(id) { | |
return new Promise((resolve, reject) => { | |
// Look for a user with id in the database | |
User.find({_id: id}, (user, err) => { | |
if(err) return reject(err); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* promise object | |
* Explanation: When creating a promise object, it is supposed to be in a pending state. | |
* If a certain process succeeded, we call resolve() callback and it is assumed resolved, | |
* also called fulfilled. Meaning, you fulfilled your promise :) | |
* If the process failed, than the promise is rejected. | |
*/ | |
let promise = new Promise((resolve, reject) => { | |
// We're now in a pending state | |
User.find({}, (user, err) => { // <-- this an async work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <signal.h> | |
#include <stdio.h> | |
#include <wiringPi.h> | |
#define LED 4 | |
#define PIR 5 | |
volatile char isRunning = 1; | |
void processMotionDetection(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <wiringPi.h> | |
#define LED 4 | |
#define PIR 5 | |
int main() { | |
// doe een setup om wiringPi te gebruiken | |
if(wiringPiSetup()<0) { | |
printf("Error setting up wiringPi..."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in some class.h | |
@protocol ProtocolName | |
@required | |
// list of required methods | |
@optional | |
// list of optional methods | |
@end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NSString+MyAddition.h | |
@interface NSString(MyAdditions) | |
- (NSString *) getCopyRightString; | |
@end | |
@implementation NSString(MyAdditions) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSString *) someMethod:(int) id withError:(NSError **)errorPtr{ | |
if(id == 1) | |
{ | |
return @"Execution of some code..."; | |
} | |
else | |
{ | |
NSString *domain = @"com.MyCompany.MyApplication.ErrorDomain"; | |
NSString *desc =@"Unable to complete the process"; | |
NSDictionary *userInfo = [[NSDictionary alloc] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#if DEBUG == 0 | |
#define DBLog(...) | |
#elif DEBUG == 1 | |
#define DBLog(...) NSLog(__VA_ARGS__) | |
#endif | |
int main() |