Skip to content

Instantly share code, notes, and snippets.

@marcieltorres
marcieltorres / aws-lambda-function-send-mail.js
Created August 25, 2018 02:05
NodeJS: Sending mail with AWS Lambda Function
var aws = require('aws-sdk');
exports.handler = (event, context, callback) => {
var _returnMessage = "";
var _destinationAddress, _sourceAddress = 'source@sourcedomain.com';
var _defaultSubject = '[Subject]';
var _defaultMessageData = '[Empty Message]';
//params SES
@marcieltorres
marcieltorres / aws-lambda-function-receitaws.py
Created August 25, 2018 02:02
Get data from ReceitaWS with the AWS Lambda Function
import json
import urllib
import re
def lambda_handler(event, context):
if 'cnpj' in event and _regex(event['cnpj']):
return json.loads(urllib.request.urlopen(_getUrlApi(event['cnpj'])).read())
return json.loads("{\"status\": \"error\", \"message\": \"Formato incorreto\"}")
@marcieltorres
marcieltorres / git-revert.txt
Last active May 27, 2018 16:11
git revert to commit
git reset <commit id>
git reset --soft HEAD@{1}
git commit -m "Revert to <commit id>"
git reset --hard
@marcieltorres
marcieltorres / mapping.json
Last active January 19, 2018 11:03
API Gateway (AWS): Mapping Body Template (/url/{param})
{
"body" : $input.json('$'),
"headers": {
#foreach($header in $input.params().header.keySet())
"$header": "$util.escapeJavaScript($input.params().header.get($header))" #if($foreach.hasNext),#end
#end
},
"method": "$context.httpMethod",
"params": {
#foreach($param in $input.params().path.keySet())