{"id":15649597,"url":"https://github.com/loftwah/loftwahs-cheatsheet","last_synced_at":"2025-06-20T17:11:19.667Z","repository":{"id":40490460,"uuid":"451310621","full_name":"loftwah/loftwahs-cheatsheet","owner":"loftwah","description":"My own personal tech cheatsheet. This covers the stuff I use quite regularly.","archived":false,"fork":false,"pushed_at":"2024-12-22T01:21:21.000Z","size":157,"stargazers_count":41,"open_issues_count":4,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-30T17:50:56.237Z","etag":null,"topics":["bash","devops","hacktoberfest","linux","nodejs","python","sre","typescript"],"latest_commit_sha":null,"homepage":"https://blog.deanlofts.xyz/guides","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loftwah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"loftwah","custom":["https://paypal.me/loftwah"]}},"created_at":"2022-01-24T04:04:22.000Z","updated_at":"2024-12-22T06:24:25.000Z","dependencies_parsed_at":"2025-04-20T10:30:45.369Z","dependency_job_id":null,"html_url":"https://github.com/loftwah/loftwahs-cheatsheet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/loftwah/loftwahs-cheatsheet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loftwah%2Floftwahs-cheatsheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loftwah%2Floftwahs-cheatsheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loftwah%2Floftwahs-cheatsheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loftwah%2Floftwahs-cheatsheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loftwah","download_url":"https://codeload.github.com/loftwah/loftwahs-cheatsheet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loftwah%2Floftwahs-cheatsheet/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260985197,"owners_count":23092888,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","devops","hacktoberfest","linux","nodejs","python","sre","typescript"],"created_at":"2024-10-03T12:30:23.220Z","updated_at":"2025-06-20T17:11:14.647Z","avatar_url":"https://github.com/loftwah.png","language":null,"funding_links":["https://github.com/sponsors/loftwah","https://paypal.me/loftwah"],"categories":[],"sub_categories":[],"readme":"# Loftwah's Cheatsheet 2025\n\n![LOFTWAH'S](https://user-images.githubusercontent.com/19922556/150899356-b3930a05-6b65-43c4-a492-f5b7e5f94b39.png)\n\nThis repository consolidates essential tools, commands, and workflows tailored for my current tech stack, focusing on efficiency and modern best practices. Each section includes practical examples with expected outputs to help understand the tools better.\n\n---\n\n## Google Workspace\n\nGoogle Workspace remains central to my workflow.\n\n- [Admin Console](https://admin.google.com/ac/home?hl=en)\n- [Cloud Platform](https://console.cloud.google.com/home/dashboard)\n- [Drive](https://drive.google.com/drive/u/0/)\n- [Gmail](https://mail.google.com/)\n- [Sheets](https://sheets.google.com/)\n- [How Search Works](https://www.google.com/search/howsearchworks/?fg=1)\n\n---\n\n## Docker\n\nDocker simplifies containerisation and deployment. Docker Compose is now bundled with the `get.docker.com` installation script.\n\n### Installing Docker on Ubuntu\n\n```bash\ncurl -fsSL https://get.docker.com -o get-docker.sh\nsudo sh get-docker.sh\nsudo usermod -aG docker ${USER}\n```\n\n### Common Commands\n\n```bash\n# Start Docker daemon\nsudo service docker start\n# Launch a container with an interactive shell\nsudo docker run -it \u003cimage-name\u003e /bin/bash\n# Access a running container shell\nsudo docker exec -it \u003ccontainer-name\u003e bash\n# Inspect container details\nsudo docker inspect \u003ccontainer-name\u003e\n# List running containers\nsudo docker ps\n# Remove all stopped containers\nsudo docker rm $(sudo docker ps -aq)\n# Remove unused volumes\nsudo docker volume prune\n```\n\n### Practical Example: Web Application Stack\n\n```bash\n# Create project structure\nmkdir my-webapp \u0026\u0026 cd my-webapp\nmkdir src\n\n# Create a test page\ncat \u003e src/index.html \u003c\u003c 'EOF'\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003ctitle\u003eDocker Test\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003ch1\u003eHello from Docker!\u003c/h1\u003e\n\u003c/body\u003e\n\u003c/html\u003e\nEOF\n\n# Create compose file\ncat \u003e compose.yaml \u003c\u003c 'EOF'\nservices:\n  web:\n    image: nginx:latest\n    ports:\n      - \"8080:80\"\n    volumes:\n      - ./src:/usr/share/nginx/html\n  db:\n    image: postgres:latest\n    environment:\n      POSTGRES_PASSWORD: example\n      POSTGRES_DB: myapp\n    volumes:\n      - postgres_data:/var/lib/postgresql/data\n\nvolumes:\n  postgres_data:\nEOF\n\n# Start the stack\ndocker compose up -d\n\n# Expected Output:\n# [+] Running 2/2\n# ⠿ Container my-webapp-db-1   Started\n# ⠿ Container my-webapp-web-1  Started\n\n# Check status\ndocker compose ps\n# Expected Output:\n# NAME                COMMAND                  SERVICE             STATUS              PORTS\n# my-webapp-db-1      \"docker-entrypoint.s…\"   db                 running             5432/tcp\n# my-webapp-web-1     \"/docker-entrypoint.…\"   web                running             0.0.0.0:8080-\u003e80/tcp\n\n# View logs\ndocker compose logs\n```\n\nYou can now access the web server at http://localhost:8080\n\n---\n\n## Terraform\n\nTerraform allows Infrastructure as Code (IaC).\n\n### Installation via tfenv\n\n```bash\n# Install tfenv\ngit clone https://github.com/tfutils/tfenv.git ~/.tfenv\nsudo ln -s ~/.tfenv/bin/* /usr/local/bin\n\n# Install Terraform using tfenv\nsudo tfenv install latest\nsudo tfenv use latest\n```\n\n### Practical Example: AWS S3 Static Website\n\n```bash\n# Create new project\nmkdir terraform-demo \u0026\u0026 cd terraform-demo\n\n# Create main configuration\ncat \u003e main.tf \u003c\u003c 'EOF'\nprovider \"aws\" {\n  region = \"ap-southeast-2\"\n}\n\nresource \"aws_s3_bucket\" \"website\" {\n  bucket = \"my-unique-website-2025\"\n}\n\nresource \"aws_s3_bucket_public_access_block\" \"website\" {\n  bucket = aws_s3_bucket.website.id\n\n  block_public_acls       = false\n  block_public_policy     = false\n  ignore_public_acls      = false\n  restrict_public_buckets = false\n}\n\nresource \"aws_s3_bucket_website_configuration\" \"website\" {\n  bucket = aws_s3_bucket.website.id\n\n  index_document {\n    suffix = \"index.html\"\n  }\n\n  error_document {\n    key = \"error.html\"\n  }\n}\n\nresource \"aws_s3_bucket_policy\" \"website\" {\n  bucket = aws_s3_bucket.website.id\n  policy = jsonencode({\n    Version = \"2012-10-17\"\n    Statement = [\n      {\n        Sid       = \"PublicReadGetObject\"\n        Effect    = \"Allow\"\n        Principal = \"*\"\n        Action    = \"s3:GetObject\"\n        Resource  = \"${aws_s3_bucket.website.arn}/*\"\n      },\n    ]\n  })\n}\nEOF\n\n# Initialize working directory\nterraform init\n\n# Preview changes\nterraform plan\n\n# Apply changes\nterraform apply\n# For automation without prompts:\nterraform apply --auto-approve\n\n# Destroy when done\nterraform destroy --auto-approve\n```\n\n---\n\n## Language Installation with mise\n\nStreamline the installation of common languages (Ruby, Node.js, Python, etc.) using `mise`.\n\n### Install mise\n\n```bash\ncurl -fsSL https://get.mise.sh | sh\n```\n\n### Practical Example: Python Project Setup\n\n```bash\n# Create project directory\nmkdir python-project \u0026\u0026 cd python-project\n\n# Create mise configuration\ncat \u003e .mise.toml \u003c\u003c 'EOF'\n[tools]\npython = \"3.12\"\nnodejs = \"20\"\nEOF\n\n# Install specified versions\nmise install\n# Expected Output:\n# Installing python@3.12.0\n# Installing nodejs@20.0.0\n\n# Activate the environment\nmise use\n\n# Verify installations\npython --version\n# Expected Output: Python 3.12.0\n\nnode --version\n# Expected Output: v20.0.0\n```\n\n---\n\n## Python Package Management with uv\n\n### Install uv\n\n```bash\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n```\n\n### Practical Example: Managing Dependencies\n\n```bash\n# Create virtual environment\nuv create myenv\n# Expected Output: Created virtual environment at /path/to/myenv\n\n# Activate environment\nuv activate myenv\n\n# Create requirements file\ncat \u003e requirements.txt \u003c\u003c 'EOF'\nfastapi==0.109.0\nuvicorn==0.27.0\npydantic==2.5.3\npython-dotenv==1.0.0\nEOF\n\n# Install dependencies\nuv pip install -r requirements.txt\n# Expected Output: Successfully installed fastapi-0.109.0 uvicorn-0.27.0 ...\n\n# Create test application\ncat \u003e app.py \u003c\u003c 'EOF'\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\n\n# Create FastAPI instance\napp = FastAPI(title=\"My API\", version=\"1.0.0\")\n\n# Define a data model\nclass Item(BaseModel):\n    name: str\n    description: str | None = None\n    price: float\n\n# Create some endpoints\n@app.get(\"/\")\nasync def root():\n    return {\"message\": \"Hello from FastAPI!\"}\n\n@app.post(\"/items/\")\nasync def create_item(item: Item):\n    return {\"item\": item, \"status\": \"created\"}\n\nEOF\n\n# Run application\nuvicorn app:app --reload\n# Access API docs at http://127.0.0.1:8000/docs\n```\n\n---\n\n## Bun\n\nBun replaces `npm` and `npx` for a faster and modern JavaScript runtime and package manager.\n\n### Install Bun\n\n```bash\n# Via mise\nmise install bun\n\n# Or via curl\ncurl -fsSL https://bun.sh/install | bash\n```\n\n### Practical Example: Next.js Project\n\n```bash\n# Create new Astro project\nbunx create astro@latest my-app\ncd my-app\n\n# Install dependencies\nbun install\n# Expected Output: XX packages installed [XXX.XXms]\n\n# Add integrations (example with Tailwind)\nbunx astro add tailwind\n# Answer the prompt with 'y' to proceed\n\n# Development commands\nbun dev        # Start development server\nbun preview    # Preview production build\nbun build      # Build for production\nbun astro sync # Sync content types\n\n# Common integrations\nbun astro add react    # Add React support\nbun astro add vercel   # Add Vercel adapter\nbun astro add mdx      # Add MDX support\n\n# Create new component\ncat \u003e src/components/Counter.astro \u003c\u003c 'EOF'\n---\nlet count = 0;\n---\n\u003cbutton id=\"counter\"\u003e\n  Count: \u003cspan\u003e{count}\u003c/span\u003e\n\u003c/button\u003e\n\n\u003cscript\u003e\n  const button = document.getElementById('counter');\n  let count = 0;\n\n  button?.addEventListener('click', () =\u003e {\n    count++;\n    if (button.querySelector('span')) {\n      button.querySelector('span')!.textContent = count.toString();\n    }\n  });\n\u003c/script\u003e\nEOF\n```\n\n---\n\n## TailwindCSS\n\nSimplifying frontend design.\n\n### Practical Example: Setting up Tailwind\n\n```bash\n# Create new project\nmkdir tailwind-project \u0026\u0026 cd tailwind-project\n\n# Initialize package.json\nbun init -y\n\n# Install Tailwind and dependencies\nbun add -d tailwindcss postcss autoprefixer\nbunx tailwindcss init\n\n# Create configuration\ncat \u003e tailwind.config.mts \u003c\u003c 'EOF'\nimport { defineConfig } from 'tailwindcss';\n\nexport default defineConfig({\n  content: ['./src/**/*.{html,js,ts,tsx}'],\n  theme: {\n    extend: {\n      colors: {\n        primary: '#3B82F6',\n      },\n    },\n  },\n  plugins: [],\n});\nEOF\n\n# Create source directory\nmkdir -p src/styles\n\n# Create CSS file\ncat \u003e src/styles/tailwind.css \u003c\u003c 'EOF'\n@tailwind base;\n@tailwind components;\n@tailwind utilities;\nEOF\n\n# Create sample HTML\ncat \u003e src/index.html \u003c\u003c 'EOF'\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003ctitle\u003eTailwind Project\u003c/title\u003e\n    \u003clink href=\"./styles/output.css\" rel=\"stylesheet\"\u003e\n\u003c/head\u003e\n\u003cbody class=\"bg-gray-100\"\u003e\n    \u003cdiv class=\"container mx-auto px-4 py-8\"\u003e\n        \u003ch1 class=\"text-4xl font-bold text-primary\"\u003e\n            Hello Tailwind!\n        \u003c/h1\u003e\n    \u003c/div\u003e\n\u003c/body\u003e\n\u003c/html\u003e\nEOF\n\n# Add build script to package.json\ncat \u003e package.json \u003c\u003c 'EOF'\n{\n  \"scripts\": {\n    \"build\": \"tailwindcss -i ./src/styles/tailwind.css -o ./src/styles/output.css\",\n    \"watch\": \"tailwindcss -i ./src/styles/tailwind.css -o ./src/styles/output.css --watch\"\n  }\n}\nEOF\n\n# Build CSS\nbun run build\n```\n\n---\n\n## Nginx\n\nReliable reverse proxy with support for SSL via Let's Encrypt.\n\n### Configure Reverse Proxy for localhost\n\n```bash\n# Create Nginx configuration\nsudo tee /etc/nginx/sites-available/myapp \u003c\u003c 'EOF'\nserver {\n    listen 80;\n    server_name localhost;\n\n    location / {\n        proxy_pass http://127.0.0.1:3000;\n        proxy_http_version 1.1;\n        proxy_set_header Upgrade $http_upgrade;\n        proxy_set_header Connection 'upgrade';\n        proxy_set_header Host $host;\n        proxy_cache_bypass $http_upgrade;\n    }\n}\nEOF\n\n# Enable configuration\nsudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/\nsudo nginx -t\nsudo nginx -s reload\n```\n\n### Add SSL with Let's Encrypt and Certbot\n\n```bash\nsudo apt update\nsudo apt install certbot python3-certbot-nginx\nsudo certbot --nginx -d example.com -d www.example.com\n\n# Test SSL renewal\nsudo certbot renew --dry-run\n\n# Reload Nginx after config changes\nsudo nginx -s reload\n```\n\n### SSL Configuration Example\n\n```nginx\nserver {\n    listen 80;\n    server_name example.com www.example.com;\n    return 301 https://$host$request_uri;\n}\n\nserver {\n    listen 443 ssl;\n    server_name example.com www.example.com;\n\n    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;\n    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;\n    ssl_protocols TLSv1.2 TLSv1.3;\n    ssl_ciphers HIGH:!aNULL:!MD5;\n\n    location / {\n        proxy_pass http://127.0.0.1:3000;\n        proxy_http_version 1.1;\n        proxy_set_header Upgrade $http_upgrade;\n        proxy_set_header Connection 'upgrade';\n        proxy_set_header Host $host;\n        proxy_cache_bypass $http_upgrade;\n    }\n}\n```\n\n---\n\n## AWS CLI\n\nAutomating infrastructure tasks.\n\n### Common S3 Commands\n\n```bash\n# Create new bucket in Sydney region\naws s3 mb s3://my-sydney-bucket-2025 --region ap-southeast-2\n# Expected Output: make_bucket: my-sydney-bucket-2025\n\n# Create a test file\necho \"This is a test file for S3 upload\" \u003e test.txt\n\n# Upload file with metadata and explicit region\naws s3 cp test.txt s3://my-sydney-bucket-2025/uploads/test.txt \\\n    --region ap-southeast-2 \\\n    --metadata \"project=demo,environment=test\" \\\n    --content-type \"text/plain\"\n# Expected Output: upload: ./test.txt to s3://my-sydney-bucket-2025/uploads/test.txt\n\n# Verify metadata\naws s3api head-object \\\n    --bucket my-sydney-bucket-2025 \\\n    --key uploads/test.txt \\\n    --region ap-southeast-2\n# Expected Output: Shows metadata including content-type and custom metadata\n\n# Download file from specific region\naws s3 cp s3://my-sydney-bucket-2025/uploads/test.txt \\\n    downloaded-test.txt \\\n    --region ap-southeast-2\n# Expected Output: download: s3://my-sydney-bucket-2025/uploads/test.txt to ./downloaded-test.txt\n\n# Verify contents\ncat downloaded-test.txt\n# Expected Output: This is a test file for S3 upload\n\n# List bucket contents with sizes and dates\naws s3 ls s3://my-sydney-bucket-2025 --recursive --human-readable\n# Expected Output: 2024-12-22 10:30:15   29 B  uploads/test.txt\n\n# Remove file\naws s3 rm s3://my-sydney-bucket-2025/uploads/test.txt \\\n    --region ap-southeast-2\n\n# Remove bucket and all contents\naws s3 rb s3://my-sydney-bucket-2025 --force \\\n    --region ap-southeast-2\n```\n\n### Find Ubuntu AMIs\n\nFind Ubuntu AMIs using the [Ubuntu Cloud Image Locator](https://cloud-images.ubuntu.com/locator/ec2/).\n\nFor Sydney region (ap-southeast-2), you can filter the results accordingly.\n\n---\n\n## Summary\n\nThis cheatsheet combines tools and workflows aligned with my 2025 tech stack, ensuring compatibility, efficiency, and scalability in daily operations. Each section includes practical examples to demonstrate real-world usage.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floftwah%2Floftwahs-cheatsheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floftwah%2Floftwahs-cheatsheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floftwah%2Floftwahs-cheatsheet/lists"}