Skip to content

Instantly share code, notes, and snippets.

View Install previous versions with brew
brew tap-new $USER/<package-name>
brew extract --version=<version-no> $USER/<package-name>
brew search /<package-name>/
brew install <path to local formula>
View Delete all containers and images
# Delete all containers
docker rm -vf $(docker ps -aq)
# Delete all images
docker rmi -f $(docker images -aq)
amitk / PR Etiquette
Last active Jul 21, 2021
List of Etiquette to follow for better code and less cycles of review on PR
View PR Etiquette
The purpose of this document is to record an etiquette guide for all pull requests in the any repository. Like all etiquette, it is designed to make life easier for everyone, and if a guideline ever becomes restrictive, we should reevaluate it.
This can generally be applied to other repos managed by Team 105.
# Contents
1. [Size](#size)
2. [Sequential PRs](#sequential-prs)
3. [Labels](#labels)
4. [Branch Names](#branch-names)
View Alias command for bash profile
# Add them to ~/.bash_profile
# reload bash profile in terminal using $. ~/.bash_profile
# git alias
alias gs="git status"
alias gpush="git push"
alias gpull="git pull"
alias gs="git status"
alias ga="git add"
alias gstash="git stash"
View Delete all files in a floder with a particular match of regex
# It will delete all the files with there names matching the regex at once.
ls | grep <regex> | xargs rm
# eg.
# If we have files in our folder as "file.txt", "example.php", "new.html", "file_one.rb"
# For deleting files with "file" in their names just execute
# ls | grep file | xargs rm
amitk / login into postgres
Created Nov 12, 2020
steps to get to postgres on different systems
View login into postgres
# for linux and AWS systems enter below two commands one by one
sudo -i -u postgres
# for mac
psql postgres
amitk / database.yml
Created Nov 11, 2020
sample file for database.yml of a typical rails application
View database.yml
# PostgreSQL. Versions 9.3 and up are supported.
# Install the pg driver:
# gem install pg
# On macOS with Homebrew:
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On macOS with MacPorts:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
amitk / .bash_profile
Created Oct 22, 2020
Add branch name to you terminal mac/Linux
View .bash_profile
# in you home direactory in the bash profile to display branch name in terminal add parsing script
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
amitk / install_docker_on_ubuntu
Created Jul 11, 2020
A way to install docker on a ubuntu system
View install_docker_on_ubuntu
# Uninstall Docker
sudo apt-get remove docker docker-engine docker-ce
# Update the apt package index
sudo apt-get update
# Allow apt to use a repository over HTTPS
sudo apt-get install \
apt-transport-https \
ca-certificates \
amitk / prime.sql
Created May 22, 2020
function to check whether a number is prime or not
View prime.sql
-- 1 is treated as prime as per this function.
create function is_prime(num integer) returns boolean as $$
begin -- begin block;
for i in 2..(num/2) loop
if num % i = 0 then
return false; -- return false if it's get divided by any number smaller than half of it or half itself.
end if;
end loop;
return true;