Skip to content

Instantly share code, notes, and snippets.

@demosifter
demosifter / how-to-dag-1.json
Last active Jun 1, 2018
"inputs" section of the "dag" in the sift.json
View how-to-dag-1.json
"emails":{
"gmailEmails":{
"filter":{
"conditions":[{
"date": "between now and 1 week before now"
}]
},
"wants": [
"archive",
"headers",
@demosifter
demosifter / how-to-dag-nodes-1.json
Last active Oct 11, 2016
Update our node's input in the sift.json
View how-to-dag-nodes-1.json
"nodes":[{
"#": "First Node",
"input": {
"bucket": "gmailEmails"
},
"implementation": {
"javascript": "server/node1.js"
},
"outputs": {
"output1": {}
@demosifter
demosifter / how-to-node1-1.js
Last active Oct 11, 2016
Simple node implementation in server/node1.js
View how-to-node1-1.js
module.exports = function (got) {
// got.in contains the key/value pairs that match the given query
const inData = got.in;
console.log('counter: node1.js: running...', inData.data);
const json = inData.data.map(d => JSON.parse(d.value));
json.forEach(function(value, i){
console.log('datum#', i, 'value:', value)
View how-to-text-utilities.js
let textUtils = require('@redsift/text-utilities');
// ...
let counts = others.map(value => {
let text = value.textBody || value.strippedHtmlBody || '';
let count = textUtils.splitWords(textUtils.trimEmailThreads(text)).length;
return count;
});
console.log(counts);
@demosifter
demosifter / how-to-dag-outputs-1.json
Last active Oct 11, 2016
defining an "outputs" section in the sift.json
View how-to-dag-outputs-1.json
"outputs":{
"exports":{
"count" : {
"key$schema":"string"
}
}
}
@demosifter
demosifter / how-to-dag-nodes-2.json
Last active Oct 11, 2016
updating our node's "outputs" section
View how-to-dag-nodes-2.json
"nodes":[{
"#": "First Node",
"input": {
"bucket": "gmailEmails"
},
"implementation": {
"javascript": "server/node1.js"
},
"outputs": {
"count": {}
@demosifter
demosifter / how-to-node1-2.js
Last active Oct 25, 2016
making our node implementation to output data for export
View how-to-node1-2.js
let textUtils = require('@redsift/text-utilities');
module.exports = function (got) {
// got.in contains the key/value pairs that match the given query
const inData = got.in;
console.log('counter: node1.js: running...', inData.data);
const json = inData.data.map(d => JSON.parse(d.value));
@demosifter
demosifter / install
Created Oct 10, 2016
shell command to install the sdk
View install
curl -sSL https://static-sdk.redsift.io/install | bash
@demosifter
demosifter / create
Created Oct 10, 2016
shell command to create a new sift named counter
View create
redsift create counter
@demosifter
demosifter / how-to-mail-filtering-1.js
Created Oct 10, 2016
filter out emails that were send by the user
View how-to-mail-filtering-1.js
const others = json.filter(j => j.user !== j['from'].email);