1. Mac browser shortcut keys

    • ⌘ + Shift + 4 // # takes you to 4th screen
    • ⌘ + w // close window
    • ⌘ + l // takes you to browser url address
    • ⌘ + t // new tab
    • ⌘ + option + arrow // go between tabs
    • ⌘ + n //open a new window
    • ⌘ + Shift + n// open a new window in Incognito mode
    • ⌘ + t // open a new tab, and jump to it
    • ⌘ + Option + Right //jump to the next open tab
    • ⌘ + Option + left // jump to the previous open tab
    • ⌘ + 1 through ⌘ + 8 // jump to a specific tab
    • ⌘ + w // closes the current tab or pop-up
    • ⌘ + m // minimize the window
    • ⌘ + q // quit program

2. Visual Studio Code Shortcuts

    • Shift + command + p // SHORTCUT KEY FINDER
    • Command + / // comments out all selected lines
    • Option + z //selected toggles code word wrap
    • Shift + Option + F // automatically indents all of your code
    • Command + l // selects entire line of code
    • Option + arrow // moves code line up or down
    • Option + shift + arrow // copies line of code and moves up/down
    • Control + tab // cycle through tabs within window
    • Select word + Command + left click // takes you to section where that function is defined
    • In PyCharm…select code...refactor...rename // rename all variables at once
    • Right click on function // get function definition

  • Debugging In Visual Studio
    • Hit debug button
    • Create break points by clicking to left of the code line numbers
    • Value should be seen in the left after clicking on the debug icon…or by hovering over
    • Use the python print function…which prints messages to the while your code is running
    • print("the error is " + str(error))

3. Command Line Interface (“CLI”)

How to navigate through folders

    • $ ls // lists out files and folders in your current directory
    • $ pwd // print working directory (i.e. current folder)
    • $ cd Dropbox //changes directory to dropbox…
    • $ cd .. // Takes you up one folder to the parent directory
    • $ cd // Takes you back to your home directory…
    • $ cd first letter, then tab //type cd, space, first letter of folder, tab autocompletes, then first letter of next folder, then tab…

Other commands

    • $ control + c //shut down server; cancel / quit
    • Up arrow //scroll through previous commands
    • $ history // history of previous commands
    • $ clear // clears history
    • Command+shift+d // opens up new CLI
    • Command+w // close windows
    • Ctrl+r //searches previously typed code
    • $ code /backend/main.py // opens up a vile in VS code
    • $ printenv // print environment variables
    • $ cp SOURCE DESTINATION // copies a file from source to the destination
    • $ export USERNAME=picasso // sets env variable USERNAME to picasso
    • $ echo $ USERNAME // prints out env variable e.g., picasso
    • $ mkdir // create a folder or directory FOLDER_NAME
    • $ touch FILE_NAME // create new file

CLI tools to run apps

    • $ python3 myapp.py // Run a normal python file (make sure to first navigate to the file where the program sits on your CLI)
    • $ FLASK_APP=app.py flask run // Run a flask app defined at app.py
    • $ FLASK_APP=app.py FLASK_DEBUG=true flask run //To enable live reload, use the following
  • Note that FLASK_APP must be set to the server file path with an equal sign in between. No spaces. FLASK_APP = app.py will not work. These flags have to be set exactly as expected, as FLAG=value.

4. GitHub

4.1. Overview

Is a Distributed Version Control System. Each clone provides a full back up of the files on each computer.

Allows you to use version control across a large structure of different code files so that you know what changes as you make edits to your code

Allows you to go back to previous versions if you make mistakes

Is especially important to use this when coding in teams

  • Coding in teams is kind of like writing a group essay; The chief editor must assign parts of the essay to each person and make sure that they arent writing over each others work
  • On a programming team, manager assigns certain rights to each individual of what they can change so that each coder works on changing out their specific part of the code without accidentally over-writing other peoples changes

