how upgrade brew packages starting from letter X

Posted:
Tags:  bash brew linux shell zsh

Run this command:

brew upgrade $(brew list | grep '^x')

Claude Desktop MCP Configuration Guide

Posted:
Tags:  Claude docker LLM MCP npx playwright

Claude Desktop MCP Configuration Guide

This guide covers how to configure Claude Desktop with various MCP (Model Context Protocol) servers to extend Claude’s capabilities with filesystem access, web browsing, documentation search, and persistent memory.

Configuration Setup

Config File Location

The Claude Desktop configuration file is located at:

Windows:

C:\Users\USER\AppData\Roaming\Claude\claude_desktop_config.json

You can also use the environment variable:

%USERPROFILE%\AppData\Roaming\Claude\claude_desktop_config.json

Configuration Methods

You can configure MCP servers using two different approaches:

NPX-Based Configuration

This method uses Node.js packages directly:

{
    "mcpServers": {
        "filesystem": {
            "args": [
                "-y",
                "@modelcontextprotocol/server-filesystem",
                "C:\\Users\\homee\\Desktop",
                "D:\\kotlin-workspace"
            ],
            "command": "npx"
        },
        "playwright": {
            "args": [
                "@playwright/mcp@latest"
            ],
            "command": "npx"
        }
    }
}

Docker-Based Configuration

This method uses Docker containers for isolated execution:

{
  "mcpServers": {
    "filesystem": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "--mount", "type=bind,src=c:\\Users\\homee\\Desktop,dst=/projects/Desktop",
        "--mount", "type=bind,src=d:\\kotlin-workspace\\michal_rutkowski,dst=/projects/michal_rutkowski",
        "mcp/filesystem",
        "/projects"
      ]
    }
  }
}

Available MCP Servers

Filesystem Access

Provides Claude with access to your local filesystem for reading and writing files.

Configuration:

"filesystem": {
    "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "C:\\Users\\homee\\Desktop",
        "D:\\kotlin-workspace"
    ],
    "command": "npx"
}

Playwright Web Browser Integration

Adds web browsing capabilities to Claude, allowing it to interact with websites, take screenshots, and automate web tasks.

Configuration:

"playwright": {
    "args": [
        "@playwright/mcp@latest"
    ],
    "command": "npx"
}

Context7 Documentation Access

Provides up-to-date documentation for popular libraries and frameworks, perfect for coding assistance.

Configuration:

"Context7": {
    "args": [
        "-y",
        "@upstash/context7-mcp"
    ],
    "command": "npx"
}

Usage Example:

Create a CRUD API in FastAPI with authentication. use context7

Basic Memory - Local LLM Memory

Gives Claude persistent memory across conversations, allowing it to remember and reference previous information.

Installation:

uv tool install basic-memory

Configuration:

"basic-memory": {
  "command": "uvx",
  "args": [
    "basic-memory",
    "mcp"
  ]
}

Usage Examples: - Write notes: “Create a note about coffee brewing methods” - Read notes: “What do I know about pour over coffee?” - Search: “Find information about Ethiopian beans”

Getting Started

  1. Locate your Claude Desktop configuration file
  2. Choose your preferred configuration method (NPX or Docker)
  3. Add the desired MCP servers to your configuration
  4. Restart Claude Desktop to apply the changes
  5. Start using the new capabilities in your conversations

These integrations significantly expand Claude’s capabilities, making it a powerful assistant for development, research, and productivity tasks.

how serve static files on localhost

Posted:
Tags:  development docker http localhost npx python server

How spin up http server to serve static files in a few seconds.

Using python

python -m http.server 8000 --bind 127.0.0.1
python -m http.server --directory /path-to-dir-with-static-files/
python -m http.server 8000 --directory /path-to-dir-with-static-files/
python -m http.server 9106 --directory /path/to/dir/with/static/files

Using npx

npx http-server -p 7890 --cors="*" /path/to/dir/with/static/files

Using docker

  • and nginx
    • on windows
    # Serve files from current directory
    docker run -it --rm -p 8080:80 -v %cd%:/usr/share/nginx/html nginx:alpine 
    
    # Serve files from specific directory
    docker run -it --rm -p 8080:80 -v /path/to/your/files:/usr/share/nginx/html nginx:alpine
    • on linux
    # Serve files from current directory
    docker run -it --rm -p 8080:80 -v $(pwd):/usr/share/nginx/html nginx:alpine
    
    # Serve files from specific directory
    docker run -it --rm -p 8080:80 -v /path/to/your/files:/usr/share/nginx/html nginx:alpine
  • or apache
    • on windows
    # Serve files from current directory
    docker run -it --rm -p 8080:80 -v %cd%:/usr/local/apache2/htdocs httpd:alpine
    
    # Serve files from specific directory
    docker run -it --rm -p 8080:80 -v /path/to/your/files:/usr/local/apache2/htdocs httpd:alpine
    • on linux
    # Serve files from current directory
    docker run -it --rm -p 8080:80 -v $(pwd):/usr/local/apache2/htdocs httpd:alpine
    
    # Serve files from specific directory
    docker run -it --rm -p 8080:80 -v /path/to/your/files:/usr/local/apache2/htdocs httpd:alpine

