How to Use Convex on GitHub Codespaces
Did you ever wanted to use Convex in GitHub Codespaces and could not? It requires a few extra steps since Codespaces uses port forwarding. Here’s how to get it working. Step 1: Start the Local Convex Server Run the following command to start the Convex development server in local mode: npx convex dev --local Step 2: Retrieve the Admin Key Open the forwarded port 6791 in your browser (click the “Open in Browser” option in Codespaces for that port). You’ll see a JSON response containing your deployment info: ...
How to generate an image using Python and RunPod
Overview This short guide explains how use python to generate an image using RunPod. What it does Creates a RunPod job using the /run endpoint with a text prompt. Polls the /status/{id} endpoint until the job reaches COMPLETED. Reads output.image_url (a data:image/png;base64,... string), decodes the base64 payload, and saves it as {job_id}.png (or into --outdir). The script is organized with small functions: create_job(prompt, key, base_url) — create a job and return the API response JSON. poll_job(job_id, key, base_url, timeout) — poll until completion and return the final JSON payload. save_image_from_output(output, job_id, out_dir) — decode and write the PNG to disk. Prerequisites requests package (install with pip install -r requirements.txt or pip install requests) A RunPod API key Set your key using an environment variable: ...
Building an MCP Server the Official Way: STDIO Core + HTTP Gateway Explained
Do you want to know how complicated it is to create an MCP server in python using the official MCP package? It’s complicated because: the MCP server should run over stdio transport belongs outside tools live inside and HTTP is just a gateway layer This blog explains how I rewired my architecture. The Architecture The application is composed of: MCP Server HTTP Gateway Layer 1: The MCP Server This is where: ...
Fixing Certificate Expiration on k3s
Did you just log in to your k3s cluster and find a certificate has expired? The Problem When k3s/kubectl fails because a cert expired you might see an error like: sudo systemctl status k3s You get something like this: [x509: certificate has expired or is not yet valid Check certificate dates from your kubeconfig: kubectl config view --minify --raw \ | yq -r '.users[0].user."client-certificate-data"' \ | base64 -d \ | openssl x509 -noout -dates With the result as: ...
Fixing Hugo on Cloudflare
Do you want to update your Hugo website on Cloudflare to use the latest version ? And you just did that and got a wierd error version 'GLIBC_2.33' not found (required by hugo) ? 19:27:47.373 Installing Hugo 0.152.2 19:27:48.269 hugo: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by hugo) 19:27:48.270 hugo: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by hugo) 19:27:48.270 hugo: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by hugo) 19:27:48.270 hugo: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by hugo) 19:27:48.274 Failed: build command exited with code: 1 19:27:49.294 Failed: error occurred while running build command The solution is simple: ...
xRDP TCP/IP Improvements
Is xRDP slow on your linux vm ? Here is an easy way to improve the TCP/IP performance: Configure the TCP send buffer size Edit the file /etc/xrdp/xrdp.ini and update tcp_send_buffer_bytes tcp_send_buffer_bytes=4194304 Restart the service: systemctl restart xrdp Configure the kernel network buffer size Change the network buffer size to a larger value with using the next command: sudo sysctl -w net.core.wmem_max=8388608 And create a new file /etc/sysctl.d/xrdp.conf with the following content: ...
Setting Up Proxmox With a Bridge Interface and DHCP
If you’re hosting Proxmox VE on a server with only one public IP, you can still create a private virtual network with NAT and DHCP for your VMs using a Linux bridge. This guide shows how to set up a Proxmox bridge (vmbr0) and run a DHCP server for VMs using a private subnet like 192.168.1.0/24. 🌐 1. Configure Proxmox Bridge (vmbr0) Edit your host’s network config (Debian-style /etc/network/interfaces) and add the setup for vmbr0 at the end, along with iptables for routing. ...
Installing a simple kubernetes UI
Here is a way to install a minimalist kubernetes UI - Headlamp. A simple way of installing it is using yaml files, like this one: kind: Service apiVersion: v1 metadata: name: headlamp namespace: kube-system spec: ports: - port: 80 targetPort: 4466 selector: k8s-app: headlamp --- kind: Deployment apiVersion: apps/v1 metadata: name: headlamp namespace: kube-system spec: replicas: 1 selector: matchLabels: k8s-app: headlamp template: metadata: labels: k8s-app: headlamp spec: containers: - name: headlamp image: ghcr.io/headlamp-k8s/headlamp:latest args: - "-in-cluster" - "-plugins-dir=/headlamp/plugins" ports: - containerPort: 4466 livenessProbe: httpGet: scheme: HTTP path: / port: 4466 initialDelaySeconds: 30 timeoutSeconds: 30 nodeSelector: 'kubernetes.io/os': linux --- kind: Secret apiVersion: v1 metadata: name: headlamp-admin namespace: kube-system annotations: kubernetes.io/service-account.name: "headlamp-admin" type: kubernetes.io/service-account-token This will install a deployment named headlamp in kube-system namespace, a service to expose the UI, and a secret for the admin user. ...
Integrate Salesforce as a custom tool in an AI Agents
Do you want a simple way to integrate Salesforce into your smolagents agents? There is an simple way to achieve this. First, let’s add smolagents, python-dotenv and simple-salesforce cli, in requirements.txt file: smolagents[gradio] python-dotenv simple-salesforce Next, let’s code a simple AI Agent: import os import yaml from dotenv import load_dotenv from simple_salesforce import Salesforce from smolagents import (CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool) from Gradio_UI import GradioUI load_dotenv('.env') @tool def get_insurance_policies_by_status(status: str) -> str: """A tool that fetches the number of insurance policies from Salesforce based on their status. Args: status: The status of the insurance policies to fetch (e.g., 'Active', 'Inactive'). Returns: A string indicating the number of insurance policies with the specified status. """ try: # Load Salesforce credentials from environment variables sf_username = os.getenv("SALESFORCE_USERNAME") sf_password = os.getenv("SALESFORCE_PASSWORD") sf_token = os.getenv("SALESFORCE_SECURITY_TOKEN") # Connect to Salesforce sf = Salesforce(username=sf_username, password=sf_password, security_token=sf_token) print("Connected to Salesforce.") # Query Salesforce for active insurance policies query = f"SELECT COUNT() FROM InsurancePolicy__c WHERE Status__c = '{status}'" result = sf.query(query) # Extract the count from the query result policies_count = result['totalSize'] return f"The number of insurance policies with status '{status}' is: {policies_count}" except Exception as e: return f"Error fetching insurance policies with status '{status}': {str(e)}" model = HfApiModel( max_tokens=2096, temperature=0.5, model_id='Qwen/Qwen2.5-Coder-32B-Instruct', custom_role_conversions=None, ) with open("prompts.yaml", 'r') as stream: prompt_templates = yaml.safe_load(stream) agent = CodeAgent( model=model, tools=[get_insurance_policies_by_status], max_steps=6, verbosity_level=1, grammar=None, planning_interval=None, name=None, description=None, prompt_templates=prompt_templates ) GradioUI(agent).launch() The core of our AI Agent is the tool get_insurance_policies_by_status that get the status from the LLM model, calls Salesforce using simple_salesforce and returns the number of active/inactive policies. ...
AWS Lambda With Magnum and FastAPI
Do you want a simple way to deploy an python FastAPI in AWS Lambda ? There is an simple way to do this with Magnum. First, let’s add FastAPI, magnum and SAM cli, in requirements.txt file: fastapi mangum aws-sam-cli Next, let’s code a simple FastAPI sample app: from fastapi import FastAPI from mangum import Mangum app = FastAPI() @app.get("/high-scores") async def high_scores(): return {"scores": [100, 200, 300]} @app.post("/insert-score") async def insert_score(data: dict): return {"status": "success", "data": data} lambda_handler = Mangum(app, lifespan="off") if __name__ == "__main__": import uvicorn uvicorn.run("app:app", port=5000, log_level="info", reload=True) Next, let’s setup SAM with a template.yml file: ...