Skip to content

Instantly share code, notes, and snippets.

View lakshmantgld's full-sized avatar
⚒️
Hacking Cloud Foundry

Lakshman Diwaakar lakshmantgld

⚒️
Hacking Cloud Foundry
View GitHub Profile
@lakshmantgld
lakshmantgld / salesTax.md
Last active May 25, 2022 15:07
Free Sales Tax API based on Postal code by Avalara

Sales Tax API

There are many companies providing sales tax API. Out of all the companies, Avalara offers free API service for sales Tax. This gist is all about setting up avalara API and querying it.

The Free-To-Use API by avalara has some restrictions. Usage of this API is subject to rate limits. Users who exceed the rate limit will receive HTTP response code 429 - Too Many Requests. The requirement for this API is to create an avalara free trail account. You can create a free account using this link create free account.

Once you have filled the form from above link, you will get an e-mail containing temporary credentials to login the avalara account. The e-mail will look something like this:

Avalara e-mail

@lakshmantgld
lakshmantgld / handler.js
Created February 29, 2020 12:18
Lambda snippet to upload file to S3
'use strict';
const AWS = require('aws-sdk');
// Set the Region
AWS.config.update({
accessKeyId: '***********',
secretAccessKey: '*************',
region: 'us-east-1',
signatureVersion: 'v4'
functions:
hello:
handler: handler.hello
events:
- http:
path: users
method: get
integration: lambda
request:
template:
╔═════════════════════════════════════════════════════╦════════════════════════════════════════════════════════════╗
║ Lambda-Proxy ║ Lambda ║
╠═════════════════════════════════════════════════════╬════════════════════════════════════════════════════════════╣
║ This is a simple, but powerful integration. All the ║ This is complex, but offers more control over transmission ║
║ request to the APIGateway URL is forwarded ║ data. The request can be modified before it is ║
║ straight to the Lambda and the response is sent ║ sent to lambda and the response can be modified ║
║ from Lambda. i.e No modifications to the ║ after it is sent from lambda. This can be done by ║
║ request(query params, body, variables) and ║ mapping templates which transforms the payload, as per ║
║ response(status code, message) are done ║ the user customisations. API Gat
@lakshmantgld
lakshmantgld / index.html
Created March 16, 2017 06:27 — forked from stesie/index.html
AWS IoT-based serverless JS-Webapp Pub/Sub demo
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>AWS IoT Pub/Sub Demo</title>
</head>
<body>
<h1>AWS IoT Pub/Sub Demo</h1>
<form>
<button type="button" id="connect">connect!</button>
@lakshmantgld
lakshmantgld / buildspec.yml
Last active June 30, 2018 04:13
config file for the codeBuild
version: 0.2
phases:
install:
commands:
# Yarn installation
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
- echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
- sudo apt-get -y update
- apt-get install -y yarn
@lakshmantgld
lakshmantgld / cronJob.md
Last active May 21, 2018 02:27
Documenting cronJob with examples

Cron is an utility program which is a time-based job scheduler in Unix-like computer operating systems. It can also be combined with AWS Lambda to invoke function based on the time-scheduler.

CronJob is represented as space-delimited 5 character string. Here is the syntax:

+---------------- minute (0 - 59)
 |  +------------- hour (0 - 23)
 |  |  +---------- day of month (1 - 31)
 | | | +------- month (1 - 12)
@lakshmantgld
lakshmantgld / serverless.yml
Created October 21, 2016 00:59
dynamoDB in serverless.yml
resources:
Resources:
DynamoDbTable:
Type: "AWS::DynamoDB::Table"
Properties:
AttributeDefinitions:
- AttributeName: "eventId"
AttributeType: "S"
- AttributeName: "googleUserName"
AttributeType: "S"
module.exports.hello = (event, context, callback) => {
const errorResponse = {
message: "Error! Dude You sent the wrong parameters"
};
// Use JSON.Stringify(), else Integration Response
// cannot read your error message.
// If not used, the Integration Response will read
// the response as [Object Object] which will make it
// impossible to detect the status code.
module.exports.hello = (event, context, callback) => {
const response = {
message: "Success!! You invoked a sleeping Lambda"
};
callback(null, response);
};