Skip to content

Instantly share code, notes, and snippets.

@M0119
Last active March 19, 2019 11:52
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 M0119/c8aaf673c1038547aaca943bcbaf3f0b to your computer and use it in GitHub Desktop.
Save M0119/c8aaf673c1038547aaca943bcbaf3f0b to your computer and use it in GitHub Desktop.

Lecture ✍️

Bash commands

Commit these to memory.

pwd # print working directory
ls # list directory contents
mkdir # make directory
cd # change directory
touch
mv # move
cp # copy
rm # remove
man # manual

These are cool but you probably won't need to use them much.

uname 
users # show users
uptime
cal # calendar
whoami # who am i
which # where is command (file)
file # view file details
echo
> # newline 
>> # write 
| # pipe
cat # concatenate files
wc # word count to count text document
info # information
kill # kill program
history # show bash history
grep # globally search a regular expression 
date
nano # small text editor
vim / vi

If you get stuck in vim (which you inevitably will) the key is knowing how to exit it.

When you see something like this:

~
~
~
~
filename.txt

Press esc then :q. If this doesn't immediately work, a combo of these (maybe esc twice) will usually get you out.

Install

Install homebrew

Install rbenv

Install ruby version 2.5.1

From the command line run ruby -v. If it displays ruby 2.5.1 you're done 🎉.

Review

We installed pry as a ruby gem. A gem is like downloading ruby code someone else has written so we can use it for ourselves.

Going forward, make pry your friend; it's such a useful tool for learning what different ruby methods actually return.

Resources

Navigate files
Using only terminal, navigate your file system to:
1. Create a file structure that matches your family tree e.g. a root folder with 2 grandparents, 2 parent directories in each with child folders within those
2. Create a folder called students. Inside the folder, create a few student text files 'jane.txt', etc
3. Rename one of the student files to include full names ('jane doe.txt') - note what happens if you try to use a space. How can you get around this?
4. Delete one student
Manual
1. Google some interesting commands
2. Use the man command to read about the command you have found
3. Experiment with this command, and its flags
Help
1. Repeat the above process, but use the —help flag to get info on the command
irb
1. Open irb from your command line by running irb
2. Try some basic math (1+1 *enter*)
3. Quit irb by sending the exit command
Run ruby
1. Use terminal to create a new file (e.g. touch my-cool-app.rb)
2. Open the file in your code editor (e.g. code my-cool-app.rb)
3. Write the same Ruby code (1+1) and save + close the file.
4. Run the code! We can do this with the ruby command. (e.g. ruby my-cool-app.rb)
5. The code runs, but nothing is returned on the screen. Add puts to the start of your code and try running the code again! (e.g. puts 1+1)
6. Experiment with some basic ruby!

Windows Setup

Installation Links

Windows Subsystem Linux (Ubuntu)

Instructions - Required Reading
Overview - Required Reading

Git

sudo apt-get update
sudo apt-get install git 

Alternative Install:

sudo apt install git
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git config --global core.autocrlf input

Ruby Version Manager & Ruby

Install GPG Keys:

$ gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Install RVM:

$ \curl -sSL https://get.rvm.io | bash -s stable

Install Ruby (Latest Version):

$ \curl -sSL https://get.rvm.io | bash -s stable --rails

Reload shell configuration & test:

$ source ~/.rvm/scripts/rvm

Check if installed correctly:

$ ruby -v
> ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin18]

Assign Default Ruby:

$ rvm use 2.6.1 --default

Troubleshooting: https://rvm.io/rvm/install#try-out-your-new-rvm-installation

Configuring VS Code Shell

Configure VS Code to use Bash One more thing you’ll want to do before you start downloading projects is set Bash to be the default terminal for VS Code. This is my primary way to interact with the Linux. To do this, open settings and add this rule to your User Settings:

"terminal.integrated.shell.windows": "C:\\WINDOWS\\sysnative\\bash.exe"

Restart VS Code and use CTRL + ` to open the Integrated Terminal (or search “Integrated Terminal” in the Command Palette). You should now be all setup and ready to web develop.

Troubleshooting: https://daverupert.com/2018/04/developing-on-windows-with-wsl-and-visual-studio-code/

Node JS Install

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
source ~/.bashrc
nvm install --lts

Creating a Soft Link

Allows you to cd into shortcut (Example cd fast-track)

`cd` to get to your "Linux" home directory
`ln -s %yourpathhere% fast-track` creates a link called "fast-track" which leads you to the path you specify if you `cd` into it.

So for me, that was /mnt/c/Users/Aaron/fast-track

Github SSH Setup

Step One:
 $ mkdir -p ~/.ssh && ssh-keygen -t ed25519 -o -a 100 -f ~/.ssh/id_ed25519 -C "TYPE_YOUR_EMAIL@HERE.com"

Step Two: 
$ cat ~/.ssh/id_ed25519.pub

Step Three: 
$ github.com/settings/ssh

Step Four: 
$ ssh -T git@github.com

Step Five: 
Sample Output:
# Hi --------! You've successfully authenticated, but GitHub does not provide shell access

Step Six (If you didnt see the above output): 
$ ssh-add ~/.ssh/id_ed25519 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment