Skip to content

Instantly share code, notes, and snippets.

@lsmolic
Last active September 24, 2020 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lsmolic/60d3fa1725be81c369dbd38bf41c89a9 to your computer and use it in GitHub Desktop.
Save lsmolic/60d3fa1725be81c369dbd38bf41c89a9 to your computer and use it in GitHub Desktop.
Machine Setup - Lemonlight
# DOCS: https://brew.sh/
# run the install script
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# update brew
brew update
# run the health check
brew doctor
# check that the output doesn't have any glaring issues
# I have acquired most of this over several years.
# It's just a nice way to start you off.
# You are welcome to customize, but be careful if you don't know bash well.
#add the cellar directory to your path
echo "source ~/.bashrc" >> ~/.profile
#add some aliases to the bash profile
echo "alias ll='ls -lah'" >> ~/.profile
echo "alias sp='source ~/.profile'" >> ~/.profile
# edit .bashrc file using vim
##> open the file
vi ~/.bashrc
## TYPE 'i' to enter edit mode and then paste the following (UNTIL ### END ### ):
### CONFIG TERMINAL
###################################################################################dd
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export TERM=xterm-color
export EDITOR="vi"
### GIT
###################################################################################dd
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
format_git_branch() {
BB=$(parse_git_branch)
if [ -n "$BB" ]
then
echo "($BB)"
fi
}
function current_dir(){
pwd
}
export PS1="::\w\[\033[32m\] \$(format_git_branch)\[\033[00m\] \n$ "
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
if type brew 2&>/dev/null; then
for completion_file in $(brew --prefix)/etc/bash_completion.d/*; do
source "$completion_file"
done
fi
PATH=""
### ESSENTIALS
PATH="/usr/local/git/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
### OPENSSL
PATH="/usr/local/opt/openssl/bin:$PATH"
### RBENV / PYENV
PATH="/usr/local/Cellar:$PATH"
### NODE
###################################################################################
export PATH="./node_modules/.bin:$PATH"
### RUBY ######################################################################
###################################################################################
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
### NVM
#######
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
### END ###
## Now type ':wq' to save and quit VIM
#reload the bash profile for access to these aliases
source ~/.profile
# DOCS: https://github.com/nvm-sh/nvm
# run the install script
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
# reload your shell (source ~/.profile), this is the alias we setup earlier
sp
# install our node version
nvm install v14.6.0
nvm use v14.6.0
# DOCS: https://github.com/rbenv/rbenv
# upgrade ruby-build (gets the latest versions)
brew upgrade ruby-build
# install the rbenv library
brew install rbenv
# reload your shell
sp
# install ruby 2.6.5
rbenv install 2.6.5
# put the git-completion script into your home directory
curl -fsSL https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash > ~/.git-completion.bash
# reload your shell
sp
# type 'gi' and hit 'TAB'
# this should now auto complete 'git'
# if you type 'git com' and hit 'TAB' it should auto complete 'git commit'
# you will discover where this works for you. You can also disable this in your ~/.bashrc by commenting it out an reloading your shell
# reloading is equivalent to opening a new terminal command.
# DOCS: https://yarnpkg.com
# install the yarn library
brew install yarn
# DOCS: https://www.postgresql.org/
# check that the latest postgres is 11,
brew search postgresql
# Assuming it is... (otherwise select the one that said postgresql@11)
brew install postgresql
# check that postgresql is installed
brew services list
# verify that postgres is started, or start it
brew services start postgresql
# check that you can access the database
psql -d postgres
# prompt should look like this:
## $ psql -d postgres
## psql (11.1)
## Type "help" for help.
##
## postgres=#
# type "CTRL + d" to exit
# DOCS: https://www.ssh.com/ssh/command/
# ssh is already installed on your mac, we're going to get you setup to auth via shared keys
# go to your home directory (you could also type 'cd ~/' -- they are equivalent)
cd $HOME
# create a new rsa key pair
# just press enter 3 times.
# DOCS: https://www.ssh.com/ssh/keygen/
ssh-keygen
# check they exist (if 'll' doesn't work an alias is broken)
ll ~/.ssh/
# you should see
## id_rsa
## id_rsa.pub
# we want to copy the public key into your clipboard
cat ~/.ssh/id_rsa.pub | pbcopy
# 1. login to your github profile and go to (https://github.com/settings/keys)
# 2. click on 'New SSH Key'
# 3. paste the key in the large box, give it a name like 'lemonlight laptop'
# 4. save the key
# Test that you can connect to github
# DOCS: https://help.github.com/en/github/authenticating-to-github/testing-your-ssh-connection
ssh -T git@github.com
# When you see 'Are you sure you want to continue connecting (yes/no)?', type 'yes'
# you have now authorized public key auth to connect to github from the command line, congrats!
# create a directory to put your projects in
# I use ~/Repos/, but you can choose anything.
# Please just don't put it on your desktop or in downloads
mkdir ~/Repos
#enter that directory (whatever you called it)
cd ~/Repos
#clone the codebase
# DOCS: https://www.git-scm.com/docs
# TL;DR DOCS: https://ndpsoftware.com/git-cheatsheet.html
git clone git@github.com:lemonlight-media/portal.git lemonlight
# enter your project directory
cd ~/Repos/lemonlight
# verify your ruby version is correct (2.6.5)
ruby -v
# verify that your node version is correct (v10.13.0)
node -v
# install bundler
gem install bundler
# run bundle to install your ruby gems
bundle
# install your node modules
yarn
# setup your databases (development & test)
rails db:setup
# you will regularly be asked to run this to make your database structure match the latest form
rails db:migrate
# run the API
rails s
# this will run webpack, compile your assets, start the rails server and open your browser.
# If you don't run this command, rails will not run webpack properly and compilation will take forever
bin/webpack-dev-server
# view the project at:
localhost:3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment