Skip to content

Instantly share code, notes, and snippets.

@amitk
amitk / Dockerfile
Created December 24, 2022 19:27
Docker file to create a rails application with ruby slim image
FROM ruby:3.1.1-slim
WORKDIR /usr/src/app
RUN apt-get update && \
apt-get install ruby-full build-essential -y && \
apt-get install libpq-dev -y
COPY . .
@amitk
amitk / postgres_database.yml
Last active November 1, 2022 10:40
database.yml
default: &default
adapter: postgresql
encoding: unicode
username: postgres
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
brew tap-new $USER/<package-name>
brew extract --version=<version-no> $USER/<package-name>
brew search /<package-name>/
brew install <path to local formula>
# Delete all containers
docker rm -vf $(docker ps -aq)
# Delete all images
docker rmi -f $(docker images -aq)
@amitk
amitk / PR Etiquette
Last active July 21, 2021 16:22
List of Etiquette to follow for better code and less cycles of review on PR
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)
# 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"
# 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
amitk / login into postgres
Created November 12, 2020 14:15
steps to get to postgres on different systems
# for linux and AWS systems enter below two commands one by one
sudo -i -u postgres
psql
# for mac
psql postgres
@amitk
amitk / database.yml
Created November 11, 2020 11:01
sample file for database.yml of a typical rails application
# 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
amitk / .bash_profile
Created October 22, 2020 12:11
Add branch name to you terminal mac/Linux
# 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\] $ "