Skip to content

Instantly share code, notes, and snippets.

View indrayam's full-sized avatar
💭
Onwards and upwards

Anand Sharma indrayam

💭
Onwards and upwards
View GitHub Profile
@indrayam
indrayam / developer-workflow-notes.md
Last active August 22, 2018 20:42
Developer Workflow for Apps Running in Kubernetes

Developer Workflow for Apps Running in Kubernetes

Assumptions:

  • CD Pipeline includes: Git => Jenkins => CI (w/ Static Code Analysis, SAST, etc.) => Docker Registry => Spinnaker
  • CD Pipeline design should be optimized for Developer Experience and Overall Speed of Deployment to the target lifecycle, without compromising on Quality or Security

Broad Brush Strokes:

  • In an ideal world, a developer should be able to perform "Write Code, Build Code, Test Code" loop on their local machine
@indrayam
indrayam / retrieve-ec2-instance-types.sh
Created May 29, 2018 18:11 — forked from nmagee/retrieve-ec2-instance-types.sh
Query the AWS Pricing API to get all currently available EC2 instance types
#!/bin/bash
curl https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json | jq -r '.products[].attributes["instanceType"]' | sort -u | grep '\.'
@indrayam
indrayam / userdata.sh
Last active February 26, 2018 18:59
User Data for DO Droplets
#!/bin/bash
cd ~
curl -O https://storage.googleapis.com/us-east-4-anand-files/misc-files/step.sh
chmod 755 ~/step.sh
@indrayam
indrayam / .log
Created February 2, 2018 00:00
Minishift logs for debugging of the Error
-- minishift version: v1.12.0+daa0943
-- Starting profile 'minishift'
Found binary path at /usr/local/bin/minishift
Launching plugin server for driver virtualbox
Plugin server listening at address 127.0.0.1:56139
() Calling .GetVersion
Using API Version 1
() Calling .SetConfigRaw
() Calling .GetMachineName
(minishift) Calling .GetState
@indrayam
indrayam / tmux_build_from_source_ubuntu.sh
Created October 9, 2017 15:51
Install latest version of tmux in Ubuntu 16.04
# Steps to build and install tmux from source on Ubuntu.
# Takes < 25 seconds on EC2 env [even on a low-end config instance].
VERSION=2.5
sudo apt-get -y remove tmux
sudo apt-get -y install wget tar libevent-dev libncurses-dev
wget https://github.com/tmux/tmux/releases/download/${VERSION}/tmux-${VERSION}.tar.gz
tar xf tmux-${VERSION}.tar.gz
rm -f tmux-${VERSION}.tar.gz
cd tmux-${VERSION}
./configure
@indrayam
indrayam / latency.txt
Created February 1, 2017 04:45 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@indrayam
indrayam / top-files-folders.sh
Last active December 11, 2016 23:07
Unix command to find the top 10 files and folders recursively inside a Unix folder
# These commands will ONLY work if you are using GNU 'du', 'find' and 'sort' commands
# Top 10 files by recursively diving inside the current folder (skip .git and .svn folders)
find . -type d \( -iregex ".*git" -o -iregex ".*svn" \) -prune -o -type f -exec du -Sh {} + | sort -rh | head -n 10
# Top 10 files by recursively diving inside the current folder (without skipping any folders)
find . -type f -exec du -Sh {} + | sort -rh | head -n 10
# Top 10 directories by recursively diving inside the current folder (skip .git and .svn folders)
du -Sh --exclude=".git" --exclude=".svn" | sort -rh | head -n 10
@indrayam
indrayam / us-states.txt
Last active December 11, 2016 23:08
All US States as an Array
[Alabama, Alaska, Arizona, Arkansas, California, Colorado, Connecticut, Delaware, Florida, Georgia, Hawaii, Idaho, Illinois, Indiana, Iowa, Kansas, Kentucky, Louisiana, Maine, Maryland, Massachusetts, Michigan, Minnesota, Mississippi, Missouri, Montana, Nebraska, Nevada, New Hampshire, New Jersey, New Mexico, New York, North Carolina, North Dakota, Ohio, Oklahoma, Oregon, Pennsylvania, Rhode Island, South Carolina, South Dakota, Tennessee, Texas, Utah, Vermont, Virginia, Washington, West Virginia, Wisconsin, Wyoming]
@indrayam
indrayam / create-jwt-using-unix-commands-on-mac.md
Last active September 21, 2022 08:08
Create JWT Token Header Using Unix Command line tools ONLY!

Pseudocode:

Y = Base64URLEncode(Header) + ‘.’ + Base64URLEncode(Payload)
JWT = Y + ‘.’ + Base64URLEncode(HMACSHA256(Y))

The steps called out here should work on a Mac as well. The only thing that might be different is the sed command used below. Instead of using -E, you will have to use -r to run sed with extended regular expression support

Use data from this tutorial:

scotch.io

@indrayam
indrayam / ns2date.pl
Created May 26, 2016 20:32
Convert nanoseconds (as in InfluxDB measurements) into human readable date/timestamp
#!/usr/bin/perl -w
#
$num_of_args = $#ARGV + 1;
if ($num_of_args != 1) {
print "Usage: ns2date.pl <epochtime in nanoseconds>\n";
exit;
}
$ns = $ARGV[0];
print scalar localtime($ns / 1000000000) . "\n";