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
#!/bin/bash | |
# Credits to http://askubuntu.com/a/343567 | |
sudo apt-get install python-software-properties -y | |
sudo add-apt-repository ppa:ondrej/php5 -y | |
sudo apt-get update -y | |
sudo apt-get install php5 -y | |
echo "" |
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
/* From https://github.com/brendanashworth/wookie | |
* src/util.h | |
* licensed under MIT license | |
*/ | |
/** | |
* A debug macro that prints out file, line number, then message. | |
* @param msg The debug message to print. | |
*/ | |
#define DEBUG(msg) printf("[DEBUG] %s:%d; %s\n", __FILE__, __LINE__, msg) |
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
var util = require('util'); | |
var events = require('events'); | |
// Create the object constructor | |
function Cat(name) { | |
this.name = name; | |
} | |
// Inherit the EventEmitter | |
util.inherits(Cat, events.EventEmitter); |
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
Cat.prototype.meow = function(message) { | |
this.emit('meow', message); | |
} | |
// Create a cat | |
var kitty = new Cat('Mittens'); | |
kitty.on('meow', function(msg) { | |
console.log('We got a message from Mittens:', msg); | |
}); | |
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
kitten.on('meow', function(msg) { | |
console.log(msg); | |
}); |
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
kitten.emit('meow', msg); |
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
var foo = 10; // any value works | |
foo.__proto__.test = function() { | |
console.log("Success"); | |
}; | |
foo.test(); |
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 is the constructor | |
function Client(name, age) { | |
this.name = name; | |
this.age = age; | |
} | |
Client.prototype.contact = function() { | |
console.log("Now contacting " + this.name + "..."); | |
} |
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
Client.prototype.zipcode = 12345; | |
// Utilizes a closure | |
Client.prototype.defaultAge = (function() { | |
return prompt("What should the default age be?"); | |
})(); |
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
function Person(age) { | |
if (age > 18) this.age = age; | |
} | |
Person.prototype.age = 18; |