Skip to content

Instantly share code, notes, and snippets.

module.exports = function (got) {
const json = got.in.data.map(d => JSON.parse(d.value));
const query = got.query;
const threadId = query[0];
let newestCount = json
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
.shift().count;
return [{
"dag": {
...
"nodes":[{
"#": "First Node",
"input": {
"bucket": "gmailEmails"
},
"implementation": {
"javascript": "server/node1.js"
},
@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-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));
{
"dag": {
"inputs": {
"rpc": {
"simple_rpc": {
"methods": ["GET"],
"path": "/simple",
"CORS": {}
}
}
"dag": {
"inputs":{
"rpc":{
"simple_rpc":{
"methods": ["GET"],
"path": "/edig/txt/*",
"CORS":{}
}
}
},
const dns = require('dns');
const pify = require('pify');
//...
module.exports = function (got) {
const inData = got.in.data;
console.log('edig: simple.js: data received:', inData);
return inData.map(d => {
const newResponse = (status_code, header, body) => {
return { status_code, header,
body: Buffer.from(JSON.stringify(body) || '').toString('base64')
}
}
module.exports = function (got) {
const inData = got.in.data;
console.log('edig: simple.js: data received:', inData);
func Compute(req sandboxrpc.ComputeRequest) ([]sandboxrpc.ComputeResponse, error) {
idx, err := utils.OpenIndex(false)
if err != nil {
return nil, errors.New("Something went wrong while creating the index: " + err.Error())
}
defer idx.Close()
datums, err := fetchMajesticCSV()
if err != nil {
return nil, err
func Compute(req sandboxrpc.ComputeRequest) ([]sandboxrpc.ComputeResponse, error) {
inData := req.In.Data
if len(inData) != 1 {
return nil, fmt.Errorf("empty input")
}
var resp []sandboxrpc.ComputeResponse
v := inData[0]
idx, err := utils.OpenIndex(true)
if err != nil {