Skip to content

Instantly share code, notes, and snippets.

@khoa-le
khoa-le / you_couldve_invented_openclaw.md
Created February 12, 2026 17:03 — forked from dabit3/you_couldve_invented_openclaw.md
You Could've Invented OpenClaw

What makes OpenClaw powerful is surprisingly simple: it's a gateway that connects an AI agent to your messaging apps, gives it tools to interact with your computer, and lets it remember who you are across conversations.

The complexity comes from handling multiple channels simultaneously, managing persistent sessions, coordinating multiple agents, and making the whole thing reliable enough to run 24/7 on your machine.

In this post, I'll start from scratch and build up to OpenClaw's architecture step by step, showing how you could have invented it yourself from first principles, using nothing but a messaging API, an LLM, and the desire to make AI actually useful outside the chat window.

End goal: understand how persistent AI assistants work, so you can build your own.

First, let's establish the problem

#!/bin/bash
# gist-sync - Push file changes to GitHub Gist immediately
# Usage: gist-sync <file> [gist-id]
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
@khoa-le
khoa-le / agent loop
Created January 7, 2026 02:30 — forked from jlia0/agent loop
Manus tools and prompts
You are Manus, an AI agent created by the Manus team.
You excel at the following tasks:
1. Information gathering, fact-checking, and documentation
2. Data processing, analysis, and visualization
3. Writing multi-chapter articles and in-depth research reports
4. Creating websites, applications, and tools
5. Using programming to solve various problems beyond development
6. Various tasks that can be accomplished using computers and the internet
@khoa-le
khoa-le / measurePerformance.php
Last active October 8, 2024 07:36
How to Measure Performance for PHP Function
<?php
function measurePerformance(callable $callback)
{
// Start measurement
$startTime = microtime(true);
$startMemory = memory_get_usage();
$startCpu = getrusage();
// Execute the block of code
$callback();

VIN to Compatible Parts API Documentation

API Overview

This API allows users to retrieve a list of compatible parts for a vehicle by providing its Vehicle Identification Number (VIN).

Base URL

https://api.example.com/v1
AWSTemplateFormatVersion: '2010-09-09'
Description: Resources for Wild Ryde rider photo processing workflow.
Outputs:
RiderPhotoProcessingStateMachineArn:
Value:
Fn::GetAtt:
- RiderPhotoProcessingStateMachine
- Arn
FaceDetectionFunctionArn:
Value:
@khoa-le
khoa-le / gist:73e18cf9638c525b24d6941a14b8aa5f
Created February 9, 2023 07:25
Open AI Create Lamba services
Sure, here's an outline of the steps you can follow to develop an AWS Lambda function using PHP that reads data from an Excel file and saves it to Amazon DynamoDB:
Create a new Lambda function: Log in to the AWS Management Console, navigate to the Lambda service, and create a new function. Choose the "Author from scratch" option, and select PHP as the runtime.
Add an Amazon S3 trigger: In the designer section of the Lambda function, you can add an S3 trigger to trigger your function every time a new Excel file is uploaded to an S3 bucket.
Read the data from the Excel file: You can use a PHP library such as PHPExcel to read the data from the Excel file. You can access the uploaded file using the S3 bucket and key passed in the event data to the function.
Save the data to DynamoDB: To save the data to DynamoDB, you can use the AWS SDK for PHP to interact with the DynamoDB API. You can create a new DynamoDB table or use an existing one to save the data.
@khoa-le
khoa-le / gist:120e59dd87a3001ff30ecbf7f4494f96
Created February 7, 2023 09:01
Get SQL Log and time execute of Laravel Query Builder
\DB::enableQueryLog(); // Enable query log
// Your Eloquent query executed by using get()
dd(\DB::getQueryLog());
ffmpeg -i video.mov -c:v libvpx-vp9 -crf 30 -b:v 0 -b:a 128k -c:a libopus video.webm
#Convert video from 4K to FullHD
```
ffmpeg -i 50周年-PRビデオ_Final.mov -vf scale=1920:1080 -c:a copy output1080vid.mp4`
```
@khoa-le
khoa-le / gist:ba36820d2a62f2d40f674f0f4ee12f8c
Created February 6, 2023 10:52
Create cover image from 1 frame of video
ffmpeg -i video.mp4 -vframes 1 -f image2 cover.jpg