Notes

Node vs Browser

A tale of Two Runtimes: Node.js vs Browser

Global vs Window


File I/O

The FS Module

Creating a New File

Reading Existing Files

Fancy File I/O

We can use Read File and Write file together to replace occurences of certain phrases with something else.

const fs = require("fs");

function replaceContents(file, oldStr, newStr) {
  fs.readFile(file, "utf8", (err, data) => {
    if (err) {
      console.log(err);
    }
    let newData = data.split(oldStr).join(newStr);
    writeContents(file, newData);
  });
}

function writeContents(file, data) {
  fs.writeFile(file, data, "utf8", (err) => {
    if (err) {
      console.log(err);
    }
    console.log("done!");
  });
}

replaceContents("poetry.txt", "do not", "should");

Gitting Started with Git

Tracking Changes in a Repository

Branches and Workflow

Bringing it Back Together

Connecting with the world via Github

Collaboration via Git and Github

> git branch add-my-new-file
> git add my-new-file.js
> git commit -m "Add new file"
> git push -u origin add-my-new-file

This is the typical push workflow.


Managing your Github Repository

Diff Options

# See differences between the 'feature'
# branch and the 'master' branch.
> git diff master feature

# Compare two different commits
> git diff 1fc345a 2e3dff

# Compare a specific file across separate commits
> git diff 1fc345a 2e3dff my-file.js

Time Travel checkout

# You can checkout a branch name.
# You'll be using this particular branch a lot!
> git checkout master

# You can also use commit hashes directly
> git checkout 7d3e2f1

# Using a hyphen instead of a hash will take
# you to the last branch you checked out
> git checkout -

# You can use "HEAD~N" to move N commits prior
# to the current HEAD
> git checkout HEAD~3

Git Do-over: Reset and Rebase

Rebase: An Alternative Form of Time Travel

The Golden Rule of Git

Never change the history of a branch that’s shared with others.


Git Merge Conflicts & You

Conflict Resolution img of conflict