Skip to content

Instantly share code, notes, and snippets.

@demosifter
demosifter / how-to-dag-1.json
Last active June 1, 2018 16:18
"inputs" section of the "dag" in the sift.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 October 11, 2016 15:09
Update our node's input in the sift.json
"nodes":[{
"#": "First Node",
"input": {
"bucket": "gmailEmails"
},
"implementation": {
"javascript": "server/node1.js"
},
"outputs": {
"output1": {}
@demosifter
demosifter / how-to-node1-1.js
Last active October 11, 2016 17:42
Simple node implementation in server/node1.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)
@demosifter
demosifter / how-to-text-utilities.js
Last active October 15, 2016 16:03
requiring text-utils
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 October 11, 2016 15:09
defining an "outputs" section in the sift.json
"outputs":{
"exports":{
"count" : {
"key$schema":"string"
}
}
}
@demosifter
demosifter / how-to-dag-nodes-2.json
Last active October 11, 2016 15:10
updating our node's "outputs" section
"nodes":[{
"#": "First Node",
"input": {
"bucket": "gmailEmails"
},
"implementation": {
"javascript": "server/node1.js"
},
"outputs": {
"count": {}
@demosifter
demosifter / how-to-node1-2.js
Last active October 25, 2016 00:17
making our node implementation to output data for export
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 October 10, 2016 17:04
shell command to install the sdk
curl -sSL https://static-sdk.redsift.io/install | bash
@demosifter
demosifter / create
Created October 10, 2016 18:25
shell command to create a new sift named counter
redsift create counter
@demosifter
demosifter / how-to-mail-filtering-1.js
Created October 10, 2016 19:12
filter out emails that were send by the user
const others = json.filter(j => j.user !== j['from'].email);