- Install Chrome
- Sign in to Chrome and sync bookmarks and other data.
- Export bookmarks
- Import in Safari.
- Ref: https://support.apple.com/en-in/guide/safari/ibrw1015/mac
- Setup Safari
- Remove unnecessary apps from Dock
- Setting up MS Teams. Download from here.
- Setup SSH key and add to Github account. Read here.
- Verify if the setup is successful.
ssh -T git@github.com
If you receive message like below, it is successful.
“Hi pbharadiya! You’ve successfully authenticated, but GitHub does not provide shell access.” - You may want to add newly generated ssh key to different staging/production servers where you need access to remote servers.
Copy the key from here, and ask someone to add to remote server under ~/.ssh/authorized_keys file.
cat ~/.ssh/id_rsa.pub
- Verify if the setup is successful.
- Install VS code. Link here
- Install HomeBrew. Refer here
- Don’t forget to follow the instructions shown at the end of installation. Run the commands.
- Install Git. Link here
- Install zsh and oh-my-zsh
- https://ohmyz.sh/#install
- Plugin for auto suggestion – https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md#oh-my-zsh
- Setup Rbenv. Link here
- I dropped the idea of using RBenv and switched back to RVM 🙂 My comfort zone. Link here
- Fixing errors while installing ruby using rvm install
- Error message: Error running ‘__rvm_make -j8
- Resolution: https://stackoverflow.com/a/74715279/3519703
- Error installing mime-magic
- Error message: error occurred while installing mimemagic (0.4.3)
- Resolution: brew install shared-mime-info & try again
- Error installing ffi
- Error message: error occurred while installing ffi (1.9.25)
- Resolution:
gem install ffi -v '1.9.25' --source 'https://rubygems.org/' -- --with-cflags="-Wno-error=implicit-function-declaration"
- Error installing bson_ext
- Error message: error occurred while installing bson_ext (1.5.1)
- Resolution:
gem install bson_ext -v '1.5.1' --source 'https://rubygems.org/' -- --with-cflags="-Wno-error=implicit-function-declaration"
- Error installing libv8
- Error message: error occurred while installing libv8 (3.16.14.19)
- Resolution: brew install v8
- bundle config build.libv8 –with-system-v8
- bundle config build.therubyracer –with-v8-dir=$(brew –prefix v8@3.15)
- Install PostgreSQL
- brew install postgresql@12Â OR brew install postgresql
https://www.sqlshack.com/setting-up-a-postgresql-database-on-mac/
- brew install postgresql@12Â OR brew install postgresql
- Fix issue of ssh
- edit or create the file
~/.ssh/configand add the following content: - Host *
- PubkeyAcceptedKeyTypes=+ssh-dss
- edit or create the file
- Important shortcuts for easing the work
- navigate to Go Forward and Go Back
Ctrl + - & Ctrl + shift + - - https://stackoverflow.com/questions/35424367/how-can-i-navigate-back-to-the-last-cursor-position-in-visual-studio-code
- Show path bar and status under Finder. Read here
- Switch between tabs in Finder – Ctrl + tab
- VS Code: Move away from ctrl + 1, ctrl +2, and so on and swap with Command + 1, Command +2 and so on.
- VS Code: Ctrl+Shift+L Select all occurrences of current selection
- Copy file path in Mac Terminal: Refer this answer
- Close VS code unsaved file without save
– Command-D for don’t save
– Exit to cancel
– Enter to save
- navigate to Go Forward and Go Back
Linux alias command: How to Create and Use Alias Command in Linux
Repeating yourself more often? We, Rails developers, believe in DRY concept. If you’re executing some commands more often than others, you can create alias for those commands. For instance, checking for git status repeatedly could be annoying. What if I can just run gs and it shows me the status of code changes of current branch?
Sounds interesting? Let’s have a quick setup for alias.
Step-1: Setup in bashrc file
$ vi ~/.bashrc
And, append the below line to the end of file. (press shift + G in vi to go to the end of the file. For nano, refer this)
source ~/.bash_profile
Step-2: Create bash_profile file (if not present already)
$ vi ~/.bash_profile
Step-3: Append the below content to the file.
alias gs="git status"
alias gd="git diff --color"
Step-4: Check whether it is working
$ bash -l (This is required to reload the bash terminal)
$ gs
(it should run git status and show you the current state of a branch)
That’s it. You can add as many alias as you want, and save your time typing the long commands.
To quickly view the list of all the alias.
$ alias
My alias list:
# Directory shortcuts
alias crm='cd /path/to/code/repo'
alias crmv2='cd /path/to/another/repo'
# Git Shortcuts
alias ga='git add'
alias gd='git diff'
alias gs='git status'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -l'
alias ls='ls --color=auto'
alias rc='rails c'
alias rs='rails s -p8888'
I hope you found this article helpful. Subscribe to my blog for more such posts.
Add hook before committing message to avoid debugging commands in commit – Git
Hello folks,
Have you ever been in a situation wherein you have committed ‘byebug’ or ‘debugger’ in your commit by mistake? If your answer is yes, then there is a solution to save you from this disaster.
Github provides hooks that you can use to trigger certain events. Below steps will take you through the setup process to add a pre-commit hook to avoid ‘undesired’ words from committing.
Step – 1: Save the below file as pre-commit.
https://gist.github.com/pbharadiya/0f615fbb5b78180d46f0c640f8aee8b1
Step – 2: Put the pre-commit file (without any extension) in the .git folder of your GitHub repository.
$ mv pre-commit ~/myapps/app/.git/hooks/
Step – 3: Change file mode to allow execution by git
$ chmod +x ~/myapps/app/.git/hooks/pre-commit
Step – 4: Usage
$ git commit -m "Add debugger command"
It will NOT allow adding commit if your any of file changes have strings from the ‘LIST’ defined.
Step – 5: There’s a hack. You can skip hook by below command.
$ git commit --no-verify -m "I understand risk"
Further:
You can add a hook for all your GitHub repository like below –
- Enabled Git templates
$ git config –global init.templatedir '~/.git-templates' - Create a directory for the global hooks
$ mkdir -p ~/.git-templates/hooks - Copy the pre-commit file at this location
$ cp ~/myapps/myapp/.git/hooks/pre-commit ~/.git-templates/hooks/
Voila! You’re done.
Hope, you find this a helpful post and will save you from scolding by your reviewer 🙂
Happy reading!
wordpress + nginx + mysql + ubuntu
Step 1: Install MySQL
Run below command to install mysql-server and mysql-client. It will install latest version available. (v5.7 as of March 2017)
It will install below NEW packages to your system:
libaio1 libevent-core-2.0-5 libhtml-template-perl mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server mysql-server-5.7 mysql-server-core-5.7
$ sudo apt-get install mysql-server
Set mysql password when prompted. Enter password again to confirm when prompted again. It is advisable NOT to keep password blank.
See screen shots below for reference.


