Skip to content

Instantly share code, notes, and snippets.

View vvkpd's full-sized avatar
👨‍💻
Focusing

Vivek Pandey vvkpd

👨‍💻
Focusing
View GitHub Profile
@vvkpd
vvkpd / branchToDelete.sh
Created April 5, 2021 14:22
Delete unused Git branch from local and remote
# to get the --no-merged branches right before 2 month (echo branch name)
for branch in $(git branch -r --no-merged | grep -v HEAD); do echo -e $(git show --format="%ci %cr %an" $branch | head -n 1) \\t$branch; done | sort -r | awk '{ if($1 <= "2020-07-23") { print $NF}}'
# to get the --no-merged branches right before 2 month
for branch in $(git branch -r --no-merged | grep -v HEAD); do echo -e $(git show --format="%ci %cr %an" $branch | head -n 1) \\t$branch; done | sort -r | awk '{ if($1 <= "2020-07-23") { print }}'
# to get the --no-merged branches right before 2 month without release branches (echo branch name)
for branch in $(git branch -r --no-merged | grep -v HEAD); do echo -e $(git show --format="%ci %cr %an" $branch | head -n 1) \\t$branch; done | sort -r | awk '{ if($1 <= "2020-07-23") { print $NF}}' | awk '!/release/'
# to get the --no-merged branches right before 2 month without release and master branches (echo branch name without origin keyword)
@vvkpd
vvkpd / keybase.md
Last active October 13, 2020 08:38

Keybase proof

I hereby claim:

  • I am vvkpd on github.
  • I am vvkpd (https://keybase.io/vvkpd) on keybase.
  • I have a public key ASDiwJOAdCwH4Z4HyyMkmIVAohWgpJWvCleBChsy4qU98go

To claim this, I am signing this object:

@vvkpd
vvkpd / learnBash.sh
Created February 28, 2019 10:48
Basic bash script
#!/usr/bin/env bash
# First line of the script is the shebang which tells the system how to execute
# the script: http://en.wikipedia.org/wiki/Shebang_(Unix)
# As you already figured, comments start with #. Shebang is also a comment.
# Simple hello world example:
echo Hello world! # => Hello world!
# Each command starts on a new line, or after a semicolon:
@vvkpd
vvkpd / basicRegex.sh
Last active January 30, 2019 08:18
Basic regex operations in shell
url='https://guide.bash.academy/variables.html'
echo "Sample URL"
echo "-----------------$url-----------------";
# Remove the shortest string that matches the pattern if it's at the start of the value.
echo "${url#*/}"
# Remove the longest string that matches the pattern if it's at the start of the value.
echo "${url%/*}"
# Remove the shortest string that matches the pattern if it's at the end of the value.
echo "${url##*/}"
@vvkpd
vvkpd / cloneAllRepo.js
Last active August 1, 2018 14:39
can clone all repo of particular github user by command line, just say `node cloneAllRepo.js <github user name>` and can clone particular repo of any user,just say :`node <github_user_name> <repo_name>`
const { exec } = require('child_process');
const cloneAllRepoOf = function(user,repo){
exec(`curl https://api.github.com/users/${user}/repos`, (err,stdout) =>{
const content = JSON.parse(stdout);
if(!Array.isArray(content)){
console.log(stdout)
return ;
}
if(repo){
@vvkpd
vvkpd / mac-setup.sh
Created June 14, 2018 11:52
Mac Setup Shell script
#!/usr/bin/env bash
# Ask for the administrator password upfront.
sudo -v
# Keep-alive: update existing `sudo` time stamp until the script has finished.
while true; do sudo -nv true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
#Ask for name to use in oh my zsh
echo "\n\nEnter name to display in prompt"
@vvkpd
vvkpd / docker-kill.sh
Last active June 11, 2018 04:44
Kill/Clean all docker containers and images
remove all containers forcefully:-
docker rm -f $(docker ps -a -q)
remove all docker images forcefully:-
docker rmi -f $(docker images -q)