Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pepearayao/dotfiles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Personal Setup Instructions

This project is for the personal setup of a new laptop for myself. This assumes an Intel Macbook Pro notebook. It has been heavily based on the setup guide used by Le Wagon for their bootcamps.

⚠️ Before cloning read until step 2.

To setup you will have to do the following in the follwing order.

  1. Install Gitlab CLI
  2. Install the dotfiles
  3. Install XCode
  4. Install Homebrew and its extensions
  5. Install Visual Studio Code and its extensions
  6. Install Oh my zsh!
  7. Install Python, Jupyter and all their packages
  8. Install Docker
  9. Install DBeaver

GitHub CLI

First in order to login, copy-paste the following command in your terminal:

⚠️ DO NOT edit the email

gh auth login -s 'user:email' -w

gh will ask you few questions:

What is your preferred protocol for Git operations? With the arrows, choose SSH and press Enter. SSH is a protocol to log in using SSH keys instead of the well known username/password pair.

Generate a new SSH key to add to your GitHub account? Press Enter to ask gh to generate the SSH keys for you.

If you already have SSH keys, you will see instead Upload your SSH public key to your GitHub account? With the arrows, select your public key file path and press Enter.

Enter a passphrase for your new SSH key (Optional). Type something you want and that you'll remember. It's a password to protect your private key stored on your hard drive. Then press Enter.

Title for your SSH key. You can leave it at the proposed "GitHub CLI", press Enter.

You will then get the following output:

! First copy your one-time code: 0EF9-D015
- Press Enter to open github.com in your browser...

Select and copy the code (0EF9-D015 in the example), then press Enter.

Your browser will open and ask you to authorize GitHub CLI to use your GitHub account. Accept and wait a bit.

Come back to the terminal, press Enter again, and that's it.

To check that you are properly connected, type:

gh auth status

βœ”οΈ If you get Logged in to github.com as <YOUR USERNAME> , then all good πŸ‘

Download GIT Repo

Open your terminal and run the following command:

export GITHUB_USERNAME=`gh api user | jq -r '.login'`
echo $GITHUB_USERNAME

You should see your GitHub username printed. Time to fork the repo and clone it on your new laptop:

mkdir -p ~/code/$GITHUB_USERNAME && cd $_
gh repo fork pepearayao/dotfiles --clone

We will install all of this in a later stage.

Command Line Tools

Open a new terminal, copy-paste the following command and hit Enter:

xcode-select --install

If you receive the following message, you can just skip this step and go to next step.

# command line tools are already installed, use "Software Update" to install updates

Otherwise, it will open a window asking you if you want to install some software: click on "Install" and wait.

βœ”οΈ If you see the message "The software was installed" then all good πŸ‘

❌ If the command xcode-select --install fails try again: sometimes the Apple servers are overloaded.

❌ If you see the message "Xcode is not currently available from the Software Update server", you need to update the software update catalog:

sudo softwareupdate --clear-catalog

Once this is done, you can try to install again.

Homebrew

1. Install:

On Mac, you need to install Homebrew which is a Package Manager. It will be used as soon as we need to install some software. To do so, open your Terminal and run:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

This will ask for your confirmation (hit Enter) and your macOS user account password (the one you use to log in when you reboot your Macbook).

πŸ›  If you get a Error: Not a valid ref: refs/remotes/origin/master error

The full error would be:

Error: Not a valid ref: refs/remotes/origin/master :
fatal: ambiguous argument 'refs/remotes/origin/master': unknown revision or path not in the working tree.

Run the following commands to solve it:

rm -fr $(brew --repo homebrew/core)  # because you can't `brew untap homebrew/core`
brew tap homebrew/core

If you already have Homebrew, it will tell you so, that's fine, go on.

2. Make sure you are on the latest version:

brew update
πŸ›  If you get a /usr/local must be writable error

Just run this:

sudo chown -R $USER:admin /usr/local
brew update

3. Then install some useful software:

Proceed running the following in the terminal (you can copy / paste all the lines at once).

brew upgrade git         || brew install git
brew upgrade gh          || brew install gh
brew upgrade wget        || brew install wget
brew upgrade imagemagick || brew install imagemagick
brew upgrade jq          || brew install jq
brew upgrade openssl     || brew install openssl
brew upgrade tree        || brew install tree
brew upgrade ncdu        || brew install ncdu
brew upgrade xz          || brew install xz
brew upgrade readline    || brew install readline

Visual Studio Code

Installation

Let's install Visual Studio Code text editor.

Copy (Cmd + C) the command below then paste it in your terminal (Cmd + V):

brew install --cask visual-studio-code

Then launch VS Code by running the following command in your terminal:

code

βœ”οΈ If a VS Code window has just opened, you're good to go πŸ‘

VS Code Extensions

Installation

Let's install some useful extensions to VS Code.

code --install-extension ms-vscode.sublime-keybindings
code --install-extension emmanuelbeziat.vscode-great-icons
code --install-extension MS-vsliveshare.vsliveshare
code --install-extension ms-python.python
code --install-extension KevinRose.vsc-python-indent
code --install-extension ms-python.vscode-pylance
code --install-extension ms-toolsai.jupyter

Oh-my-zsh

Let's install the zsh plugin Oh My Zsh.

In a terminal execute the following command:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

If asked "Do you want to change your default shell to zsh?", press Y

At the end your terminal should look like this:

Ubuntu terminal with OhMyZsh

direnv

direnv is a shell extension. It makes it easy to deal with per project environment variables. This will be useful in order to customize the behavior of your code.

brew install direnv

Dotfiles

Run the dotfiles installer.

cd ~/code/$GITHUB_USERNAME/dotfiles && zsh install.sh

Check the emails registered with your GitHub Account. You'll need to pick one at the next step:

gh api user/emails | jq -r '.[].email'

Run the git installer:

cd ~/code/$GITHUB_USERNAME/dotfiles && zsh git_setup.sh

☝️ This will prompt you for your name (FirstName LastName) and your email. Be careful you need to put one of the email listed above thanks to the previous gh api ... command. If you don't do that, Kitt won't be able to track your progress.

Please now quit all your opened terminal windows.

Installing Python (with pyenv)

Uninstall conda

As we are using pyenv to install and manage our Python version, we need to uninstall conda, another package manager you may have on your machine if you previously installed Anaconda. Thus, we are preventing any possible Python version issue later.

Check if you have conda installed on your machine:

conda list

If you have zsh: command not found: conda, you can skip the uninstall of conda and jump to the Install pre-requisites section.

conda uninstall instructions
  • Install the Anaconda-Clean package from your terminal and run the cleaning
conda install anaconda-clean
anaconda-clean --yes
  • Remove every Anaconda directories
rm -rf ~/anaconda2
rm -rf ~/anaconda3
rm -rf ~/.anaconda_backup
rm -rf ~/opt
  • Remove Anaconda path from your .bash_profile
    • Open the file with code ~/.bash_profile
    • If the file opens find the line matching the following pattern export PATH="/path/to/anaconda3/bin:$PATH" and delete the line
    • Save the file with CMD + s
  • Restart your terminal with exec zsh
  • Remove Anaconda initialization from your .zshrc:
    • Open the file with code ~/.zshrc
    • Remove the code lines starting from >>> conda initialize >>> to <<< conda initialize <<<

Install pre-requisites

Before installing Python, please check your xz version with:

brew info xz

It should be more than 5.2.0, if not you should run:

sudo rm -rf /usr/local/opt/xz
brew upgrade
brew install xz

Then run:

brew install readline

Install pyenv

