Git Commands

# Undo last commit but keep changes
git reset --soft HEAD^

# Stash changes with a message
git stash save "work in progress"

# Create and switch to new branch
git checkout -b feature/new-branch

# Amend last commit message
git commit --amend -m "New commit message"

# Empty commit
git commit --allow-empty -m "Empty-Commit"

Docker

# List all containers
docker ps -a

# Stop all running containers
docker stop $(docker ps -a -q)

# Remove all stopped containers
docker rm $(docker ps -a -q)

# Build and tag an image
docker build -t myapp:latest .

JavaScript

// Remove duplicates from array
const unique = [...new Set(array)];

// Deep clone an object
const clone = JSON.parse(JSON.stringify(obj));

// Sleep/delay function
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

// Check if array contains all unique values
const isUnique = arr => new Set(arr).size === arr.length;

SQL Queries

-- Find duplicate records
SELECT column_name, COUNT(column_name)
FROM table_name
GROUP BY column_name
HAVING COUNT(column_name) > 1;

--