Skip to content

Instantly share code, notes, and snippets.

Design A Vending Machine
A vending machine has Products (snacks) stacked in "Product Slots". Each "Product Slot" has an ID which is TWO DIGIT number, a PRICE.
Vending machine has a "coin slot", which can take NICKLE, DIME or QUATER only.
Vending machine has a keypad has follwing keys
* KEY 0 to 9 to pick Product Slot ID
* CLEAR is to clear your selection
* ENTER key is used to confirm your Product selection if credit is available
* DONE key is return any balance or deposited coins
@trmsmy
trmsmy / link 1
Last active February 27, 2020 03:26
jinja2 on ui docker image
52 mv minikube-v1.3.0.iso ~/.minikube/cache/iso
53 sudo apt-get install docker.io
55 docker
56 docker ps
57 sudo systemctl start docker
58 sudo systemctl status docker
echo $USER
@trmsmy
trmsmy / ddb-kinesis-lambda.py
Created May 20, 2019 18:52 — forked from sasankmukkamala/ddb-kinesis-lambda.py
Send Existing Data from Dynamodb to AWS Lambda via Kinesis by scanning entire table.
import boto3
import boto3.dynamodb.types
import json
# Load the service resources in the desired region.
session = boto3.Session(profile_name='default')
dynamodb = session.resource('dynamodb', region_name="ap-south-1")
kinesis = session.client('kinesis', region_name="ap-south-1")
# Set names for ddb table and ks stream
@trmsmy
trmsmy / Socket Client
Created January 23, 2019 21:53
Write to Socket
package com.lca.phoenix.lcc;
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
@trmsmy
trmsmy / EchoTest.java
Created May 10, 2018 02:36 — forked from chbaranowski/EchoTest.java
Cheat Sheet Test for Mockito
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.is;
import static org.mockito.Mockito.*;
import static org.mockito.BDDMockito.*;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
@trmsmy
trmsmy / System Design.md
Created April 5, 2018 12:07 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@trmsmy
trmsmy / template-java-after.xml
Created March 6, 2018 16:25 — forked from mnuessler/template-java-after.xml
Templates for the Eclipse IDE
<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="true" context="java-members" deleted="false" description="tear down after test" enabled="true" name="after">@${afterType:newType(org.junit.After)}
public void tearDown() throws Exception {
${cursor}
}</template></templates>
@trmsmy
trmsmy / SecurityConfig.java
Created March 2, 2018 15:53 — forked from yashpatil/SecurityConfig.java
Spring Security Java configuration for Pre-authenticated scenario
import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.access.AccessDecisionVoter;
import org.springframework.security.access.vote.AffirmativeBased;
import org.springframework.security.access.vote.RoleVoter;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.ProviderManager;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
@trmsmy
trmsmy / Service 2 and Service 3 logs
Created February 24, 2018 04:12
Spring Sleuth - trace ID is not passed to subsequent calls
2018-02-23 23:10:18.365 DEBUG [config-service,,,] 8212 --- [nio-8888-exec-1] o.s.c.sleuth.instrument.web.TraceFilter : Received a request to uri [/service2] that should not be sampled [true]
2018-02-23 23:10:18.369 DEBUG [config-service,,,] 8212 --- [nio-8888-exec-1] o.s.c.sleuth.instrument.web.TraceFilter : Found a parent span b927ff4389efc6c0/b927ff4389efc6c0 in the request
2018-02-23 23:10:18.369 DEBUG [config-service,,,] 8212 --- [nio-8888-exec-1] o.s.c.sleuth.instrument.web.TraceFilter : Parent span is NoopSpan{context=b927ff4389efc6c0/b927ff4389efc6c0}
2018-02-23 23:10:18.398 DEBUG [config-service,b927ff4389efc6c0,b927ff4389efc6c0,false] 8212 --- [nio-8888-exec-1] o.s.c.s.i.web.TraceHandlerInterceptor : Handling span NoopSpan{context=b927ff4389efc6c0/b927ff4389efc6c0}
2018-02-23 23:10:18.399 DEBUG [config-service,b927ff4389efc6c0,b927ff4389efc6c0,false] 8212 --- [nio-8888-exec-1] o.s.c.s.i.web.TraceHandlerInterceptor : Adding a method tag with value [echo] to a span NoopSpan{context=b927ff4389e