Skip to content

Instantly share code, notes, and snippets.

View shudipta's full-sized avatar

Shudipta Sharma shudipta

View GitHub Profile
@shudipta
shudipta / postgres_queries_and_commands.sql
Created September 19, 2021 18:45 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@shudipta
shudipta / get-latest-tag-on-git.sh
Created May 10, 2021 10:09 — forked from rponte/get-latest-tag-on-git.sh
Getting latest tag on git repository
# The command finds the most recent tag that is reachable from a commit.
# If the tag points to the commit, then only the tag is shown.
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
# and the abbreviated object name of the most recent commit.
git describe
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
git describe --abbrev=0
# other examples
@shudipta
shudipta / kubectl_chitsheat
Last active June 18, 2020 16:24
`kubectl` hacks
# create k8s resource without reading from file
$ cat - <<-EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: dummy-secret
type: Opaque
data:
API_KEY: bWVnYV9zZWNyZXRfa2V5
API_SECRET: cmVhbGx5X3NlY3JldF92YWx1ZTE=
@shudipta
shudipta / colors.go
Last active July 28, 2020 00:35 — forked from ik5/colors.go
Simple golang expirement with ANSI colors
package main
// http://play.golang.org/p/jZ5pa944O1 <- will not display the colors
import "fmt"
const (
InfoColor = "\033[1;34m%s\033[0m"
NoticeColor = "\033[1;36m%s\033[0m"
WarningColor = "\033[1;33m%s\033[0m"
ErrorColor = "\033[1;31m%s\033[0m"
DebugColor = "\033[0;36m%s\033[0m"
@shudipta
shudipta / update-golang.md
Created January 9, 2020 09:15 — forked from nikhita/update-golang.md
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

$ kubectl create -f sts-svc.yaml
$ kubectl logs -f web-0
PING web-0.test (10.28.0.104): 56 data bytes
64 bytes from 10.28.0.104: seq=0 ttl=64 time=0.029 ms
--- web-0.test ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.029/0.029/0.029 ms
PING web-1.test (10.28.2.71): 56 data bytes
#!/bin/bash
export MINIKUBE_VER=v1.0.0
export KUBECTL_VER=`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`
show_help() {
echo "mk-kc.sh - update minikube and kubectl"
echo " "
echo "mk-kc.sh [options]"
echo " "
@shudipta
shudipta / cp+.sh
Last active August 7, 2020 14:27
Build and run c++ source file, flags for c++11 and c++14 can be used, some simple checking for flags and arg, show help
#!/bin/bash
set -eou pipefail
export VERSION=14
export ARGS=0
export FILE=
show_help() {
echo "c++14 - builds and runs a c++ source file specified by the only argument"
echo " "
@shudipta
shudipta / redis-ha-sentinel
Last active August 17, 2018 10:11
redis-ha-sentinel
apiVersion: v1
kind: Pod
metadata:
name: redis-master
labels:
app: sentinel
role: master
spec:
containers:
- name: redis-master
@shudipta
shudipta / Uninstall.md
Created August 14, 2018 17:57 — forked from pokisin/Uninstall.md
Uninstall git, ubuntu

Uninstall git

To remove just git package itself from Ubuntu 14.04 execute on terminal:

$ sudo apt-get remove git

Uninstall git and it's dependent packages

To remove the git package and any other dependant package which are no longer needed from Ubuntu Trusty.

$ sudo apt-get remove --auto-remove git