Skip to content

Instantly share code, notes, and snippets.

View sanketsudake's full-sized avatar

Sanket Sudake sanketsudake

View GitHub Profile

The Problem

Alice and Bob have accounts at Bankgroup. Each account has 0 or more dollars in it.

Bankgroup wants to add a new “wire” feature, where any user can transfer money to any other user. This feature has the following requirements:

  • Each wire must be between two different people in the bank and wire at least one dollar.

  • If a wire is successful, the value of the wire is deducted from the sender account and added to the receiver account.

@sanketsudake
sanketsudake / easy_cloning.md
Created January 17, 2019 06:46
Cloning repo with ease
  1. Add in .gitconfig url shortcut
[url "git@github.com:infracloudio/"]
    insteadOf = inf:
  1. Clone repo with ease
@sanketsudake
sanketsudake / boto3_assume_role.py
Last active February 22, 2019 21:43
Assume role for AWS cross-account with boto 3
import logging
import boto3
import dateutil
logger = logging.getLogger()
logger.addHandler(logging.StreamHandler()) # Writes to console
logger.setLevel(logging.INFO)
def create_sts_client(aws_access_key_id=None,
ISSUE SUMMARY
DETAILED DESCRIPTION OF IMPACT
ROOT CAUSE
REMEDIATION AND PREVENTION
@sanketsudake
sanketsudake / aws_instances.sh
Last active July 5, 2018 10:02
List ALL AWS Instances
for region in `aws ec2 describe-regions --output text | cut -f3`
do
echo -e "Instances in region:'$region'..."
aws ec2 describe-instances --region $region --query 'Reservations[].Instances[].[State.Name,KeyName,InstanceType,Tags[].Value,PublicIpAddress]'
done
@sanketsudake
sanketsudake / tensorflow_device_info.py
Created May 29, 2018 05:29
Get devices available for Tensorflow Computations
from tensorflow.python.client import device_lib
def get_available_devices():
"""
>>> get_available_devices()
['/device:CPU:0']
"""
devices_info = device_lib.list_local_devices()
return [dev.name for dev in devices_info]
# Training job contains 1 Tensorflow master,1 Tensorflow worker and 2 parameter servers.
# In replica specifications, we specify replica type and replica specific details like container image etc.
apiVersion: "kubeflow.org/v1alpha1"
kind: "TFJob"
metadata:
name: "example-job"
spec:
replicaSpecs:
- replicas: 1
tfReplicaType: MASTER
@sanketsudake
sanketsudake / Kubeflow_install.sh
Last active May 21, 2018 13:33
Get Kubeflow Running for Myself
NAMESPACE=kubeflow
kubectl create namespace ${NAMESPACE}
VERSION=v0.1.2
APP_NAME=my-kubeflow
ks init ${APP_NAME}
cd ${APP_NAME}
ks env set default --namespace ${NAMESPACE}
ks registry add kubeflow github.com/kubeflow/kubeflow/tree/${VERSION}/kubeflow
ks pkg install kubeflow/core@${VERSION}
ks pkg install kubeflow/tf-serving@${VERSION}
@sanketsudake
sanketsudake / Makefile
Created September 18, 2017 07:25 — forked from rcmachado/Makefile
Add a help target to a Makefile that will allow all targets to be self documenting
.SILENT:
.PHONY: help
# Based on https://gist.github.com/prwhite/8168133#comment-1313022
## This help screen
help:
printf "Available targets\n\n"
awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
@sanketsudake
sanketsudake / GCE Python Sample
Created September 17, 2017 16:18
[WIP] List Google Compute Engine Resources
# pip install google-api-python-client>=1.4.2
from googleapiclient.discovery import build
from oauth2client.client import GoogleCredentials
service_key='service_key.json'
project='myproject'
credentials = GoogleCredentials.from_stream(service_key)
service = build('compute', 'beta', credentials=credentials)
service.machineTypes().list(project=project, zone='us-central1-c').execute()
service.networks().list(project=project, zone='us-central1-c').execute()