Check and verify mysql. Open terminal (shortcut: ctrl + alt + T).
$ mysql --version
If you see output similar to below, then you’re good to move further. If you see any error, you can simply google the error.

Run below command. Enter root user’s password when prompted.
$ mysql -u root -p
Then you can run below commands to get started:
mysql> show databases;
mysql> use <database_name>;
mysql> show tables;
mysql> explain <table_name>;
mysql> select count(*) from <table_name>;
mysql> help;
That’s all for MySQL.
Step-2: Setup WordPress
You can go through quick guide for installing and running wordpress here.
Step-3: Setup Nginx
Locate the nginx config file by running below command:
$ locate nginx.conf
Edit the file and add below lines for WordPress blog setup for your application.
http {
...
...
# server block
server {
listen 80;
server_name blog.example.com;
location / {
root blog/public;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root blog/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
include fastcgi_params;
}
error_log logs/myapp/error.log;
access_log logs/myapp/access.log;
}
}
Finally, restart Nginx.
$ sudo service nginx restart
That’s all for the post. I hope, it helped you to ease your life.
You can leave your comment below.
-Parth
Getting SciTE to recognise html.erb extension
If you ever asked yourself, “How to get scite to recognize html.erb files so that it color codes them automatically (without having to hit F12 explicitly?)” Then, this post will surely make you happy to get your answer 🙂
Step – 1 : Run following command to open scite as sudoer.
$ sudo scite
Step – 2 : Then, go to Options > Edit Properties > open html.properties and find below line.
file.patterns.html=$(file.patterns.web);$(file.patterns.php);*.htt;*.cfm;*.tpl;*.dtd;*.hta
Replace it by following lines.
file.patterns.ruby=*.erb
file.patterns.html=$(file.patterns.web);$(file.patterns.php);$(file.patterns.ruby);*.htt;*.cfm;*.tpl;*.dtd;*.hta
That’s all! Now,onwards your all the html.erb files will be recognized automatically without pressing F12 key. Njoy!
-Parth
Install Sublime 3, Scite Editor for Ruby, Rails
SUBLIME 3 :
Platform: Linux
Update [17-May-2018]:
- Add word wrap option
- Add open folder keyboard shortcut
- Add copy file path keyboard shortcut
- Add keyboard shortcut to allow toggling between tabs in sequence
> Installation
First you need to add a ppa-repository into your sources.list
$ sudo add-apt-repository ppa:webupd8team/sublime-text-3
Then update your system.
$ sudo apt-get update
Now that you’re all set to install Sublime 3 into your machine.
$ sudo apt-get install sublime-text-installer
> Getting started
– Open project by going into File > Open folder
– Enhance Sublime (Optional) :
Installation-Package Control. Go through following wonderful guide for Package Control installation.
https://sublime.wbond.net/installation#st3
– Install additional theme as you want.
Open Sublime editor by searching in ‘Dash home’. Then go to Preferences > Package control. Then click on Package control: Install Package. It will open one window. you can search by name directly or try searching ‘theme’ and on single click, it will be installed in your editor.
Select theme by going into Preferences > Color scheme > ‘your theme’. Enjoy the new theme!
– Programmer friendly Sublime 3 for Ruby
Change Preferences by going into Preferences > Settings. Then copy – paste these lines into it.
{
"draw_white_space": "all",
"font_size": 11,
"show_full_path": true,
"spell_check": true,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"word_wrap": true
}
– Add keyboard shortcut for “open folder”:
Open Preferences > Key Bindings, and add below lines on the right hand side pane which would be empty array in most cases.
[
{ "keys": ["ctrl+shift+o"], "command": "prompt_open_folder" },
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" },
{ "keys": ["ctrl+i"], "command": "copy_path" }
]
Update Sublime to latest version:
$ sudo apt-get install --only-upgrade sublime-text
SCITE :
Platform : Linux
> Installation
Install Scite by running following command in your terminal window.
$ sudo apt-get install scite
> Getting started
– Programmer friendly Scite for Ruby
Change Preferences by going into Options > Open User Options File. Then copy – paste these lines into it.
find.files=*.erb *.rb
# Show line numbers:
line.margin.visible=1
line.margin.width=5
# Set tabs to 4 spaces:
tabsize=2
indent.size=2
use.tabs=0
# Show whitespaces:
view.whitespace=1
# Autocomplete:
autocompleteword.automatic=1
# show status bar:
statusbar.visible=0
# show full path in the SciTE application window title bar:
# (just the filename will remain in the tab caption)
title.full.path=1
# Set monospaced font:
font.base=$(font.monospace)
font.small=$(font.monospace)
font.comment=$(font.monospace)
font.text=$(font.monospace)
font.text.comment=$(font.monospace)
font.embedded.base=$(font.monospace)
font.embedded.comment=$(font.monospace)
font.vbs=$(font.monospace)
Now you’re ready to fly with scite for Ruby!
Hope you find this helpful. That’s all for this post.
-Parth
Program to generate Pyramid of star using Ruby
#!/usr/local/bin/ruby -w
class Pyramid
def print_star
space = 10
(0...5).each do |i|
(0..space).each do
printf ""
end
(0...2*i+1).each do
printf "*"
end
puts "\n"
space -=1
end
end
end
p = Pyramid.new
p.print_star
Output :

