Skip to content

Instantly share code, notes, and snippets.

@theraaz
theraaz / coins-count.js
Created June 27, 2021 23:49
calculate coins count for vending machine
/**
* Problem Statement
*
* Task Description
A vending machine has the following denominations: 1c, 5c, 10c, 25c, 50c, and $1.
Your task is to write a program that will be used in a vending machine to return change.
Assume that the vending machine will always want to return the least number of coins or
notes. Devise a function getChange(M, P) where M is how much money was inserted into the
machine and P the price of the item selected, that returns an array of integers
@theraaz
theraaz / Python_Virtual_Environment_Setup.md
Last active January 25, 2020 21:27
how to install virtual environment for python

Python Virtual Env Setup

Install python and pip first. Once the python is installed, we can start setup for virtual environment. (assuming you installed python3), 1- installing pip:

sudo apt-get install python3-pip

2- next, install virtual env

 pip3 install virtualenv 
@theraaz
theraaz / raz-ingress.yaml
Created July 13, 2019 15:51
Kubernetes + Travis CI/CD with DigitalOcean - https://medium.com/p/c0c4058b7734
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: echo-ingress-router
namespace: development
annotations:
kubernetes.io/ingress.class: nginx
certmanager.k8s.io/cluster-issuer: letsencrypt-prod
nginx.ingress.kubernetes.io/affinity: "cookie"
nginx.ingress.kubernetes.io/session-cookie-name: "route"
@theraaz
theraaz / ingress-nginx.yaml
Created July 13, 2019 15:49
Kubernetes + Travis CI/CD with DigitalOcean - https://medium.com/p/c0c4058b7734
kind: Service
apiVersion: v1
metadata:
name: ingress-nginx
namespace: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
spec:
externalTrafficPolicy: Local
@theraaz
theraaz / deployment.production.yaml
Created July 13, 2019 15:44
Kubernetes + Travis CI/CD with DigitalOcean - https://medium.com/p/c0c4058b7734
apiVersion: apps/v1
kind: Deployment
metadata:
name: raz4
namespace: production
labels:
app: raz4
spec:
replicas: 3
minReadySeconds: 60 # wait for 60 seconds before considering pod as ready and continuing with next
@theraaz
theraaz / aws.yaml
Created July 13, 2019 15:43
Kubernetes + Travis CI/CD with DigitalOcean - https://medium.com/p/c0c4058b7734
# https://gist.github.com/cablespaghetti/b5343b04dd5bdc68dcb62754986a34ed
# this file along with ecr-red-updater.sh is a one time run thing. it is used to setup a crontask in k8s
# to get auth details from AWS so that we can fetch docker repo. once called, no need to call again
# to use, just call the bash file ./ecr-cred-updater.sh [namespace-here]
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: ecr-cred-updater
rules:
@theraaz
theraaz / ci-deploy.sh
Created July 13, 2019 15:42
Kubernetes + Travis CI/CD with DigitalOcean - https://medium.com/p/c0c4058b7734
#! /bin/bash
# exit script when any command ran here returns with non-zero exit code
set -e
COMMIT_SHA1=$TRAVIS_COMMIT
# We must export it so it's available for envsubst
export COMMIT_SHA1=$TRAVIS_COMMIT
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod u+x ./kubectl
@theraaz
theraaz / .travis.yaml
Created July 13, 2019 15:40
Kubernetes + Travis CI/CD with DigitalOcean - https://medium.com/p/c0c4058b7734
# Use Dockerized infrastructure
sudo: false
language: generic
cache:
bundler: true
git:
depth: 10
@theraaz
theraaz / cluster-role.yaml
Created July 13, 2019 15:39
Kubernetes + Travis CI/CD with DigitalOcean - https://medium.com/p/c0c4058b7734
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: cicd
rules:
- apiGroups: ["", "apps", "batch", "extensions"]
resources: ["deployments", "services", "replicasets", "pods", "jobs", "cronjobs", "secrets", "roles"]
verbs: ["*"]
@theraaz
theraaz / cluster-role-binding.yaml
Created July 13, 2019 15:38
Kubernetes + Travis CI/CD with DigitalOcean - https://medium.com/p/c0c4058b7734
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: cicd
subjects:
- kind: ServiceAccount
name: cicd
namespace: default
roleRef:
kind: ClusterRole