Skip to content

Instantly share code, notes, and snippets.

View metasansana's full-sized avatar
🕺
Wine on a buffer.

Lasana Murray metasansana

🕺
Wine on a buffer.
View GitHub Profile
@metasansana
metasansana / broken by promises
Last active August 29, 2015 14:10
Broken by promises
/**
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
@metasansana
metasansana / gist:107132f1920cb5a1d7cc
Created August 4, 2014 00:55
Make directories based on the files in a folder (excluding the extensions).
for i in $(ls | cut -d "." --complement -f2- ); do mkdir $i; done
@metasansana
metasansana / gist:1d06c9adf5c6697c0f98
Created July 20, 2014 02:12
Vendorlizer Sample .env file
CLOUDINARY_URL=cloudinary://null
MANDRILL_API_KEY=null
COOKIE_SECRET="Cat Keyboard"
MONGO_URI="mongodb://localhost/myexample"
DOMAIN="myexample"
BRAND="Vendorlizer"
//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;
@metasansana
metasansana / nunjucks
Last active August 29, 2015 14:03
KeystoneJS with nunjucks.
//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: '$>'
}
@metasansana
metasansana / gist:d043fbeb3338c5ab1622
Created June 26, 2014 23:47
Render email templates with nunjucks in KeystoneJS.
/**
* Email is a wrapper around the keystone Email object.
* @class Email
*
* @constructor
*
*/
module.exports = function Email(name, keystone, nunjucks) {
return new keystone.Email({
<!-- 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>
-->
@metasansana
metasansana / phpclosure
Created September 1, 2013 15:01
PHP closure.
function outer (int $outerArg) { //this could also be a custom type
return function (int $innerArg) { // closure function
return $outerArg+$innerArg;
}
@metasansana
metasansana / golangclosure
Created September 1, 2013 14:58
Go language closure.
func outer (outerArg int) func(int) { //this could also be a custom type
return func (innerArg int) int { // closure func
return outerArg+innerArg;
@metasansana
metasansana / jsclosure
Created September 1, 2013 14:54
Javascript closure
function outer (outerArg) {
return function (innerArg) { // closure function
return outerArg+innerArg;
};