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 / ArraySumWithMap.java
Created March 9, 2013 03:56
Check if a collection contains 2 numbers that add up to the input. This uses a hashmap so that the computational complexity is constant.
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class ArraySumWithMap {
private Map<Integer, Integer> numbers = new HashMap<Integer, Integer>();
/**
@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");
@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

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
@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 / 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 / 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="maven-plugin@2.15.1">
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM" plugin="git@3.2.0">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
@lobster1234
lobster1234 / config.xml
Created April 25, 2017 04:56
Hello World API Packer Jenkins Job
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<hudson.model.ParametersDefinitionProperty>
<parameterDefinitions>
<hudson.model.StringParameterDefinition>
<name>Build</name>
@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
@lobster1234
lobster1234 / Main.java
Last active August 9, 2017 04:20
Quick Test for reflection vs. new vs. cached
package com.marqeta.mqpay;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
System.out.println("via Reflection took " + instantiateViaReflection() + " milliseconds");
System.out.println("via New took " + instantiateAsNew() + " milliseconds");