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
/*The Great Dependency Injection.*/ | |
//This is psuedo code. Screw the syntax rules! | |
//No dependency injection. | |
class User { | |
private Database db; | |
private String email; |
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 ns= {}; | |
ns.Object = function () { | |
var that = {}; | |
that.toString = function () { | |
return 'I am an Object!!'; | |
} |
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
//One of the popular concepts in OOP style programming is the concept of loose coupling. | |
//Your objects should have everything they need to carry out their duties from the time you instansiate them (new Object). | |
//Failing that, you should be able to inject any missing dependecies into your classes whenever necessary. | |
//This does not mean you go and create a whole bunch of setters. | |
//Wrong! | |
dog = new Animal(); | |
dog.setColor('blue'); |
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
s |
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
Does this 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
function outer (outerArg) { | |
return function (innerArg) { // closure function | |
return outerArg+innerArg; | |
}; |
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
func outer (outerArg int) func(int) { //this could also be a custom type | |
return func (innerArg int) int { // closure func | |
return outerArg+innerArg; | |
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 outer (int $outerArg) { //this could also be a custom type | |
return function (int $innerArg) { // closure function | |
return $outerArg+$innerArg; | |
} | |
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
<!-- Add the following lines to theme's html code right before </head> --> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> | |
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script> | |
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script> | |
<!-- | |
Usage: just add <div class="gist">[gist URL]</div> | |
Example: <div class="gist">https://gist.github.com/1395926</div> | |
--> |
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
/** | |
* Email is a wrapper around the keystone Email object. | |
* @class Email | |
* | |
* @constructor | |
* | |
*/ | |
module.exports = function Email(name, keystone, nunjucks) { | |
return new keystone.Email({ |
OlderNewer