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 Alpha = require('@lifeomic/alpha'); | |
const lambda = require('./path/to/lambda/module'); | |
const test = require('ava'); | |
test.beforeEach((test) => { | |
test.context.client = new Alpha(lambda.handler); | |
}); | |
test('The lambda returns 200', async (test) => { | |
const response = await test.context.client.get('/'); |
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 Alpha = require('@lifeoic/alpha'); | |
async function performRequests () { | |
const client = new Alpha(); | |
const httpResponse = await client.get('http://example-service/some/path'); | |
const lambdaResponse = await client.get('lambda://example-function:some-alias/some/path'); | |
console.log(`http service responded with ${httpResponse.status}`); | |
console.log(`lambda service responded with ${lambdaResponse.status}`); | |
} |
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
{ | |
"env": { | |
"es6": true, | |
"node": true | |
}, | |
"rules": { | |
"comma-dangle": [ 2, "never" ], | |
"no-cond-assign": [ 2, "always" ], | |
"no-console": 2, |
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 rectangle (length, width) { | |
var rectangle = Object.create(null); | |
rectangle.area = function () { | |
return length * width; | |
}; | |
return rectangle; | |
} |
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 Rectangle (length, width) { | |
this._length = length; | |
this._width = width; | |
} | |
Rectangle.prototype.area = function () { | |
return this._length * this._width; | |
} | |
function Square (side) { |
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 makeInstance (constructor, context) { | |
return context === global || context === undefined ? | |
Object.create(constructor.prototype) : | |
context; | |
} | |
function Rectangle (length, width) { | |
var rectangle = makeInstance(Rectangle, this); | |
rectangle.area = 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
var async = require("async"); | |
function asyncExample (callback) { | |
console.log("asynchronous error"); | |
async.waterfall( | |
[ | |
function (next) { | |
console.log("throwing error"); | |
next(new Error("Fail!")); | |
}, |
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
# Unit testing support for DOH. | |
from django.conf import settings | |
from django.test import TestCase | |
import os | |
import subprocess | |
from time import sleep | |
from urlparse import parse_qs as parse | |
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
var events = require('events'); | |
var util = require('util'); | |
function FixedStream (string) { | |
events.EventEmitter.call(this); | |
this._buffer = new Buffer(string); | |
this._data = []; | |
this._end = false; | |
} |
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
.terminal-cursor { | |
background-color: #00ff00; | |
color: black; | |
} | |
.terminal-console { | |
background-color: black; | |
font-family: monospace, courier, arial; | |
color: #00ff00; |