📜  cheat seet traversy (1)

📅  最后修改于: 2023-12-03 14:59:55.222000             🧑  作者: Mango

Cheat Sheet for Programmers

Introduction

As a programmer, sometimes it can be difficult to remember all the syntax, commands and shortcuts for every programming language or tool you may use. This cheat sheet was created to serve as a quick reference guide for common programming tasks and syntax.

Table of Contents
  • HTML
  • CSS
  • JavaScript
  • Python
  • Git
  • Visual Studio Code
HTML

Basic Structure

<!DOCTYPE html>
<html>
  <head>
    <title>Page Title</title>
  </head>
  <body>
    <h1>Heading 1</h1>
    <p>Paragraph</p>
  </body>
</html>

Images

<img src="image.jpg" alt="description of image">

Links

<a href="https://example.com">Link Text</a>
CSS

Selector Types

/* element selector */
h1 {
  color: red;
}

/* class selector */
.className {
  font-size: 18px;
}

/* ID selector */
#myID {
  background-color: #ccc;
}

Box Model

/* margin */
.element {
  margin: 10px;
}

/* padding */
.element {
  padding: 5px;
}

/* border */
.element {
  border: 1px solid #000;
}
JavaScript

Variables

let x = 5;
const PI = 3.14;

Functions

function functionName(param1, param2) {
  // function code
}

// arrow function
const functionName = (param1, param2) => {
  // function code
}

Loops

// for loop
for (let i = 0; i < 10; i++) {
  // loop code
}

// while loop
while (condition) {
  // loop code
}

// do-while loop
do {
  // loop code
} while (condition)
Python

Variables

x = 5
PI = 3.14

Functions

def functionName(param1, param2):
  # function code

# lambda function
lambda_function = lambda param1, param2: param1 + param2

Loops

# for loop
for i in range(10):
  # loop code

# while loop
while condition:
  # loop code

# for-each loop
for item in list:
  # loop code
Git

Basic Commands

# clone a repo
git clone https://github.com/username/repo.git

# add changes to staging area
git add .

# commit changes
git commit -m "commit message"

# push changes to remote repo
git push origin master

# pull changes from remote repo
git pull origin master

Branching

# create a new branch
git checkout -b newBranch

# switch to an existing branch
git checkout existingBranch

# merge branches
git checkout master
git merge newBranch
Visual Studio Code

Shortcuts

# open command palette
Ctrl + Shift + P

# search for a file
Ctrl + P

# select all occurrences of a word
Ctrl + Shift + L

# comment out a line
Ctrl + /

# format code
Shift + Alt + F
Conclusion

This cheat sheet is by no means an exhaustive reference guide, but it should be helpful in many common programming tasks. Feel free to add to it or customize it for your own needs. Happy programming!