Skip to content

Instantly share code, notes, and snippets.

View ashwinrs's full-sized avatar
💭
🍦

Ashwin S ashwinrs

💭
🍦
View GitHub Profile
@ashwinrs
ashwinrs / example.ts
Created May 17, 2018 22:04
Function signature with return type in typescript
// This function takes two params and returns a variable of type Immutable.Map<String, any>.
// Function is just for explaining the format of a function in typescript. Functionally this function does not do anything :)
// param1 : Type is Immutable.Map<String, any>
// param2 : Type is number
// returns a value of type Immutable.Map<Strin, any>
const functionVar = (param1: Immutable.Map<String, any>, param2: number): Immutable.Map<String, any> => {
return state;
};
@ashwinrs
ashwinrs / randomString.sh
Created June 25, 2018 18:33
Generate a random string
head -n 4096 /dev/urandom | openssl sha1
@ashwinrs
ashwinrs / .bash_kube.sh
Created January 3, 2020 16:51
Kubernetes aliases
alias k='kubectl'
alias kx='kubectx'
alias khelp='echo n:nodes, p:pods, s:services, d: deployment, con:context, i:ingress, ns:namespace, map:configmaps, sec:secret, roll:rollout, kx=kubectx'
### Drop into an interactive terminal on a container
alias kexec='f() { kubectl exec -it "$@" -- bash; }; f'
### Pod management.
alias kp='kubectl get pods'
alias kpwatch='kubectl get pods --watch'
alias kpwide='kubectl get pods -o wide'
@ashwinrs
ashwinrs / impersonate_sa.sh
Created August 3, 2020 21:12
How to run CLI command as a Google service account
# download service account key (this will require ServiceAccount Key Admin role)
gcloud iam service-accounts keys create ./key.json --iam-account <service_account>
# Set following env var to point to the service account key file
export GOOGLE_APPLICATION_CREDENTIALS=./key.json
# Keep in mind that changing gcloud auth by the below command, will not work as only "gcloud" commands use it,
# gcloud auth activate-service-account <service_account> --key-file=./key.json
# gcloud auth list