Skip to content

Instantly share code, notes, and snippets.

#!/usr/local/bin/bash
# NA SA EU AP
AWS_ENV="${1:-NA}"
echo "USING AWS ENVIRONMENT: ${AWS_ENV} (also avail SA, EU, AP)"
declare -A SERVICES
"requestTemplates" : { "application/json": "{\n \"body\" : $input.json('$'),\n \"headers\": {\n #foreach($header in $input.params().header.keySet())\n \"$header\": \"$util.escapeJavaScript($input.params().header.get($header))\" #if($foreach.hasNext),#end\n \n #end\n },\n \"method\": \"$context.httpMethod\",\n \"params\": {\n #foreach($param in $input.params().path.keySet())\n \"$param\": \"$util.escapeJavaScript($input.params().path.get($param))\" #if($foreach.hasNext),#end\n \n #end\n },\n \"query\": {\n #foreach($queryParam in $input.params().querystring.keySet())\n \"$queryParam\": \"$util.escapeJavaScript($input.params().querystring.get($queryParam))\" #if($foreach.hasNext),#end\n \n #end\n } \n}" },
serverless project create
_______ __
| _ .-----.----.--.--.-----.----| .-----.-----.-----.
| |___| -__| _| | | -__| _| | -__|__ --|__ --|
|____ |_____|__| \___/|_____|__| |__|_____|_____|_____|
| | | The Serverless Application Framework
| | serverless.com, v0.4.2
`-------'
Serverless: Initializing Serverless Project...
var hi = require('highland');

function stringify(s) {
    return s.map(function(msg) {
        return JSON.stringify(msg);
    });
}

function wrapMessage(s) {

Hello everyone... I have a question, that maybe someone can help me out with.. I have a highland stream let's call it streamA basically I want to capture the first non error event emitted by that stream and determine whether it is an object message {...} being emitted or a raw string "...". If streamA's first message is a string I want to send it through a particular transform stream, If it streamA's first message is an object I will send it through different set of transforms. I am working under the assumption that the stream will only emit the same data type on each message and thus it would be inefficient to do the data type check on each message. Here is an example of the code I have come up with...

var hi = require('highland');
// grok pattern
\[checkout\] Checkout (?<action>\w+) - (?<checkout_type>[^-]+)(?: - \[(?<total>[0-9\.]+)\]$)?
// grok pattern with grok pattern substitution
\[checkout\] Checkout %{WORD:action} - (?<checkout_type>[^-]+)(?: - \[%{NUMBER:total}\]$)?
// log entries
[b2c_web] [app2] [b2c-3774016-5092740] - 2015-04-14T16:41:30.626Z - info: [checkout] Checkout attempt - new credit card - [158.99]
[b2c_web] [app2] [b2c-3774016-5092740] - 2015-04-14T16:41:33.284Z - info: [checkout] Checkout success - new credit card - [158.99]
[b2c_web] [app0] [b2c-3774016-5092740] - 2015-04-14T16:43:25.468Z - info: [checkout] Checkout attempt - new credit card - [158.94]

Question on node ChildProcess.spawn

My question is regarding the node spawn interface... I was under the impression that you could use the stdio field of the option argument to give yourself a way to redirect data to/from a child process (e.g [Readable -> child.stdin, child.stdout -> Writeable Stream, child.stderr -> Writeable stream])

My question is why can I not provide a writeable stream as the second index in the array I am passing for this field. When I do I get the error: "TypeError: Incorrect value for stdio stream: [object Object]"

why does this work??

var spawn = require("child_process").spawn;
var args = "-F --lines=0 /Users/choover/workspace/sandbox/forwarding-agent/test/test.log"
mkfifo ./tail_logs
tail -F --lines=0 /home/ua/.forever/v6-b2c-0.log | awk '{print "[app_log_0] - " $0}' > ./tail_logs &
tail -F --lines=0 /home/ua/.forever/v6-b2c-1.log | awk '{print "[app_log_1] - " $0}' > ./tail_logs &
tail -F --lines=0 /home/ua/.forever/v6-b2c-2.log | awk '{print "[app_log_2] - " $0}' > ./tail_logs &
tail -F --lines=0 /home/ua/.forever/v6-b2c-3.log | awk '{print "[app_log_3] - " $0}' > ./tail_logs &
nc -u X.X.X.X 8008 < ./tail_logs
index.js?_b=6004:45725 bootstrap
index.js?_b=6004:45725 es check
index.js?_b=6004:45725 config init
index.js?_b=6004:45620 Error: Uncaught SyntaxError: Unexpected token p (http://184.170.226.245:5601/#/settings/indices/?_g=():1)
at window.onerror (index.js?_b=6004:45829)
(index):1 Uncaught SyntaxError: Unexpected token p
index.js?_b=6004:45584 Uncaught Error: Uncaught SyntaxError: Unexpected token p (http://184.170.226.245:5601/#/settings/indices/?_g=():1)
index.js?_b=6004:45721 complete in 151.86ms
# Kibana is served by a back end server. This controls which port to use.
port: 5601
# The host to bind the server to.
host: "0.0.0.0"
# The Elasticsearch instance to use for all your queries.
elasticsearch_url: "http://10.0.4.4:9200"
# preserve_elasticsearch_host true will send the hostname specified in `elasticsearch`. If you set it to false,