Skip to content

Latest commit

 

History

History
135 lines (108 loc) · 4.4 KB

File metadata and controls

135 lines (108 loc) · 4.4 KB

Week6

Markdown

This section is inspired by Markdown Guide - Basic Syntax.

  1. Philosophy
    • Easy-to-read and Easy-to-write
  2. Headings
  3. Paragraphs
    • Indentation
  4. Line Breaks
    • Two \n or Two white spaces
    • For line break, use trailing white space or the HTML tag at the end of the line
  5. Emphasis
    • Bold
    • Italic
    • Bold and Italic
  6. Blockquotes
    • Single block
    • Multiline
    • Nested Blockquotes
    • Blockquotes with Other Elements
  7. Lists
    • Ordered List
    • Unordered List
    • Adding Elements in Lists
      • Four Spaces or One Tab
    • Nested List
      • Four Spaces or One Tab
  8. Code
    • Single Line code
    • Code Blocks
    • Escaping Backticks
  9. Horizontal Rules
  10. Links
    • Adding Titles
    • Formatting Links
    • Reference-style Links
  11. Images
    • Adding Titles
  12. Math Mode
  13. Escaping Characters

Git

This article is inspired by Missing Semester - Version Control (Git) and Version control concepts and best practices.

  1. Pre-Git history
    • What is a Version control systems (VCSs)?

    • Purpose of VCS

    • Git vs. SVN

  2. Brief Introduction to Git
    • Repositories and working copies
  3. Model of Git
    • Snapshot
    • Linear History (Directed Acyclic Graph)
    • Data model
    • Hash Function: sha1
    • References: Master and HEAD
    • Staging Area
  4. Git commands
    • Basics
    • Branching and merging
    • Remotes
    • Undo
  5. Advanced Commands
    • git add -p
    • blame
    • rebase
    • stash
    • .gitignore
  6. Best practice to use Git
    • Don't commit generated files
    • Write a good commit messages (cz)
  7. More to explore: submodules, gpg, pre-commit hook...

Shell Scripting

This section is inspired by Shell Scripting for Beginners – How to Write Bash Scripts in Linux.

  1. Shebang revisited
  2. Declare variables in Shell
  3. Arithmetic Expressions
  4. How to read user input
  5. Numeric Comparison logical operators
  6. If and AND + OR
  7. Loop
    • Looping with Numbers
    • Looping with Strings
    • While Loop
  8. Function and Arguments

Exercises for Shell Scripting

  1. Write bash functions marco and polo that do the following. Whenever you execute marco the current working directory should be saved in some manner, then when you execute polo, no matter what directory you are in, polo should cd you back to the directory where you executed marco. For ease of debugging you can write the code in a file marco.sh and (re)load the definitions to your shell by executing source marco.sh.

  2. Write a tiny-echo bash function that prints all the arguments it received to the terminal. You should not use echo in your function. (printf may be a helpful function.)

  3. Say you have a command that fails rarely. In order to debug it you need to capture its output, but it can be time-consuming to get a failure run. Write a bash script that runs the following script until it fails and captures its standard output and error streams to files and prints everything at the end. Bonus points if you can also report how many runs it took for the script to fail.

#!/usr/bin/env bash

n=$(( RANDOM % 100 ))

if [[ n -eq 42 ]]; then
echo "Something went wrong"
>&2 echo "The error was using magic numbers"
exit 1
fi

echo "Everything went according to plan"

Additional Resources

  1. Semantic Linefeed
  2. What is in that .git directory?
  3. Git Commands You Probably Do Not Need
  4. Markdown Presentation Ecosystem