Skip to content

Instantly share code, notes, and snippets.

View LxYuan0420's full-sized avatar
✈️
On client travel - responses may be slower

Lik Xun Yuan (Lx) LxYuan0420

✈️
On client travel - responses may be slower
View GitHub Profile
@LxYuan0420
LxYuan0420 / nemo_data_designer_multilingual_codeswitch_reasoning_debate.py
Created December 18, 2025 06:56
Single-file NVIDIA NeMo Data Designer example that generates a multilingual code-switching reasoning+debate dataset using the OpenAI provider. Each row is produced via one structured LLM call (then flattened into query, reasoning, debate, final_answer) with samplers for language-mix intensity (Singlish/Manglish-style English+中文+Bahasa Melayu), d…
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "data-designer==0.2.0",
# "python-dotenv>=1.0.0",
# ]
# ///
r"""Generate a small multilingual reasoning+debate dataset (OpenAI provider).
@LxYuan0420
LxYuan0420 / uuid_pk_bench.sql
Created December 16, 2025 10:54
Postgres bigint PK vs UUIDv4 PK: locality + buffers demo (psql script)
-- Compare bigint PK vs UUIDv4 PK behavior in Postgres.
--
-- What this script tries to show (toy but reproducible):
-- 1) UUIDv4 PK indexes are bigger (uuid is 16 bytes vs bigint 8 bytes).
-- 2) UUIDv4 insertion order doesn't correlate with PK order, so "keyset pagination"
-- style access patterns touch far more heap pages (worse locality => more buffers).
--
-- It creates two tables with identical payloads:
-- - bigint_pk: sequential IDENTITY primary key
-- - uuidv4_pk: random gen_random_uuid() primary key
@LxYuan0420
LxYuan0420 / gliner_demo.py
Created December 6, 2025 10:06
Example of GLiNER2 multi-task schema on a finance-flavored dummy memo
#!/usr/bin/env python
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "gliner2",
# "rich",
# ]
# ///
"""Show GLiNER2 multi-task schema on a finance-flavored dummy memo.
@LxYuan0420
LxYuan0420 / sqlite_vector_extension.py
Created September 6, 2025 16:15
Interactive SQLite vector search demo using OpenAI embeddings and sqlite-vec
"""
SQLite + sqlite-vec interactive demo using OpenAI embeddings.
Usage
- Ensure `OPENAI_API_KEY` is set in your environment.
- Ensure `sqlite-vec` is available for Python (`import sqlite_vec`).
- Run: `python sqlite_vector_extension.py`
"""
from __future__ import annotations
@LxYuan0420
LxYuan0420 / cc-clipboard-alias.sh
Last active February 24, 2026 07:46
A minimalist but powerful Bash/Zsh alias that quickly copies the content of files or directories (Python, MDC, Shell scripts) directly to your clipboard with file headers for easy pasting into editors or ChatGPT prompts. Perfect when you need a fast and straightforward solution without installing any additional packages or dependencies.
# cc: pbcopy on steroids for file or directory
function cc() {
local target="$1"
if [[ -z "$target" ]]; then
echo "Usage: cc <file-or-directory>"
return 1
fi
# Resolve to absolute path
@LxYuan0420
LxYuan0420 / model2vec_example.py
Last active June 1, 2025 08:00
Quick Static Multilingual Embedding Demo with Vicinity
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.8"
# dependencies = [
# "model2vec",
# "vicinity",
# "numpy",
# ]
# ///