Skip to content

Instantly share code, notes, and snippets.

View lobster1234's full-sized avatar
🎯
Focusing

Manish Pandit lobster1234

🎯
Focusing
View GitHub Profile
@lobster1234
lobster1234 / config.xml
Created April 24, 2017 23:45
This is the config.xml for Jenkins Build of helloworld-api project
<?xml version='1.0' encoding='UTF-8'?>
<maven2-moduleset plugin="[email protected]">
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM" plugin="[email protected]">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
@lobster1234
lobster1234 / localstack.md
Last active August 8, 2023 20:06
Working with localstack on command line

Starting localstack

C02STG51GTFM:localstack mpandit$ make infra
. .venv/bin/activate; exec localstack/mock/infra.py
Starting local dev environment. CTRL-C to quit.
Starting local Elasticsearch (port 4571)...
Starting mock ES service (port 4578)...
Starting mock S3 server (port 4572)...
Starting mock SNS server (port 4575)...
@lobster1234
lobster1234 / serverless_framework_java_maven.md
Last active January 23, 2024 21:18
Tutorial for running the templated maven-java serverless project using the serverless framework.

Working with Serverless and Java - Part 1

In this tutorial, we will create and deploy a java-maven based serverless service using the serverless project (https://serverless.com/). In this part we will not modify any code, or even look at the generated code. We will focus on the deployment and the command line interface provided by serverless. Serverless is a node.js based framework that makes creating, deploying, and managing serverless functions a breeze. We will use AWS as our FaaS (Function-as-a-Service) provider.

Pre-requisites

Here is what the setup on my Mac looks like (Sierra)

  • brew (1.1.10) - you will need this if you do not have node/npm installed already.
  • node (v7.6.0)
  • npm (4.1.2)
  • Apache Maven (3.2.5)
@lobster1234
lobster1234 / lambda.md
Last active February 28, 2017 20:58
My notes from the AWS Lambda Deep Dive webinar

AWS Lambda

Lambda is the key enabler and a core AWS component for serverless computing. Lets you run the code you want, without worrying about the underlying infrastructure and provisioning. It is also cost efficient, as there are no instances that are in running state but idle. Lambda handles scaling up and scaling down as needed, transparently to the customer.

Components

  • Event Source - Changes in state of the resources or data, or any events triggered explicitly or implicitly. A large number of AWS services can act as Event Sources - Like S3 (Object PUT, DELETE..), DynamoDB, IoT, CloudFormation, CloudWatch, SNS, API Gateway and Cron schedule to name a few.

  • Function - The piece of code that would be run when that event occurs. The function can access any services downstream if needed. Currently Supported languages are Node.js, Python, Java 8 and C#.

Use cases

  • Stateless, event-based file/data processing.
@lobster1234
lobster1234 / Solution.java
Last active December 25, 2016 00:16
Code to match brackets - my O(N) submission to HackerRank
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
@lobster1234
lobster1234 / AWS_Certified_Developer_Associate_Sample.md
Last active July 18, 2017 09:04
AWS_Certified_Developer_Associate_Sample.md

My Answers to the Sample Questions provided on the certification site -

You can download the PDF of the questions here

  1. Which of the following statements about SQS is true?
  • A. Messages will be delivered exactly once and messages will be delivered in First in, First out order
  • B. Messages will be delivered exactly once and message delivery order is indeterminate
  • C. Messages will be delivered one or more times and messages will be delivered in First in, First out order
  • D. Messages will be delivered one or more times and message delivery order is indeterminate

Use a tenant_id for each record

What it is

  • Single database running on single instance
  • Every record has a tenant_id as a part of the composite primary key.
  • Application will need to provide this tenant_id for every query as a part of the where clause

Pros

  • One database, one instance
  • Relatively easy to run cross-tenant queries

EC2

  • Can start an AMI to create any number of on-demand instances by using the RunInstances call. Default max is 20 per account.
  • If the request is good, the RunInstances call returns success with a list of DNS names, and instances begin to launch within 10 minutes.
  • The launch request is associated with a reservation ID. One reservation ID can map to multiple instances which are all a part of one launch request.
  • The status can be checked via DescribeInstances call
  • Can be terminated using TerminateInstances call
  • If a running instances uses EBS-backed root volume (boot partition), it can be stopped by StopInstances call. This preseves the data.
  • The same can be done via CLI or the Console instead of REST APIs
  • EBS based root device store will preserve data, hence it is not tied to the life of the instance. Local instance based store presisence is tied to the life of the instance. There is no "stop" option.
@lobster1234
lobster1234 / docker.md
Last active October 5, 2016 04:53
Notes for docker setup

Installation of Docker Platform (MacOS Sierra)

  • Head to https://docs.docker.com/docker-for-mac/
  • Download the latest docker binary from https://download.docker.com/mac/stable/Docker.dmg
  • Install it (drag and drop)
  • Go to applications, and click on the Docker icon, it will walk you through the rest of the setup.
  • You can notice the docker whale animating in the toolbar at the top right of your mac as it initalizes.
  • You can click that whale to see the current status of docker engine.
  • What has been installed is the docker engine (to manage and run containers), docker machine (the host) and docker compose.
  • We will also need virtualbox, so install it from https://www.virtualbox.org/wiki/Downloads
@lobster1234
lobster1234 / Binary.java
Created January 11, 2016 06:47
Quick and dirty to convert decimal to binary
public static String binary(int input){
StringBuilder builder = new StringBuilder();
int numerator = input;
while(true){
int divisor = numerator/2;
int remainder = numerator%2;
builder.append(remainder+"");
numerator = divisor;
if(divisor==1){
builder.append("1");