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
'use strict'; | |
const cp = require('child_process'); | |
const showdown = require('showdown'); | |
const config = require('my-config'); | |
const requestTimeout = config.get('app:requestTimeoutMs'); | |
const converter = new showdown.Converter(); | |
// in the master process |
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
'use strict'; | |
const showdown = require('showdown'); | |
const converter = new showdown.Converter(); | |
function markdownToHtml(markdown) { | |
return converter.makeHtml(markdown); | |
} | |
module.exports = { | |
markdownToHtml |
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
# Place this file in the .ebextensions folder of your project | |
files: | |
"/home/ec2-user/logdna.sh" : | |
mode: "000777" | |
owner: root | |
group: root | |
content: | | |
#!/bin/sh | |
echo "[logdna] | |
name=LogDNA packages |
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
import {go, chan, take, put} from 'js-csp'; | |
let channel = chan(); | |
go(function* () { | |
const text = yield take(ch); | |
console.log('A > RECEIVED:', text); | |
}); | |
go(function* () { | |
const text = yield take(ch); |
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 redisGet = Q.nbind(redisClient.get, redisClient); | |
var mysqlGet = Q.nbind(mysqlClient.get, mysqlClient); | |
function GetUser(userId) { | |
return redisGet(userId) | |
.then(function(redisResult){ | |
if (redisResult !== null) return redisResult; | |
else return mysqlGet(userId); | |
}); | |
} |
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
function GetUser(userId, callback) { | |
redisClient.get(userId, function(redisError, redisResult){ | |
if (redisError !== null) callback(redisError, null); | |
else if (redisResult !== null) callback(null, redisResult); | |
else { | |
mysqlClient.getUser(userId, function(mysqlError, mysqlResult){ | |
if (mysqlError !== null) callback(mysqlError, null); | |
else callback(null, mysqlResult); | |
}); | |
} |
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
public User Get(string userId) { | |
User cachedUser = redisClient.GetUser(userId); | |
if (cachedUser !== null) return cachedUser; | |
else return mySqlClient.GetUser(userId); | |
} |
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 crypto = require('crypto'); | |
var DOORBELL_SECRET = '--your secret--'; | |
var DOORBELL_KEY = '--your app key--'; | |
function getOptions() { | |
var options = { | |
appKey: DOORBELL_KEY, | |
timestamp: Math.floor(new Date() / 1000), | |
token: crypto.randomBytes(16).toString('hex') |
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
"use strict"; | |
var request = require('superagent'); | |
var Q = require('q'); | |
var config = { | |
github : { | |
// https://help.github.com/articles/creating-an-access-token-for-command-line-use/ | |
user : GITHUB_USERNAME, | |
password : GITHUB_TOKEN | |
}, |
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 express = require('express'); | |
var supertest = require('supertest'); | |
var mainport = 80; | |
var app = express(); | |
app.get('/test', function(req, res) { res.send({ 'pid' : process.pid }); } ); | |
function listenToMainport() { | |
app.listen(mainport, function(){ |