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
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,
@up1
up1 / 1.txt
Last active November 4, 2024 08:12
GenAI Script
$npx genaiscript run genaisrc/demo01.genai.mjs
genaiscript: genaisrc/demo01.genai.mjs
trace: /.genaiscript/runs/demo01/2024-11-04T08-11-49-564Z.trace.md
prompting openai:gpt-4o (~543 tokens)
```json schema=CITY_SCHEMA
[
{
"name": "Bangkok",
@up1
up1 / 1.txt
Last active November 3, 2024 15:18
Google AI API
const a = await ai.languageModel.capabilities()
console.log(a.available);
// ถ้าขึ้นคำว่า readily แสดงว่าเราสามารถใช้งานได้เลย
// แต่ถ้าไม่ ให้ทำการสร้างดังนี้
await ai.languageModel.create();
ทำการตรวจสอบใน browser = chrome://components
* Optimization Guide On Device Model
@up1
up1 / application.properties
Last active November 3, 2024 12:07
Spring Boot 3 + OpenTelemetry
# For OTLP - OTLP Prometheus endpoint, OTLP requires pushing
management.otlp.metrics.export.url=http://localhost:9090/api/v1/otlp/v1/metrics
# only for demo purposes
management.otlp.metrics.export.step=2s
# All traces should be sent to latency analysis tool
management.tracing.sampling.probability=1.0
# OTLP endpoint - OTLP Tempo endpoint
management.zipkin.tracing.endpoint=http://localhost:4318/v1/traces
management.zipkin.tracing.encoding=PROTO3
@up1
up1 / 1.txt
Last active October 30, 2024 03:57
Demo :: Fetch Mock
$node --test --experimental-test-coverage
▶ getUserById
✔ should fetch user data successfully (4.168291ms)
✔ getUserById (4.678666ms)
ℹ tests 1
ℹ suites 1
ℹ pass 1
ℹ fail 0
ℹ cancelled 0
@up1
up1 / db.js
Last active October 23, 2024 15:43
NodeJs 23
import { DatabaseSync } from "node:sqlite";
const db = new DatabaseSync(":memory:");
db.exec(`
CREATE TABLE data(
key TEXT PRIMARY KEY,
value TEXT
) STRICT
`);
@up1
up1 / 1.txt
Last active October 18, 2024 03:31
FastAPI Testimg
$pytest --cov=main --cov-report=html
================================= test session starts ==================================
platform darwin -- Python 3.12.5, pytest-8.3.3, pluggy-1.5.0
rootdir: python-test
plugins: time-machine-2.14.2, cov-5.0.0, anyio-4.4.0, Faker-25.2.0
collected 2 items
test_main.py .. [100%]
@up1
up1 / 1.py
Last active October 14, 2024 16:46
FastAPI :: OpenAPI or Swagger
from fastapi import FastAPI
app = FastAPI()
@app.get("/", tags=["Main"])
async def root():
return {"message": "Hello World"}
@app.get("/products/{product_id}", tags=["Product"])
async def get_product(product_id: int):
@up1
up1 / 01.bash_shortcuts_v2.md
Created September 26, 2024 03:46 — forked from tuxfight3r/01.bash_shortcuts_v2.md
Bash keyboard shortcuts

Bash Shortcuts

visual cheetsheet

Moving

command description
ctrl + a Goto BEGINNING of command line