Skip to content

Instantly share code, notes, and snippets.

View mahigupta's full-sized avatar

Mahesh Gupta mahigupta

  • San Francisco ,CA
View GitHub Profile
https://jwiegley.github.io/git-from-the-bottom-up/

Design Doc Title

Stakeholders

List stakeholders for project/feature.

Role Person
Dev Owner
Other Dev 1 (Engine)
@mahigupta
mahigupta / latency.txt
Created July 4, 2020 04:47 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
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
@mahigupta
mahigupta / github_branch_name.sh
Last active August 9, 2019 20:56
Git color prompt branch name in command line
#!/bin/bash
force_color_prompt=yes
color_prompt=yes
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
else
@mahigupta
mahigupta / gcloud.md
Created August 9, 2019 20:53
Gcloud basic commands

Gcloud commands

gcloud auth application-default login
gcloud init

gcloud auth application-default print-access-token

multiple config in cloud
@mahigupta
mahigupta / kubectl_quick_command.md
Last active August 9, 2019 20:52
Kubectl quick command

kubectl


1. kubectl explain pod.spec
2.   kubectl explain pods
3.    kubectl create -f kubia-manual.yaml    — creating new pod from yaml file
4.   kubectl port-forward kubia-manual 8888:8080   — port forwarding to reach a manually added pod from outside
5.  kubectl label pods kubia-manual creation_method=manual  — adding label to a running container
6.  kubectl label pods kubia-manual-v2 env=debug --overwrite — edit label on a running container
@mahigupta
mahigupta / mysql_process.md
Last active August 9, 2019 20:48
Mysql long running query debugging

to debug long runnign queries in mysql/mariadb

show ENGINE innodb status;
show status like '%';
show processlist;
Show status like "Threads%";
Select substring_index(host, ':', 1as host_name,state,count(*from information_schema.processlist group by state,host_name;
Show global variables like '%';
@mahigupta
mahigupta / jquery_regex.js
Created August 9, 2019 20:42
Jquery Regex selector
jQuery.expr[':'].regex = function(elem, index, match) {
var matchParams = match[3].split(','),
validLabels = /^(data|css):/,
attr = {
method: matchParams[0].match(validLabels) ?
matchParams[0].split(':')[0] : 'attr',
property: matchParams.shift().replace(validLabels,'')
},
regexFlags = 'ig',
regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
@mahigupta
mahigupta / object_create.js
Created August 9, 2019 20:40
Javascript Object create function
if (typeof Object.create !== 'function') {
Object.create = function (o) {
function F() {}
F.prototype = o;
return new F();
};
}