Note : Here you can change value of i(i=5 here) to a number of rows you want to print. Also you can change value of space. Try it on your favorite editor!
Installation of RVM, Ruby, Rails, Git
RVM : Ruby Version Manager
Platform : Linux
First you need a package called build-essential. So this is the first package that should be installed.
$ sudo apt-get install build-essential
In addition, RVM will also need curl to download files.
$ sudo apt-get install curl
Next you’re going to need a few libraries and their development package counterparts. Two of these libraries are readline, which lets you edit lines of text in bash or IRB, and zlib, which Rubygems will need to function. Also included is OpenSSL and LibXML.
$ sudo apt-get install zlib1g-dev libreadline-dev libssl-dev libxml2-dev
Now that you’re all set up, install RVM itself. This is done via a shell script which you can download and run directly with a single command.
$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
Append the following line to your ~/.bashrc file.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM
And then reload your bash environment (or close the terminal window and open a new one).
$ source ~/.bashrc
Yeah! Successfully installed RVM. Check whether it is installed correctly or not.
$ rvm -v
Platform : Windows
Actually there is no RVM for Windows. Instead you should consider installing Pik for Version Manager in Windows. Go through following wonderful guide for Pik install.
https://github.com/vertiginous/pik
RUBY : Programming Language
Platform : Linux, Windows
Now, Install Ruby using RVM. It will install different Ruby versions(1.9.3, 2.0.0)
$ rvm install 1.9.3
$ rvm install 2.0.0
Confirm it by checking,
$ ruby -v
RAILS : Web Application Framework
Platform : Linux, Windows
Install Rails as a gem.
$ gem install rails
Confirm it by checking,
$ rails -v
GIT : VERSION CONTROL SYSTEM
Platform : All platforms
There is very straight forward guide for installing git for different platforms.
That’s all for this post.
Parth.
Learn and Share
Hello Readers,
Welcome to my blog. Here I will post about mainly Ruby /Rails, Table Tennis, Photography. I will also post about general helpful tips or Tech commands to solve issues which I faced in my tenure.
Targeted Audience :
Anybody who willing to learn new things and want to explore from ones daily routine.
Suggestion / Complaint :
If you have any ideas, solutions or complaint regarding anything then you can contact me via Contact Me
Thanks. Happy reading!!
Parth.