how to detect aws ecs deployment failure

Posted:
Tags:  aws cloudwatch ecs prometheus

Deployment Issue and Alert Configuration

Recently we had an interesting issue.
Due to an incorrect cloud config entry, one of our services fell into an endless loop of failed deployments.

So we had to add some kind of alerts to detect this in the future.

We are deploying our services on AWS ECS.
As we are using yet-another-cloudwatch-exporter to export CloudWatch metrics into Prometheus, the natural way was to expose new metrics and add a Prometheus alert based on it.

We exported one new metric from ECS/ContainerInsights:

apiVersion: v1alpha1
# [...]
discovery:
  jobs:
    - type: ECS/ContainerInsights
      regions:
        - eu-west-1
      dimensionNameRequirements: [ClusterName, ServiceName]
      statistics: [Average]
      nilToZero: true
      addCloudwatchTimestamp: false
      metrics:
        - name: DeploymentCount
# [...]

and added new config for Prometheus alerts to config/apps-alerts.yml:

---
groups:
  - name: apps-alerts
    rules:
      - alert: DeploymentAlert
        expr: sum by (dimension_ServiceName) (aws_ecs_containerinsights_deployment_count_average) >= 2
        for: 15m
        labels:
          severity: page
        annotations:
          summary: "Probable deployment problem: `{{ $labels.dimension_ServiceName }}`"

and finally added new config to Prometheus env-based configs (prometheus-XXX-config.yml):

# [...]
rule_files:
  # [...]
- apps-alerts.yml
# [...]

Now if there are some problems with failed deployments, we are seeing notifications in our slack.

how use multiple ssh keys with github

Posted:
Tags:  git github ssh win windows

Assuming that you have already configured one key to access GitHub using SSH.

Step 1: Create Additional SSH Key

Put an additional key in the SSH config directory, e.g.:

Windows:

%USERPROFILE%/.ssh/some-name/id_ed25519

Linux/macOS:

~/.ssh/some-name/id_ed25519

Step 2: Configure SSH Config

Now you need to edit (or create) SSH config under:

Windows:

%USERPROFILE%/.ssh/config

Linux/macOS:

~/.ssh/config

Add additional config:

Host github-some-new-label
    HostName github.com
    User git
    IdentityFile c:\Users\USERNAME\.ssh\some-name\id_ed25519
    IdentitiesOnly yes

Caution

IdentityFile - must be full path to SSH key

Notice

IdentitiesOnly yes is a crucial SSH configuration option that tells SSH to only use the specific key file you’ve specified and ignore all other keys.

Without IdentitiesOnly yes

SSH tries multiple keys in this order

  1. Keys loaded in SSH agent
  2. Default keys (~/.ssh/id_rsa, ~/.ssh/id_ed25519, etc)
  3. Your specified key file

GitHub sees the first key that works and authenticates with that account

With IdentitiesOnly yes

  • SSH only uses the exact key file you specified
  • It ignores SSH agent keys and default keys
  • GitHub only sees your intended key

Step 3: Configure Repository

Go to repo that should use new key.

Optionally set new git username and git email for given repo:

git config user.name "git username"
git config user.email "your.email@example.com"

Update remote to use new GitHub config:

git remote set-url origin git@github-some-new-label:github-user/project1.git

Where: - github-some-new-label - is the same as label after Host in .ssh/config -> Host github-some-new-label - github-user is GitHub user of appropriate repo; i.e., if https url is https://github.com/code-drill/django-app-template.git -> then ssh link will be: git@github-code-drill:code-drill/django-app-template.git.

Step 4: Test Configuration

Test the SSH connection:

ssh -T git@github-some-new-label

You should see:

Hi username! You've successfully authenticated, but GitHub does not provide shell access.

Step 5: Push Changes

Now you can push using the correct SSH key:

git push origin main

Simple Domain Redirect On AWS

Posted:
Tags:  aws route 53 s3

Assuming you have some domain configured on AWS using Route 53: example.eu
And now you want to redirect all traffic from example.eu to blog.example.eu

Step 1: Create S3 Bucket

  1. S3 Console -> Create bucket
  2. Bucket name: example.eu (must match your domain exactly)
  3. Keep all default settings -> Create bucket

