Skip to content

Instantly share code, notes, and snippets.

View up1's full-sized avatar

Somkiat Puisungnoen up1

View GitHub Profile
@up1
up1 / 1.txt
Created December 16, 2024 14:16
Memcached from terminal
# สร้าง key ชื่อ user_01 มีค่าเป็น somkiat และ key มีอายุ 60 วินาที
$echo -e 'set user_01 0 60 5\r\nsomkiat\r' | nc <server ip> 11211
# ดึงข้อมูลด้วย key
$echo 'get user_01' | nc <server ip> 11211
# ลบข้อมูลด้วย key
$echo 'delete user_01' | nc <server ip> 11211
# ลบข้อมูลทั้งหมด
@up1
up1 / 1.py
Last active December 16, 2024 10:06
MarkItDown
from markitdown import MarkItDown
markitdown = MarkItDown()
result = markitdown.convert("ExecutionArchitectureApproachPaper.pdf")
print(result.text_content)
@up1
up1 / 1.txt
Last active December 15, 2024 14:48
Programming :: performance
$go go build -o main main.go
$./main
# Before
Number of primes found: 50847534
Time taken: 9.29 seconds
# After
Number of primes found: 50847534
Time taken: 5.34 seconds
@up1
up1 / 1.txt
Last active December 15, 2024 05:10
RESP protocol with Go
# ฝั่ง Redis-cli
127.0.0.1:6379> set counter 1
OK
# ฝั่ง Server
Received: *3\r\n$3\r\nset\r\n$7\r\ncounter\r\n$1\r\n1\r\n
แสดงผลใน terminal
set
$7
@up1
up1 / 1.txt
Last active December 12, 2024 14:39
Playwright :: screenshot + full page
$npx playwright screenshot --full-page "somkiat.cc" "screenshot.png"
ดูรายละเอียดเพิ่มเตอม
$npx playwright screenshot --help
Usage: npx playwright screenshot [options] <url> <filename>
capture a page screenshot
@up1
up1 / 1.txt
Last active December 9, 2024 09:55
Local LLM with LlamaEdge
1. ติดตั้ง WasmEdge
$curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install_v2.sh | bash
2. Download LLM model เพื่อมา run บนเครื่อง local โดยใช้งาน Llama 3.2, 1b
$curl -LO https://huggingface.co/second-state/Llama-3.2-1B-Instruct-GGUF/resolve/main/Llama-3.2-1B-Instruct-Q5_K_M.gguf
3. ทำการ Download app chat มาใช้งาน เพื่อทดสอบการถามตอบกับ Local LLM server
$curl -LO https://github.com/second-state/LlamaEdge/releases/latest/download/llama-chat.wasm
4. ทำการ run app chat เพื่อใช้งาน model Llama 3.2, 1b ที่ทำการ download มา
@up1
up1 / 1.txt
Last active November 30, 2024 14:37
Playwith MCP
// 1. ติดตั้ง SQLite database
$brew install uv git sqlite3
// 2. สร้าง database และข้อมูลตัวอย่าง
# Create a new SQLite database
sqlite3 ./test.db <<EOF
CREATE TABLE products (
id INTEGER PRIMARY KEY,
@up1
up1 / 1.txt
Last active November 26, 2024 11:01
Terminal-based presentaion
$brew install slides
$slides slide.md
@up1
up1 / 1.txt
Last active November 16, 2024 04:39
.NET 9
$dotnet --version
9.0.100
$dotnet new list
These templates matched your input:
Template Name Short Name Language Tags
-------------------------------------------- -------------------------- ---------- --------------------------------
API Controller apicontroller [C#] Web/ASP.NET
ASP.NET Core Empty web [C#],F# Web/Empty
@up1
up1 / 1.txt
Last active November 9, 2024 06:47
Gemini model with OpenAI library
$export GEMINI_API_KEY=your-key
$python demo.py
ChatCompletionMessage(
content='I can definitely help you find a restaurant in Thailand! To give you the best recommendations,
I need a little more information. Tell me:\n\n* **Where in Thailand are you looking?**
(e.g., Bangkok, Chiang Mai, Phuket, etc.) \n* **What kind of cuisine are you interested in?**
(e.g., Thai, Italian, Japanese, street food, etc.)\n* **What is your budget?**
(e.g., budget-friendly, mid-range, high-end)\n* **What kind of atmosphere are you looking for?**
(e.g., romantic, lively, casual, etc.)\n\nOnce I have this information,