Skip to content

Instantly share code, notes, and snippets.

Jeffrey Jagoda jagoda

Block or report user

Report or block jagoda

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View alpha_test.js
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('/');
@jagoda
jagoda / alpha_request.js
Last active Jun 11, 2018
Alpha Request
View alpha_request.js
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}`);
}
@jagoda
jagoda / .eslintrc
Created Jan 11, 2016
ESLint config
View .eslintrc
{
"env": {
"es6": true,
"node": true
},
"rules": {
"comma-dangle": [ 2, "never" ],
"no-cond-assign": [ 2, "always" ],
"no-console": 2,
@jagoda
jagoda / factory.js
Created Feb 23, 2014
factory pattern
View factory.js
function rectangle (length, width) {
var rectangle = Object.create(null);
rectangle.area = function () {
return length * width;
};
return rectangle;
}
@jagoda
jagoda / constructor.js
Created Feb 23, 2014
constructor pattern
View constructor.js
function Rectangle (length, width) {
this._length = length;
this._width = width;
}
Rectangle.prototype.area = function () {
return this._length * this._width;
}
function Square (side) {
@jagoda
jagoda / both.js
Last active Aug 29, 2015
Factories and Constructors
View both.js
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 () {
@jagoda
jagoda / async_error.js
Last active Dec 27, 2015
Demonstrate non-intuitive `async.waterfall` behavior.
View async_error.js
var async = require("async");
function asyncExample (callback) {
console.log("asynchronous error");
async.waterfall(
[
function (next) {
console.log("throwing error");
next(new Error("Fail!"));
},
@jagoda
jagoda / doh.py
Created Apr 6, 2012
django.test + DOH
View doh.py
# 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
@jagoda
jagoda / fixed_stream.js
Created Dec 23, 2011
NodeJS wrapper to treat strings as streams.
View fixed_stream.js
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;
}
@jagoda
jagoda / terminal.css
Created Nov 28, 2011
jQuery UI Terminal Widget
View terminal.css
.terminal-cursor {
background-color: #00ff00;
color: black;
}
.terminal-console {
background-color: black;
font-family: monospace, courier, arial;
color: #00ff00;
You can’t perform that action at this time.