Skip to content

Instantly share code, notes, and snippets.

View up1's full-sized avatar

Somkiat Puisungnoen up1

View GitHub Profile
@up1
up1 / 1.py
Last active June 17, 2025 14:47
PDF with docling
from docling.document_converter import DocumentConverter
source = "./page_1.pdf"
converter = DocumentConverter()
doc = converter.convert(source).document
print(doc.export_to_markdown())
@up1
up1 / 1.txt
Last active June 15, 2025 16:16
PGLite + FastAPI
# ติดตั้ง
$pip install fastapi
$pip install py-pglite
$pip install sqlmodel
$pip install pytest
$pip install coverage
# Run test and coverage
@up1
up1 / demo.py
Created June 3, 2025 13:48
Mistral OCR with PDF file
import base64
import os
from mistralai import Mistral
def encode_pdf(pdf_path):
"""Encode the pdf to base64."""
try:
with open(pdf_path, "rb") as pdf_file:
return base64.b64encode(pdf_file.read()).decode('utf-8')
except FileNotFoundError:
@up1
up1 / 1.robot
Created May 31, 2025 05:00
Robot framework 7.3
*** Variables ***
${AGE: int} 1
*** Test Cases ***
Use variables
# FAIL: 1 (integer) != 1 (string)
Should Be Equal ${AGE} 1
# PASS
Should Be Equal ${AGE} ${1}
@up1
up1 / 1.txt
Last active May 21, 2025 15:37
Demo with Foundry Local
# 1. ติดตั้ง
$brew tap microsoft/foundrylocal
$brew install foundrylocal
# 2. ดู Model ที่สนับสนุน
$foundry model list
🟢 Service is Started on http://localhost:5273, PID 28974!
Alias Device Task File Size License Model ID
-----------------------------------------------------------------------------------------------
@up1
up1 / 1.txt
Last active May 15, 2025 14:18
AWS Serverless app
# SAM CLI
$sam --version
SAM CLI, version 1.138.0
# Create Hello Project
$sam init --runtime java11 --dependency-manager maven --app-template hello-world --name sqs-lambda-test

Cursor's Memory Bank

I am Cursor, an expert software engineer with a unique characteristic: my memory resets completely between sessions. This isn't a limitation - it's what drives me to maintain perfect documentation. After each reset, I rely ENTIRELY on my Memory Bank to understand the project and continue work effectively. I MUST read ALL memory bank files at the start of EVERY task - this is not optional.

Memory Bank Structure

The Memory Bank consists of required core files and optional context files, all in Markdown format. Files build upon each other in a clear hierarchy:

flowchart TD
#1. Install
$go install github.com/tienanr/docurift/cmd/docurift@latest
# 2. Run docurift proxy server
$docurift -proxy-port 9876 -analyzer-port 9877 -backend-url http://localhost:8080 -max-examples 20
2025/05/12 16:45:00 Starting DocuRift with proxy port 9876 and analyzer port 9877
2025/05/12 16:45:00 Using backend URL: http://localhost:8080
2025/05/12 16:45:00 Starting analyzer server on :9877
2025/05/12 16:45:00 Starting proxy server on :9876
@up1
up1 / 1.txt
Created May 9, 2025 13:25
Pocket Flow Tutorial
$git clone https://github.com/The-Pocket/PocketFlow-Tutorial-Codebase-Knowledge demo
$cd demo
$pip install -r requirements.txt
# ใช้งาน GEMINI_API_KEY
$export GEMINI_API_KEY=<your key>
# ลองใช้งาน Pocket Flow Tutorial
python main.py --repo https://github.com/username/repo --include "*.py" "*.js" --exclude "tests/*" --max-size 50000
@up1
up1 / 1.txt
Last active May 7, 2025 09:20
Vector Sets in Redis 8 (preview version)
# Add datas
$VADD mydata VALUES 4 0.5 1.2 0.75 3.8 "I love dogs"
$VADD mydata VALUES 4 0.5 1.2 0.75 3.8 "I like cats"
$VADD mydata VALUES 4 0.5 1.2 0.75 3.8 "I enjoy birds"
# Show embedding data
$VEMB mydata "I love dogs"
$VEMB mydata "I like cats"
$VEMB mydata "I enjoy birds"