This file contains hidden or 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
Cat = {} | |
Cat.sound = 'meow!' | |
Cat.speak = function () { | |
console.log(this.sound) | |
} |
This file contains hidden or 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
setTimeout(Cat.speak.bind(Cat), 2000) |
This file contains hidden or 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
var Animal = function(sound) { | |
this.sound = sound | |
self = this | |
} | |
Animal.prototype.speak = function() { | |
console.log(self.sound) | |
} | |
var cat = new Animal('meow') | |
cat.speak() | |
setTimeout(cat.speak, 1000) |
This file contains hidden or 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
var http = require('http'); | |
var options = { | |
host: 'url', | |
port: 80, | |
path: 'path', | |
method: 'POST' | |
}; | |
var req = function(callback) { |
This file contains hidden or 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
> typeof new String("test") | |
'object' | |
> typeof "test" | |
'string' | |
> var myString = new String("test") | |
> myString | |
{ '0': 't', '1': 'e', '2': 's', '3': 't' } | |
> var myOtherString = "test" | |
> myOtherString | |
'test' |
This file contains hidden or 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
User.find({}).sort('roundwins', -1).limit(3).execFind(function(err, foundusers) { | |
var place = -1; | |
var places = ['roundfirsts', 'roundseconds', 'roundthirds']; | |
foundusers.forEach(function(user) { | |
//Alright, so, sorry about this one, but: | |
//Increase the document's property equal to user.'whatever place', where | |
//'whatever place' is determined from the value of place increased by 1 | |
//as an index of the places array | |
console.log(place); | |
console.log(user); |
This file contains hidden or 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
-if (typeof title!=='undefined') | |
h1= title | |
-else | |
h1 'Default Title' |
This file contains hidden or 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
┌─( ryan ) - ( ~/git/rock-paper-scissors-node ) | |
└─> jitsu logs app rock-paper-scissors 10 | |
info: Welcome to Nodejitsu | |
info: It worked if it ends with Nodejitsu ok | |
info: Executing command logs app rock-paper-scissors 10 | |
info: Authenticated as mrryanjohnston | |
error: Error running command logs app rock-paper-scissors 10 | |
error: Nodejitsu Error (500): Internal Server Error | |
warn: Error returned from Nodejitsu | |
error: Error: socket hang up |
This file contains hidden or 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
Game.prototype.timer = function(seconds, callback) { | |
seconds || (seconds = 5) | |
var timerInterval = setInterval(function() { | |
if (--seconds==0) { | |
callback(); | |
clearInterval(timerInterval); | |
}, 1000*seconds); | |
} | |
This file contains hidden or 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
var Deck = exports.Deck = function(newSize, newUpper, newLower) { | |
this.size = newSize || 10; | |
this.cards = []; | |
this.cardIterator = 0; | |
this.upperBound = newUpper || 1; | |
this.lowerBound = newLower || 10; | |
this._generateCards(); | |
} | |
Deck.prototype.getSize = function() { |
OlderNewer