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
/** | |
I've been using promises a lot lately after my first dance in callback hell. | |
I have not read (but did skim) any of the specs nor do I intend too. I also find the bedtime stories about | |
promises cute but far to wordy when I'm in a hurry. | |
So I decided to type up this for future reference, when next time I chain some promises together and am completly confused as | |
to why they don't work the way I expect. | |
Think of promises like an asynchronous try, catch, finally |
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
for i in $(ls | cut -d "." --complement -f2- ); do mkdir $i; done |
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
CLOUDINARY_URL=cloudinary://null | |
MANDRILL_API_KEY=null | |
COOKIE_SECRET="Cat Keyboard" | |
MONGO_URI="mongodb://localhost/myexample" | |
DOMAIN="myexample" | |
BRAND="Vendorlizer" |
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
//Here is a simple example. Pretend we are using express. | |
var app = express(); | |
var config; | |
var db = new ConfigServerThing(); | |
//This part is useless because the main loop exits before we call app.listen() | |
db.find(function(err, config) { | |
if(err) throw 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
//Of course you may want to do more configuration than this. | |
var app = express(); | |
var env = nunjucks.configure('/views', { | |
autoescape: true, | |
express: app, | |
tags: { | |
variableStart: '<$', | |
variableEnd: '$>' | |
} |
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({ |
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
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
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 (outerArg) { | |
return function (innerArg) { // closure function | |
return outerArg+innerArg; | |
}; |