Git
| Command/Syntax | Description |
|---|---|
git init | Initialize a new repository |
git clone | Clone a remote repository |
git status | Check working tree status |
git add . | Stage all changes |
git commit -m "msg" | Commit staged changes |
git push origin main | Push to remote |
git pull | Fetch and merge remote changes |
git branch | Create new branch |
git checkout | Switch branches |
git merge | Merge branch into current |
git log --oneline | Compact commit history |
git diff | Show unstaged changes |
git stash | Stash uncommitted changes |
git reset --hard HEAD~1 | Undo last commit (destructive) |
git remote -v | List remote URLs |
Docker
| Command/Syntax | Description |
|---|---|
docker ps | List running containers |
docker images | List local images |
docker run -d -p 80:80 nginx | Run container detached with port mapping |
docker build -t myapp . | Build image from Dockerfile |
docker exec -it | Shell into running container |
docker stop | Stop a container |
docker rm | Remove a container |
docker rmi | Remove an image |
docker-compose up -d | Start compose services |
docker-compose down | Stop compose services |
docker logs | View container logs |
docker volume ls | List volumes |
docker network ls | List networks |
docker pull | Pull image from registry |
docker system prune | Remove unused data |
Python
| Command/Syntax | Description |
|---|---|
python -m venv env | Create virtual environment |
pip install | Install package |
pip freeze > requirements.txt | Export 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*2 | Anonymous function |
from collections import defaultdict | Import 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 |
@decorator | Apply decorator |
if __name__ == "__main__": | Script entry point guard |
*args, **kwargs | Variable arguments |
JavaScript
| Command/Syntax | Description |
|---|---|
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/await | Async function pattern |
const {a, b} = obj | Object destructuring |
const [...rest] = arr | Array 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 function | ES module export |
SQL
| Command/Syntax | Description |
|---|---|
SELECT * FROM table | Select all rows |
WHERE col = value | Filter rows |
ORDER BY col DESC | Sort results |
GROUP BY col | Group aggregation |
JOIN t2 ON t1.id = t2.fk | Inner join |
LEFT JOIN t2 ON ... | Left outer join |
INSERT INTO t (col) VALUES (v) | Insert row |
UPDATE t SET col=v WHERE id=1 | Update row |
DELETE FROM t WHERE id=1 | Delete row |
COUNT(*), SUM(col), AVG(col) | Aggregate functions |
HAVING COUNT(*) > 1 | Filter groups |
LIMIT 10 OFFSET 20 | Pagination |
CREATE INDEX idx ON t(col) | Create index |
DISTINCT col | Unique values |
COALESCE(col, default) | Null fallback |
Bash
| Command/Syntax | Description |
|---|---|
ls -la | List all files with details |
cd /path | Change directory |
mkdir -p dir/sub | Create nested directories |
cp -r src dest | Copy recursively |
mv old new | Move/rename |
rm -rf dir | Remove directory (force) |
find . -name "*.txt" | Find files by name |
grep -r "pattern" . | Search in files |
chmod 755 file | Set permissions |
echo $VAR | Print variable |
export VAR=value | Set environment variable |
cat file | grep pat | Pipe output |
> file (overwrite), >> file (append) | Redirect output |
$(command) | Command substitution |
for f in *.txt; do echo $f; done | Loop over files |
Regex
| Command/Syntax | Description |
|---|---|
. | Any character |
\d, \w, \s | Digit, 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|b | Alternation (or) |
(?=lookahead) | Positive lookahead |
(?!neg-lookahead) | Negative lookahead |
\b | Word boundary |
[^abc] | Negated character class |
\1 | Back-reference |
/pattern/gi | Global, case-insensitive flags |
CSS
| Command/Syntax | Description |
|---|---|
display: flex | Flexbox container |
justify-content: center | Center horizontally (flex) |
align-items: center | Center vertically (flex) |
display: grid | Grid container |
grid-template-columns: repeat(3, 1fr) | 3 equal columns |
position: relative/absolute | Positioning |
@media (max-width: 768px) | Responsive breakpoint |
transition: all 0.3s ease | Smooth transitions |
box-shadow: 0 2px 8px rgba(0,0,0,.1) | Box shadow |
border-radius: 8px | Rounded corners |
:hover, :focus, :active | Pseudo-classes |
::before, ::after | Pseudo-elements |
var(--custom-prop) | CSS custom properties |
clamp(1rem, 2vw, 3rem) | Responsive sizing |
gap: 1rem | Grid/flex gap |