Skip to content

Instantly share code, notes, and snippets.

View davidgf's full-sized avatar

David García davidgf

View GitHub Profile
@davidgf
davidgf / IncrementReportCounters.js
Last active May 4, 2018 06:34
Example of counting email events by type and campaign in a functional way
import R from 'ramda';
import Promise from 'bluebird';
const ReportRepository = {
incrementCounters: () => Promise.resolve('Counters incremented')
};
const supportedEventTypes = ['email.delivered', 'email.reported', 'email.bounced'];
const eventTypeSupported = R.pipe(
R.prop('type'),
const makeRequest = () => {
return getJSON()
.then(data => handleResult(data))
}
const handleResult = (data) => {
return data.needsAnotherRequest
? handleIncompleteResult(data)
: handleCompleteResult(data);
}
@davidgf
davidgf / serverless
Last active June 28, 2018 13:41
Bash completion for Serverless
_sls()
{
local cur prev words cword
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
words="${COMP_WORDS}"
local COMMANDS=(
"project"