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
package main | |
import ( | |
"net/http" | |
"database/sql" | |
"fmt" | |
"log" | |
"os" | |
) |
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
### | |
# Node.js app Docker file | |
# | |
# Some basic build instructions: | |
# ``` | |
# # you should delete node_modules b/c you don't want that copied during 'ADD' | |
# docker build -t thom-nic/node-bootstrap . | |
# # run a shell in the container to inspect the environment (as root): | |
# docker run --rm -itu root thom-nic/node-bootstrap /bin/bash | |
# ``` |
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
############################################################ | |
# Builds a Meteor 0.9.x+ application Docker image | |
# | |
# See: http://docs.docker.io/ | |
# | |
# Important: Best to run from a clean directory that hasn't had meteor run in it. | |
# Important: packages/<pkg>/.npm and .build* should not exist | |
# | |
# Example usage: | |
# cd appdir #in app dir |
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
class AutoComponent extends React.Component { | |
constructor() { | |
super() | |
var cls = this.constructor | |
var methods, methodName | |
while (cls !== AutoComponent) { | |
methods = Object.getOwnPropertyNames(cls.prototype) | |
for (var i in methods) { | |
methodName = methods[i] | |
if (methodName.match(/^on[A-Z]/) !== null) { |
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
async.series([ | |
function(callback){ | |
// do some stuff ... | |
callback(null, 'one'); | |
}, | |
function(callback){ | |
// do some more stuff ... | |
callback(null, 'two'); | |
} | |
], |
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
/* UPDATED: This example has been changed to use the new object predicates, that were | |
* introduced in Bluebird 3.0. If you are using Bluebird 2.x, you will need to use the | |
* older example below, with the predicate function. */ | |
var Promise = require("bluebird"); | |
var fs = Promise.promisifyAll(require("fs")); | |
Promise.try(function(){ | |
return fs.readFileAsync("./config.json").then(JSON.parse); | |
}).catch({code: "ENOENT"}, function(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
const cluster = require('cluster'); | |
if (cluster.isMaster) { | |
let router = zmq.socket('router').bind('tcp://127.0.0.1:5433'); | |
// forward messages between router and dealer | |
router.on('message', function() { | |
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
doAsyncThing.then(function(result){ | |
return doAnotherAsyncThing().then(function(result){ | |
return doYetAnotherAsyncThing().then(function(result){ | |
console.log("Done!"); | |
}); | |
}); | |
}).catch(function(err){ | |
/* This is where errors from *any* of the above promises end up. */ | |
}); |
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
meta = { | |
module : { | |
author : author, | |
title : title, | |
descrip : description, | |
clips : [{clip : {$ : {href : 'test'}, | |
description : '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
app.get("/user/:userid", function (req, res, next) { | |
var id = parseInt(req.params.userid); | |
if (id === 'John') { | |
next(); | |
} else { | |
//do something with the none John user id | |
} | |
}); |
NewerOlder