macOS comes with an outdated version of Python that we don't want to use. You might already have installed Anaconda or something else to tinker with Python and Data Science packages. All of this does not really matter as we are going to do a professional setup of Python where you'll be able to switch which version you want to use whenever you type python in the terminal.

First let's install pyenv with the following Terminal command:

brew install pyenv
exec zsh

Install Python

Let's install the latest stable version of Python:

pyenv install 3.10.6
πŸ›  Troubleshooting

If you encounter an error installing Python with pyenv about zlib:

zipimport.ZipImportError: can't decompress data; zlib not available

Install zlib with:

brew install zlib
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"

Then try to install Python again:

pyenv install 3.10.6

It could raise another error about bzip2, you can ignore it and continue to the next step.


OK once this command is complete, we are going to tell the system to use this version of Python by default. This is done with:

pyenv global 3.10.6
exec zsh

To check if this worked, run python --version. If you see 3.10.6, perfect! If not, ask a TA that will help you debug the problem thanks to pyenv versions and type -a python (python should be using the .pyenv/shims version first).

Python Virtual Environment

Before we start installing relevant Python packages, we will isolate the setup of the machine into a dedicated virtual environment. We will use a pyenv plugin called pyenv-virtualenv.

First let's install this plugin:

git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
exec zsh

Let's create the virtual environment we are going to use during the whole bootcamp:

pyenv virtualenv 3.10.6 default

Let's now set the virtual environment with:

pyenv global default

Great! Anytime we'll install Python package, we'll do it in that environment.

Python packages

Now it's time to install some packages in it.

First, let's upgrade pip, the tool to install Python Packages from pypi.org. In the latest terminal where the virtualenv default is activated, run:

pip install --upgrade pip

Then within the same folder, let's install some packages:

pip install -r requirements.txt

jupyter notebook extensions

Improve jupyter notebooks with extensions:

# install nbextensions
jupyter contrib nbextension install --user
jupyter nbextension enable toc2/main
jupyter nbextension enable collapsible_headings/main
jupyter nbextension enable spellchecker/main
jupyter nbextension enable code_prettify/code_prettify

Custom CSS

Improve the display of the details disclosure elements in the notebooks.

Open custom/custom.css in the config directory:

cd $(jupyter --config-dir)
mkdir -p custom
touch custom/custom.css
code custom/custom.css

Edit custom.css with:

summary {
    cursor: pointer;
    display:list-item;
}
summary::marker {
    font-size: 1em;
}

jupyter check up

Let's reset your terminal:

exec zsh

Now, check you can launch a notebook server on your machine:

jupyter notebook

Your web browser should open on a jupyter window:

jupyter.png

Click on New:

jupyter_new.png

A tab should open on a new notebook:

jupyter_notebook.png

nbextensions check up

Perform a sanity check for jupyter notebooks nbextensions. Click on Nbextensions:

jupyter_nbextensions.png

Untick "disable configuration for nbextensions without explicit compatibility" then check that at least all nbextensions circled in red are enabled:

nbextensions.png

You can close your web browser then terminate the jupyter server with CTRL + C.

Python setup check up

Check your Python version with the following commands:

zsh -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/python_checker.sh)" 3.10.6

Run the following command to check if you successfully installed the required packages:

zsh -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.sh)"

Now run the following command to check if you can load these packages:

python -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.py)"

Make sure you can run Jupyter:

jupyter notebook

And open a Python 3 notebook.

Make sure that you are running the correct python version in the notebook. Open a cell and run :

import sys; sys.version

Here you have it! A complete python virtual env with all the third-party packages you'll need for the whole bootcamp.

DBeaver

Download and install DBeaver, a free and open source powerful tool to connect to any database, explore the schema and even run SQL queries.

Docker πŸ‹

Docker is an open platform for developing, shipping, and running applications.

if you already have Docker installed on your machine please update with the latest version

Install Docker

Go to Docker website and choose Apple Intel:

Then follow the setup instructions, you are going to install a desktop application.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages