Developer Cheatsheets

Quick reference for Git, Docker, Python, JavaScript, SQL, Bash, Regex, CSS, HTML & Markdown

Git

Command/SyntaxDescription
git initInitialize a new repository
git clone Clone a remote repository
git statusCheck working tree status
git add .Stage all changes
git commit -m "msg"Commit staged changes
git push origin mainPush to remote
git pullFetch and merge remote changes
git branch Create new branch
git checkout Switch branches
git merge Merge branch into current
git log --onelineCompact commit history
git diffShow unstaged changes
git stashStash uncommitted changes
git reset --hard HEAD~1Undo last commit (destructive)
git remote -vList remote URLs

Docker

Command/SyntaxDescription
docker psList running containers
docker imagesList local images
docker run -d -p 80:80 nginxRun container detached with port mapping
docker build -t myapp .Build image from Dockerfile
docker exec -it bashShell into running container
docker stop Stop a container
docker rm Remove a container
docker rmi Remove an image
docker-compose up -dStart compose services
docker-compose downStop compose services
docker logs View container logs
docker volume lsList volumes
docker network lsList networks
docker pull Pull image from registry
docker system pruneRemove unused data

Python

Command/SyntaxDescription
python -m venv envCreate virtual environment
pip install Install package
pip freeze > requirements.txtExport dependencies
list comprehension: [x for x in range(10)]Create list inline
dict.get(key, default)Safe dictionary access
with open("f") as f:Context manager for files
lambda x: x*2Anonymous function
from collections import defaultdictImport defaultdict
try: ... except Exception as e:Exception handling
f"Hello {name}"F-string formatting
enumerate(list)Loop with index
zip(a, b)Iterate two lists together
@decoratorApply decorator
if __name__ == "__main__":Script entry point guard
*args, **kwargsVariable arguments

JavaScript

Command/SyntaxDescription
const x = arr.map(i => i*2)Transform array
const y = arr.filter(i => i>5)Filter array
const z = arr.reduce((a,b) => a+b, 0)Reduce array
async/awaitAsync function pattern
const {a, b} = objObject destructuring
const [...rest] = arrArray spread/rest
arr.find(x => x.id === 1)Find first match
Object.keys(obj)Get object keys
JSON.parse(str)Parse JSON string
fetch(url).then(r => r.json())Fetch API
localStorage.setItem(k, v)Store data locally
arr.sort((a,b) => a-b)Sort numerically
new Map()Create Map object
Promise.all([p1, p2])Await multiple promises
export default functionES module export

SQL

Command/SyntaxDescription
SELECT * FROM tableSelect all rows
WHERE col = valueFilter rows
ORDER BY col DESCSort results
GROUP BY colGroup aggregation
JOIN t2 ON t1.id = t2.fkInner join
LEFT JOIN t2 ON ...Left outer join
INSERT INTO t (col) VALUES (v)Insert row
UPDATE t SET col=v WHERE id=1Update row
DELETE FROM t WHERE id=1Delete row
COUNT(*), SUM(col), AVG(col)Aggregate functions
HAVING COUNT(*) > 1Filter groups
LIMIT 10 OFFSET 20Pagination
CREATE INDEX idx ON t(col)Create index
DISTINCT colUnique values
COALESCE(col, default)Null fallback

Bash

Command/SyntaxDescription
ls -laList all files with details
cd /pathChange directory
mkdir -p dir/subCreate nested directories
cp -r src destCopy recursively
mv old newMove/rename
rm -rf dirRemove directory (force)
find . -name "*.txt"Find files by name
grep -r "pattern" .Search in files
chmod 755 fileSet permissions
echo $VARPrint variable
export VAR=valueSet environment variable
cat file | grep patPipe output
> file (overwrite), >> file (append)Redirect output
$(command)Command substitution
for f in *.txt; do echo $f; doneLoop over files

Regex

Command/SyntaxDescription
.Any character
\d, \w, \sDigit, word char, whitespace
[a-z]Character class
^, $Start/end of line
*, +, ?Zero+, one+, optional
{n,m}n to m repetitions
(group)Capture group
(?:non-capture)Non-capturing group
a|bAlternation (or)
(?=lookahead)Positive lookahead
(?!neg-lookahead)Negative lookahead
\bWord boundary
[^abc]Negated character class
\1Back-reference
/pattern/giGlobal, case-insensitive flags

CSS

Command/SyntaxDescription
display: flexFlexbox container
justify-content: centerCenter horizontally (flex)
align-items: centerCenter vertically (flex)
display: gridGrid container
grid-template-columns: repeat(3, 1fr)3 equal columns
position: relative/absolutePositioning
@media (max-width: 768px)Responsive breakpoint
transition: all 0.3s easeSmooth transitions
box-shadow: 0 2px 8px rgba(0,0,0,.1)Box shadow
border-radius: 8pxRounded corners
:hover, :focus, :activePseudo-classes
::before, ::afterPseudo-elements
var(--custom-prop)CSS custom properties
clamp(1rem, 2vw, 3rem)Responsive sizing
gap: 1remGrid/flex gap

HTML

Command/SyntaxDescription
HTML5 doctype
Character encoding
Responsive viewport
,
,
Semantic structure
Semantic sections
Hyperlink
Image with alt text
Form
Email input
Submit button
Table structure
  • ,
Lists
Collapsible content
loading="lazy"Lazy load images
External CSS

Markdown

Command/SyntaxDescription
# H1, ## H2, ### H3Headings
**bold**, *italic*Text formatting
[text](url)Link
![alt](image-url)Image
- item or * itemUnordered list
1. itemOrdered list
`inline code`Inline code
```lang ... ```Code block
> quoteBlockquote
---Horizontal rule
| col | col |Table
- [ ] taskTask list
[^1]: footnoteFootnote
Collapsible (HTML in MD)
~~strikethrough~~Strikethrough