Skip to content

Instantly share code, notes, and snippets.

@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 / get-mx-records.js
Created August 25, 2018 01:58
nodeJS-get-mx-records-from-domain
var dns = require('dns');
function getMxRecords(domain){
return new Promise(function(resolve, reject) {
dns.resolveMx(domain, function (err, addresses) {
if (err) {
//console.log(err, err.stack)
resolve(null);
}
@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())