Skip to content

Instantly share code, notes, and snippets.

View mrryanjohnston's full-sized avatar
😎
Set your status

Ryan Johnston mrryanjohnston

😎
Set your status
View GitHub Profile
Cat = {}
Cat.sound = 'meow!'
Cat.speak = function () {
console.log(this.sound)
}
setTimeout(Cat.speak.bind(Cat), 2000)
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)
var http = require('http');
var options = {
host: 'url',
port: 80,
path: 'path',
method: 'POST'
};
var req = function(callback) {
> 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'
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);
-if (typeof title!=='undefined')
h1= title
-else
h1 'Default Title'
┌─( 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
Game.prototype.timer = function(seconds, callback) {
seconds || (seconds = 5)
var timerInterval = setInterval(function() {
if (--seconds==0) {
callback();
clearInterval(timerInterval);
}, 1000*seconds);
}
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() {