This file contains hidden or 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
def getPrimaryIpFromMongoConnection(mongoConnection): | |
# mongoConnection = MongoClient(aMongoServerIp, replicaSet=replicaSetName) | |
replicaSetStatus = mongoConnection.admin.command('replSetGetStatus') | |
for member in replicaSetStatus[u'members']: | |
if member[u'stateStr'] == u'PRIMARY': | |
return member[u'name'] | |
return False |
This file contains hidden or 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 https = require('https'); | |
var http = require('http'); | |
var fs = require('fs'); | |
var express = require('express'); | |
var options = { | |
key: fs.readFileSync('key.pem'), | |
cert: fs.readFileSync('cert.pem') | |
}; |
This file contains hidden or 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
[user] | |
name = Sean Sullivan | |
email = myemail | |
[color] | |
diff = auto | |
status = auto | |
branch = auto | |
[alias] |
This file contains hidden or 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
/* | |
// Route defined as: | |
app.get('/test/login', function (req, res) { | |
res.render('login/login', {something: 'here'}); | |
}); | |
*/ | |
var localsAsResponseEngine = function (pathName, locals, cb) { | |
delete locals._locals; | |
delete locals.settings; |
This file contains hidden or 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 Q = require('q'); | |
var documents = { | |
'a': "Document A", | |
'b': "Document B", | |
'c': "Document C" | |
}; | |
/** | |
* get a document by key |
This file contains hidden or 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 Q = require('q'); | |
var getSomethingGood = function () { | |
var deferred = Q.defer(); | |
Q.fcall(getSomethingElse) | |
.then(function (result) { | |
console.log(result); | |
setTimeout(function () { // get db result |
This file contains hidden or 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 string = (<r><![CDATA[ | |
The text string goes here. Since this is a XML CDATA section, | |
stuff like <> work fine too, even if definitely invalid XML. | |
]]></r>).toString(); |
This file contains hidden or 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 q = require('q'); | |
var counter = 0, | |
current = counter, | |
syncFunc = function (result) { | |
current = counter++; | |
console.log('in sync func '+current); | |
return 'from func '+current; | |
}, | |
asyncFunc = function (result, callback) { |
This file contains hidden or 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 q = require('q'); | |
var method1 = function (result) { | |
var deferred = q.defer(); | |
// an async method | |
setTimeout(function () { | |
console.log('method1'); | |
deferred.resolve('from method1'); | |
}, 0); |
This file contains hidden or 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
<canvas id="canvas"></canvas> | |
<script type="text/javascript"> | |
var can = document.getElementById('canvas'); | |
var ctx = can.getContext('2d'); | |
var img = new Image(); | |
img.onload = function(){ | |
can.width = img.width; | |
can.height = img.height; | |
ctx.drawImage(img, 0, 0, img.width, img.height); |