Allows you to make commits one part at a time; it is best practice to make commits often…this is similar to saving your work often

Allows you to provide feedback and info to maximize code quality

Is ubiquitous across the industry within programming

Technically it stores data by…With Git, every time you commit, or save the state of your project, Git basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. To be efficient, if files have not changed, Git doesnt store the file again, just a link to the previous identical file it has already stored. Git thinks about its data more like a stream of snapshots.

4.2. GitHub Vocab

Git a version control program that saves your programs and folder

.git folder contains all the information that is necessary for your project in version control and all the information about commits, remote repository address etc. All are present in this folder. It also contains a log which stores your commit history so that you can roll back to history.

Github uses the git software and makes it easier to manage git repositories; it is ubiquitous in the industry

  • Also has command line codes
  • Github desktop uses the command line in a GUI

Repository (repo) = a central location where your project is stored and managed. Can be local or remote/online

  • Local repo is on your machine
  • Remote repo is online in cloud (e.g., gitHub)

Git directoryis where Git stores the metadata and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer.

Working tree is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify.

Command Line is the only place you can run all Git commands — most of the GUIs implement only a partial subset of Git functionality for simplicity. If you know how to run the command-line version, you can probably also figure out how to run the GUI version, while the opposite is not necessarily true.

Clone Is a copy of the cloud version that you can download to your local version

Branch Allows to create a separate chain of commits so that you can work on part of a project while someone else is working on another branch of the project. Makes it easier for you to compare dfiferences between two versions of the same code.

4.3.Workflow Summary

1. Go to right directory in terminal

2. Once in right local folder, clone GitHub directory to local folder

  • $ git clone https://github.com/myUserName/repoName

2b. Or add that folder and code to github

  • $ git init
  • $ git add .
  • $ git commit -m 'initial project version'
  • $ git remote add origin2 https://github.com/myUserName/repoName
  • $ git remote -v
  • $ git push origin2 master

3. Open folder & make changes to files

  • $ code test_repo.py
  • $ git status

4. Save changes through a new commit and push that to github

  • $ git add .
  • $ git commit -m "test commit 1"
  • $ git push origin2 master
  • $ git status
  • $ heroku git:clone -a uprise-u

5. Download changes made by other users

  • $ git fetch origin
  • $ git pull

6. If you make a mistake, go back to an old commit and start again

  • $ git log
  • $ git checkout -b oldStateName d919509
  • $ git add .
  • $ git commit -m "third commit based on oldStateName branch"
  • $ git push origin oldStateName
  • $ git checkout master
  • $ git checkout oldStateName
  • $ git checkout master
  • $ git merge oldStateName

4.4. Debugging commands

    • $ git config -list // describes which remote origin you are pointed towards
    • $ git config --global user.name "John Doe"
    • $ git config --global user.email johndoe@example.com // lets you change your username and password that you are required for you to post and write and pull from GitHub
    • $ git help fetch // brings up help manual for fetch or any other verb
    • $ man git-VERB // brings up help manual for fetch or any other verb
    • $ git diff // lets you view your staged and unstaged changes
    • $ git log --oneline --decorate --graph --all print out history of your commits, showing where your branch pointers are and how your history has diverged
    • $git log --oneline --decorate can easily see this by running a simple git log command that shows you where the branch pointers are pointing
    • $ git branch // If you run it with no arguments, you get a simple listing of your current branches. * character that prefixes the master branch indicates the branch that you currently have checked out (i.e., the branch that HEAD points to)
    • $ git branch -v // shows last commit on each branch
    • $ git branch -D BRANCHNUMBER You can delete branches that you no longer use
    • $ git reset -hard deletes all changes since last commit

4.5.Additional Resources

See “Pro Git” second edition by Scott Chacon and Ben Straub

http://www.youtube.com/watch?v=DQUcmNO4diQ

http://gitref.org/basic/

http://git-scm.com/book/en/Getting-Started-About-Version-Control