Step 2: Configure S3 for Redirect

  1. Select your bucket -> Properties tab
  2. Static website hosting -> Edit
  3. Enable static website hosting
  4. Hosting type: Redirect requests for an object
  5. Host name: blog.example.eu
  6. Protocol: https
  7. Save changes

Copy the S3 website endpoint (e.g., http://example.eu.s3-website-us-east-1.amazonaws.com)

Step 3: Request SSL Certificate

Important: Must be done in us-east-1 region

  1. Certificate Manager -> Request certificate
  2. Domain name: example.eu
  3. Validation: DNS validation
  4. Request certificate
  5. Create records in Route 53 (button will appear)
  6. Wait for “Issued” status (5-10 minutes)

Step 4: Create CloudFront Distribution

  1. CloudFront Console -> Create distribution
  2. Origin domain: Paste your S3 website endpoint from Step 2 (e.g., http://example.eu.s3-website-us-east-1.amazonaws.com)
  3. Protocol: HTTP only
  4. Viewer protocol policy: Redirect HTTP to HTTPS
  5. Alternate domain names: example.eu
  6. SSL certificate: Select your certificate from Step 3
  7. Create distribution

Wait 15-20 minutes for deployment

Step 5: Update Route 53

  1. Route 53 -> Hosted zones -> example.eu
  2. Create record
  3. Record name: Leave empty
  4. Record type: A
  5. Alias: Yes
  6. Route traffic to: CloudFront distribution
  7. Select your distribution
  8. Create records

Wait 5~20 minutes, then test:
- Opening http://example.eu -> should redirect to https://blog.example.eu
- Opening https://example.eu -> should redirect to https://blog.example.eu

Using top in mongodb aggregation

Posted:
Tags:  aggregation db mongodb top

As mongo docs says:

MongoDB aggregation stage limits
Each stage can use up to 100 MB of RAM. You will get an error from the database if you exceed this limit. 

So if you are having this problem and you need the first (or last) element from a sorted collection, you can use the top operator.

So instead of sorting:

db.Entity.aggregate([
    {
        "$match": {
            "startTime": {
                "$gte": ISODate("2025-04-02T22:00:00Z"),
                "$lt": ISODate("2025-04-03T22:00:00Z")
                }
            }
        },
    {
        "$addFields": {
            "creatorPriority": {
                "$switch": {
                    "branches": [
                        { "case": { "$eq": ["$creator", "ADMIN"] }, "then": 1 }
                        ],
                    "default": 0
                    }
                }
            }
        },
    {
        "$sort": {
            "creatorPriority": -1,
            "createdAt": -1
            }
        },
    {
        "$group": {
            "_id": {
                "deviceId": "$deviceId",
                "startTime": "$startTime"
                },
            "records": { "$push": "$$CURRENT" }
            }
        },
    {
        "$replaceRoot": {
            "newRoot": { "$first": "$records" }
            }
        }
    ])

Use top:

db.Entity.aggregate([
    {
        "$match": {
            "startTime": {
                "$gte": ISODate("2025-06-18T22:00:00Z"),
                "$lt": ISODate("2025-06-20T22:00:00Z")
                }
            }
        },
    {
        "$addFields": {
            "creatorPriority": {
                "$switch": {
                    "branches": [
                        { "case": { "$eq": ["$creator", "ADMIN"] }, "then": 1 }
                        ],
                    "default": 0
                }
            }
        }
    },

    {
        "$group": {
            "_id": {
                "entityId": "$entityId",
                "startTime": "$startTime"
                },
            "topRecord": {
                "$top": {
                    "sortBy": { "createdAt": -1 },
                    "output": "$$ROOT"
                    }
                }
            }
        },
    {
        "$replaceRoot": {
            "newRoot": "$topRecord"
            }
        }
    ] , {
    allowDiskUse: false
    })

Gitignore windows cmd util

Posted:
Tags:  bash cmd command-line git gitignore linux windows zsh

Simple utility that lets you generate .gitignore using cmd/shell. You must have curl in your path.

  • windows/cmd: gitignore.cmd
@echo off
curl -sL https://www.toptal.com/developers/gitignore/api/%*
  • linux - add function into your aliases file or .*rc
    • function for alias
    function gitignore() { curl -sL https://www.toptal.com/developers/gitignore/api/\$@ ;}
    • zsh - code to run to add function to .zshrc
    echo "function gitignore() { curl -sL https://www.toptal.com/developers/gitignore/api/\$@ ;}" >> ~/.zshrc
    • bash - code to run to add function to .bash
    echo "function gitignore() { curl -sL https://www.toptal.com/developers/gitignore/api/\$@ ;}" >> ~/.bashrc

and than you can type:

gitignore python,pycharm,django