Skip to content

Instantly share code, notes, and snippets.

View stalluri's full-sized avatar

Satish stalluri

  • a16z
  • Menlo Park, CA
View GitHub Profile
@stalluri
stalluri / shell_float_to_integer.sh
Last active March 11, 2016 18:23
Shell float to integer conversion and integer arithmetic
# Start with a float number
NP_TRIGGER_VALUES=999.23
# Convert float to integer value as shell supports only integer arithmetic not float
CURRENT_QUEUE_COUNT=$(printf "%.0f" $NP_TRIGGER_VALUES )
# Integer value
DYNO_CAPACITY=500
# Division; Give a space before and after the operator - shell gotcha
@stalluri
stalluri / DynamoDB_Loadtest.sh
Created February 18, 2016 23:08
Load test for DynamoDB - Fill up a table and then read from it
# Create table in region us-west-1 from DynamoDB console : SatishTestTable
# Use only a hash number : primarykey
# With capacities read : 20 ; write 10
# From your mac terminal using AWS CLI, fill up the table
for serialno in {1..2000}
do
aws dynamodb put-item --table-name SatishTestTable --region us-west-1 --item '{ "primarykey" : {"N":"'$serialno'"}, "text1" : {"S": "NeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNeptuneioNep
@stalluri
stalluri / Angular_watchers.js
Created September 25, 2015 20:59
Find number of angular watchers on a page; Less than 2000 is okay, beyond you might have performance issues
(function () {
var root = $(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
watchers.push(watcher);
});
}
@stalluri
stalluri / fugitive_best.sh
Last active August 29, 2015 14:26
Fugitive best commands
# Stage current file to index
Gwrite
# Read current file from last checkedin version
Gread
# Move current file and update vim buffer ( with relative paths, if starting with / means relative to git root directory)
Gmove
# Remove current file and update vim buffer
@stalluri
stalluri / DockerMemoryFootprint.sh
Created August 5, 2015 18:21
Docker memory footprint
for line in `docker ps | awk '{print $1}' | grep -v CONTAINER`; do \
echo $(( `cat /sys/fs/cgroup/memory/docker/$line*/memory.usage_in_bytes` / 1024 / 1024 ))MB \
$(docker ps | grep $line | awk '{printf $NF" "}') ; \
done | sort -n
@stalluri
stalluri / diskStatus.sh
Last active February 13, 2021 14:44
Publish disk utilization percentage metric to AWS Cloudwatch
#! /bin/sh
###############################################
# Purpose : To push an application metric (Disk utiization metric) for visibility and subsequently creating alarms on it
# Usage : Run this script on ec2 instance
# Crontab usage : */1 * * * * /home/ec2-user/publishProcessStatus.sh
#
# Dependencies : AWS CLI needs to be installed
# Author : Neptune.io, Inc.
###############################################
@stalluri
stalluri / memoryStatus.sh
Last active December 5, 2017 11:49
Publish memory utilization in percentage to AWS Cloudwatch
#! /bin/sh
###############################################
# Purpose : To push an application metric (Memory utiization metric) for visibility and subsequently creating alarms on it
# Usage : Run this script on ec2 instance
# Crontab usage : */1 * * * * /home/ec2-user/publishProcessStatus.sh
#
# Dependencies : AWS CLI needs to be installed
# Author : Neptune.io, Inc.
###############################################
@stalluri
stalluri / processStatus.sh
Last active August 29, 2015 14:03
Publish process status metric to AWS Cloudwatch
#! /bin/sh
###############################################
# Purpose : To push an application metric (process status metric) for visibility and subsequently creating alarms on it
# Usage : Run this script on ec2 instance
# Crontab usage : */1 * * * * /home/ec2-user/publishProcessStatus.sh
#
# Dependencies : AWS CLI needs to be installed
# Author : Neptune.io, Inc.
###############################################
@stalluri
stalluri / Disk_Space_Alert_Runbook
Created April 3, 2014 04:41
Runbook for disk space alert
## Runbook for Disk space alert ##
# Step 1 : Get disk utilization
df -H
# Step 2 : Get biggest files on disk
du -am | gawk 1024 MB | sort -n