notes

Log | Files | Refs

commit 56ec126c7109c53885617cb1d138b4cb6fb449be
parent e66488e9bebb11b564df22beebb4506d90e613a9
Author: ling0x <ling0x@users.noreply.github.com>
Date:   Sat, 13 Jun 2026 13:00:44 +0100

chore: format

Diffstat:
Dcommands/docker.md | 4----
Acommands/docker.txt | 4++++
Dcommands/gawk.md | 115-------------------------------------------------------------------------------
Acommands/gawk.txt | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dcommands/git.md | 20--------------------
Acommands/git.txt | 4++++
Dcommands/llama-cpp.md | 37-------------------------------------
Acommands/llama-cpp.txt | 9+++++++++
Dcommands/ollama.md | 31-------------------------------
Acommands/ollama.txt | 13+++++++++++++
Dcommands/psql.md | 108-------------------------------------------------------------------------------
Acommands/psql.txt | 10++++++++++
Dcommands/rust.md | 5-----
Acommands/rust.txt | 25+++++++++++++++++++++++++
Dcommands/yay.md | 46----------------------------------------------
Acommands/yay.txt | 19+++++++++++++++++++
Acommands/yt-dlp-guide.txt | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
17 files changed, 242 insertions(+), 366 deletions(-)

diff --git a/commands/docker.md b/commands/docker.md @@ -1,4 +0,0 @@ -# Docker - -Pretty display docker ps: -`docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}\t{{.Networks}}"` diff --git a/commands/docker.txt b/commands/docker.txt @@ -0,0 +1,4 @@ +DOCKER + +Pretty display docker ps: +docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}\t{{.Networks}}" diff --git a/commands/gawk.md b/commands/gawk.md @@ -1,115 +0,0 @@ -# ================================================================================ GAWK — quick notes (Arch Linux) - -GNU Awk. Handy for shaping psql or other CLI output in a pipe. - -## INSTALL - -sudo pacman -S gawk postgresql - -psql is in the postgresql package. - -## PSQL: OUTPUT THAT PIPES WELL - -Use unaligned, one-field-per-line rows: - -psql -h localhost -U myuser -d mydb -t -A -F','\ --c "SELECT id, name, active FROM users LIMIT 5" - -Flags: -t rows only (no header/footer) -A unaligned -F',' field separator (comma -or tab) - -## SIMPLE EXAMPLES - -Print one column - -``` - psql -h localhost -U myuser -d mydb -t -A -c "SELECT email FROM users" \ - | gawk '{ print $1 }' - - With comma-separated psql output: - - psql ... -t -A -F',' -c "SELECT id, email FROM users" \ - | gawk -F',' '{ print $2 }' - - -Filter rows -~~~~~~~~~~~ - - Keep rows where active (3rd field) is true: - - psql ... -t -A -F',' -c "SELECT id, name, active FROM users" \ - | gawk -F',' '$3 == "t" { print $1, $2 }' - - -Add a CSV header -``` - -psql ... -t -A -F',' -c "SELECT id, name FROM users"\ -| gawk -F',' 'BEGIN { print "id,name" } { print }' - -Sum a numeric column - -``` - psql ... -t -A -c "SELECT amount FROM orders" \ - | gawk '{ sum += $1 } END { print sum }' - - -key=value lines -~~~~~~~~~~~~~~~ - - psql ... -t -A -F',' -c "SELECT id, name FROM users WHERE id = 42" \ - | gawk -F',' '{ printf "id=%s name=%s\n", $1, $2 }' - - -COMPLEX EXAMPLE — MULTI-RECORD CLI OUTPUT ------------------------------------------ - -When input is not one row per line (nested structs, repeated fields): - - - set RS (record separator) to split on blocks, not newlines - - use gawk match() with a 3rd arg for capture groups (needs gawk, not awk) - - loop with match() to collect repeated fields (e.g. roles) - -Turn verbose get-all-profiles output into a table: - - kioko cad "$ENV" db user get-all-profiles | gawk ' - BEGIN { - RS = "UserProfile" - printf "%-3s %-22s %-20s %-8s %-5s %s\n", "ID", "USERNAME", "NAME", "BLOCKED", "LINK", "ROLES" - } - /TrimmedUser/ { - match($0, /id: ([0-9]+)/, a) - match($0, /username: "([^"]*)"/, u) - match($0, /first_name: "([^"]*)"/, f) - match($0, /last_name: "([^"]*)"/, l) - match($0, /blocked: ([a-z]+)/, b) - match($0, /email_link: ([0-9]+)/, e) - roles = "" - s = $0 - while (match(s, /role: ([A-Za-z]+)/, r)) { - roles = roles (roles ? "," : "") r[1] - s = substr(s, RSTART + RLENGTH) - } - printf "%-3s %-22s %-20s %-8s %-5s %s\n", a[1], u[1], f[1] " " l[1], b[1], e[1], roles - }' - - What each piece does: - - RS = "UserProfile" split stream on each profile block - /TrimmedUser/ only process records with that marker - match($0, /.../, arr) put capture group 1 into arr[1] - while (match(s, ...)) walk the string; collect every role: - printf "%-3s ..." fixed-width columns - - Same idea works on any verbose tool output, or psql nested text - (e.g. json_agg) when flat -F splitting is not enough. - - -TIPS ----- - - * Match gawk -F to the separator you pass to psql -F. - * Use gawk (not plain awk) for match(str, regex, array) captures. - * Quote SQL in -c "..." so the shell does not eat $ in awk patterns. - * In psql, \copy and \o are fine interactively; gawk fits scripts and pipes. -``` diff --git a/commands/gawk.txt b/commands/gawk.txt @@ -0,0 +1,90 @@ +================================================================================ +GAWK — quick notes (Arch Linux) + +GNU Awk. Handy for shaping psql or other CLI output in a pipe. + +INSTALL +sudo pacman -S gawk postgresql + +psql is in the postgresql package. + +PSQL: OUTPUT THAT PIPES WELL +Use unaligned, one-field-per-line rows: + +psql -h localhost -U myuser -d mydb -t -A -F','\ +-c "SELECT id, name, active FROM users LIMIT 5" + +Flags: -t rows only (no header/footer) -A unaligned -F',' field separator (comma +or tab) + +SIMPLE EXAMPLES +Print one column +psql -h localhost -U myuser -d mydb -t -A -c "SELECT email FROM users" \ + | gawk '{ print $1 }' + +With comma-separated psql output: +psql ... -t -A -F',' -c "SELECT id, email FROM users" \ + | gawk -F',' '{ print $2 }' + +Filter rows +Keep rows where active (3rd field) is true: +psql ... -t -A -F',' -c "SELECT id, name, active FROM users" \ + | gawk -F',' '$3 == "t" { print $1, $2 }' + +Add a CSV header +psql ... -t -A -F',' -c "SELECT id, name FROM users"\ +| gawk -F',' 'BEGIN { print "id,name" } { print }' + +Sum a numeric column +psql ... -t -A -c "SELECT amount FROM orders" \ + | gawk '{ sum += $1 } END { print sum }' + +key=value lines +psql ... -t -A -F',' -c "SELECT id, name FROM users WHERE id = 42" \ + | gawk -F',' '{ printf "id=%s name=%s\n", $1, $2 }' + +COMPLEX EXAMPLE — MULTI-RECORD CLI OUTPUT +----------------------------------------- +When input is not one row per line (nested structs, repeated fields): +- set RS (record separator) to split on blocks, not newlines +- use gawk match() with a 3rd arg for capture groups (needs gawk, not awk) +- loop with match() to collect repeated fields (e.g. roles) + +Turn verbose get-all-profiles output into a table: +kioko cad "$ENV" db user get-all-profiles | gawk ' +BEGIN { + RS = "UserProfile" + printf "%-3s %-22s %-20s %-8s %-5s %s\n", "ID", "USERNAME", "NAME", "BLOCKED", "LINK", "ROLES" +} +/TrimmedUser/ { + match($0, /id: ([0-9]+)/, a) + match($0, /username: "([^"]*)"/, u) + match($0, /first_name: "([^"]*)"/, f) + match($0, /last_name: "([^"]*)"/, l) + match($0, /blocked: ([a-z]+)/, b) + match($0, /email_link: ([0-9]+)/, e) + roles = "" + s = $0 + while (match(s, /role: ([A-Za-z]+)/, r)) { + roles = roles (roles ? "," : "") r[1] + s = substr(s, RSTART + RLENGTH) + } + printf "%-3s %-22s %-20s %-8s %-5s %s\n", a[1], u[1], f[1] " " l[1], b[1], e[1], roles +}' + +What each piece does: +RS = "UserProfile" split stream on each profile block +/TrimmedUser/ only process records with that marker +match($0, /.../, arr) put capture group 1 into arr[1] +while (match(s, ...)) walk the string; collect every role: +printf "%-3s ..." fixed-width columns + +Same idea works on any verbose tool output, or psql nested text +(e.g. json_agg) when flat -F splitting is not enough. + +TIPS +---- +* Match gawk -F to the separator you pass to psql -F. +* Use gawk (not plain awk) for match(str, regex, array) captures. +* Quote SQL in -c "..." so the shell does not eat $ in awk patterns. +* In psql, \copy and \o are fine interactively; gawk fits scripts and pipes. diff --git a/commands/git.md b/commands/git.md @@ -1,20 +0,0 @@ -# Git - -Undo last 2 already pushed commits: - -``` -git revert HEAD HEAD~1 -``` - -(If the commits have already been pushed to a shared remote, use git revert -instead — it creates new "undo" commits rather than rewriting history, which -avoids causing problems for collaborators. ) - -And the push it back to repo: - -``` -git push origin <branch-name> --force-with-lease -``` - -(This rewrites remote history and can break things for anyone who has already -pulled those commits — avoid on shared branches.) diff --git a/commands/git.txt b/commands/git.txt @@ -0,0 +1,4 @@ +GIT + +Pretty display git log: +git log --graph --pretty=format:'%h - %10n: %s' --date=short diff --git a/commands/llama-cpp.md b/commands/llama-cpp.md @@ -1,37 +0,0 @@ -# llama.cpp - -Install: - -```bash -curl -fsSL https://llama.app/install.sh | sh -``` - -Serve on a custom port (terminal 1): - -```bash -llama serve \ - -hf google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0 \ - --port 9090 \ - -np 1 \ - -c 8192 -``` - -`--port 9090` binds to 9090 instead of the default 8080. - -### Context size - -The context overflow you hit is because the server defaulted to 4096 tokens. pi's system prompt + tools + your message exceeded that. Restart with a larger context using `-c 8192` as above. - -If 8192 still overflows on large tasks, try `-c 16384` (your 4090 may fit it with `-np 1`). - -Use with pi (terminal 2): - -```bash -pi install git:github.com/huggingface/pi-llama # once - -LLAMA_BASE_URL="http://localhost:9090/v1" \ - pi --provider llama-cpp \ - --model google/gemma-4-31B-it-qat-q4_0-gguf:Q4_0 -``` - -`LLAMA_BASE_URL` must match the server port (`/v1` is the OpenAI-compatible API path). diff --git a/commands/llama-cpp.txt b/commands/llama-cpp.txt @@ -0,0 +1,9 @@ +LLAMA-CPP + +Quick start: +llama-cpp -m models/path/to/model.gguf -n 128 -p "Explain quantum physics" + +Optimizations: +- Use -ngl 32 for GPU offloading (NVIDIA/AMD) +- Use -rl 2048 for context window +- Use --threads [number of physical cores] diff --git a/commands/ollama.md b/commands/ollama.md @@ -1,31 +0,0 @@ -# Ollama - -### Test 1: Non-streaming (stream: false) - -```bash -curl -X POST http://127.0.0.1:11434/api/generate \ - -H "Content-Type: application/json" \ - -d '{ - "model": "gemma4:26b", - "prompt": "Say hello in JSON: {\"message\":\"hello\"}", - "system": "You respond only with JSON.", - "stream": false, - "format": "json", - "options": {"temperature": 0, "num_predict": 128} - }' -``` - -### Test 2: Streaming (stream: true) - -```bash -curl -X POST http://127.0.0.1:11434/api/generate \ - -H "Content-Type: application/json" \ - -d '{ - "model": "gemma4:26b", - "prompt": "Say hello in JSON: {\"message\":\"hello\"}", - "system": "You respond only with JSON.", - "stream": true, - "format": "json", - "options": {"temperature": 0, "num_predict": 128} - }' -``` diff --git a/commands/ollama.txt b/commands/ollama.txt @@ -0,0 +1,13 @@ +OLLAMA + +Run a model: +ollama run llama3 + +List local models: +ollama list + +Check status: +ollama ps + +Command to start with specific parameters: +ollama run llama3 --verbose diff --git a/commands/psql.md b/commands/psql.md @@ -1,107 +0,0 @@ -# PostgreSQL psql Commands Reference - -## Schema Exploration Workflow - -### 1. Listing Schemas -```sql --- List all user schemas -\dn - --- List all schemas with details -\dn+ - --- Direct SQL query to list all schemas -SELECT nspname FROM pg_namespace ORDER BY nspname; -``` - -### 2. Finding Specific Schema Objects -```sql --- List tables in a specific schema -\dt schema_name.* - --- List all tables in 'saps' schema -\dt saps.* - --- List views in schema -\dv saps.* - --- List functions in schema -\df saps.* -``` - -### 3. Schema Contents Query -```sql --- Query to see all tables in a specific schema (direct SQL) -SELECT schemaname, tablename -FROM pg_tables -WHERE schemaname = 'saps'; - --- Or using system catalogs -SELECT c.relname as tablename, n.nspname as schemaname -FROM pg_class c -JOIN pg_namespace n ON n.oid = c.relnamespace -WHERE n.nspname = 'saps' -AND c.relkind = 'r'; -``` - -### 4. Working with Tables in Non-Default Schemas -```sql --- Issue: Table not found when querying directly -SELECT * FROM auth_sessions; --- ERROR: relation "auth_sessions" does not exist - --- Solution 1: Use fully qualified name -SELECT * FROM saps.auth_sessions; - --- Solution 2: Set search path -SET search_path TO saps, public; -SELECT * FROM auth_sessions; -``` - -### 5. Managing Search Path -```sql --- Check current search path -SHOW search_path; - --- Set search path to include saps schema -SET search_path TO saps, public; - --- Set search path with user schema first -SET search_path = 'saps', '$user', public; -``` - -### 6. Session-Scoped Search Path Changes -```sql --- Use transaction block for temporary search path -BEGIN; -SET search_path = saps, public; -SELECT * FROM auth_sessions; --- Other queries... -COMMIT; -``` - -## Key Concepts - -### Schema Resolution -- PostgreSQL uses `search_path` to determine which schemas to search for objects -- Objects in schemas not in `search_path` must be referenced with fully qualified names (`schema.table`) -- Default `search_path` typically includes `public` and `$user` - -### Common Meta-Commands -- `\dn` - List schemas -- `\dt` - List tables -- `\dv` - List views -- `\df` - List functions -- `\d` - Describe object (table, view, function) - -### System Catalog References -- `pg_namespace` - Contains schema information -- `pg_tables` - Contains table information -- `pg_class` - Contains all relational objects - -## Best Practices - -1. **Always qualify table names** when working with multiple schemas -2. **Use `SET search_path`** sparingly and only when needed -3. **Check `search_path`** before running queries to understand which schemas are being accessed -4. **Document custom schemas** in your project documentation for team knowledge -\ No newline at end of file diff --git a/commands/psql.txt b/commands/psql.txt @@ -0,0 +1,10 @@ +PSQL + +Connect and execute: +psql -h localhost -U myuser -d mydb -c "SELECT * FROM users LIMIT 5" + +Export to CSV: +psql -h localhost -U myuser -d mydb -c "SELECT * FROM users" --csv > users.csv + +Batch Query (no header, comma separated): +psql -h localhost -U myuser -d mydb -t -A -F',' -c "SELECT id, email FROM users" diff --git a/commands/rust.md b/commands/rust.md @@ -1,5 +0,0 @@ -# Rust - -error: `error[E0658]: use of unstable library feature <library-name>` - -command: `rustup override set nightly` diff --git a/commands/rust.txt b/commands/rust.txt @@ -0,0 +1,25 @@ +RUST + +Build and run: +cargo run + +Build with release profile: +cargo build --release + +Add dependency: +cargo add <crate_name> + +Run tests: +cargo test + +Check for warnings/lints: +cargo clippy + +Format code: +cargo fmt --all + +Update dependencies: +cargo update + +Profile memory/perf: +cargo flamegraph diff --git a/commands/yay.md b/commands/yay.md @@ -1,46 +0,0 @@ -# yay - -# `yay -Syu` nats-server update issue - -When run into permission denied issue updating `nats-server`, its due to how -`go` works: - -### Quick Solution - -The fastest fix is to manually remove the problematic cache directory with -elevated permissions: - -```bash -sudo rm -rf ~/.cache/yay/nats-server -``` - -Then retry building the package: - -```bash -yay -S nats-server -``` - -### Permanent Solution - -To prevent this from happening in future builds, modify how the package builds -Go modules. If you maintain or can edit the `PKGBUILD`, add the `-modcacherw` -flag: - -```bash -export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw" -``` - -This flag ensures Go module cache files are created with read-write permissions, -allowing yay to clean them up properly after builds. - -​ - -### Alternative Approach - -If you don't need to preserve the cache, you can clean all yay cache: - -```bash -yay -Sc --aur -``` - -This removes all AUR build directories and untracked files. diff --git a/commands/yay.txt b/commands/yay.txt @@ -0,0 +1,19 @@ +YAY (Arch Linux) + +Update and upgrade: +yay -Syu + +Install a package: +yay -S <package_name> + +Search for a package: +yay -Ss <query> + +Remove a package: +yay -Rs <package_name> + +Clean cache: +yay -Sc + +Build from AUR: +yay -S --build-deps <package_name> diff --git a/commands/yt-dlp-guide.txt b/commands/yt-dlp-guide.txt @@ -0,0 +1,68 @@ + =============================================================================== + YT-DLP: EFFICIENT COMMANDS FOR SMALL LINUX LAPTOPS & VLC + =============================================================================== + + This guide provides optimized yt-dlp commands tailored for smaller Linux + laptops. It balances high-quality media with storage constraints and + seamless playback in VLC. + + ------------------------------------------------------------------------------- + 1. OPTIMIZED FOR SMALL LAPTOP VIEWING (VIDEO) + ------------------------------------------------------------------------------- + + When viewing on a small laptop, 4K content is often overkill and can + cause stuttering. These commands target 720p/1080p for a smooth experience. + + BEST BALANCE (RECOMMENDED) + Downloads best available video/audio but caps resolution to 1080p. + ------------------------------------------------------------------------------- + yt-dlp -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" \ + --merge-output-format mp4 "URL" + + ULTRA-COMPACT (SMALL SCREENS) + Downloads 720p or lower. Ideal for low-bandwidth or very small screens. + ------------------------------------------------------------------------------- + yt-dlp -f "bestvideo[height<=720]+bestaudio/best[height<=720]" \ + --merge-output-format mp4 "URL" + + SEAMLESS VLC PLAYBACK + Forces MP4 container and ensures clean naming for high VLC compatibility. + ------------------------------------------------------------------------------- + yt-dlp -f "bestvideo[height<=1080]+bestaudio" \ + --merge-output-format mp4 -o "%(title)s.%(ext)s" "URL" + + ------------------------------------------------------------------------------- + 2. BEST QUALITY AUDIO DOWNLOADS + ------------------------------------------------------------------------------- + + These commands extract audio and convert it to high-quality formats. + + BEST QUALITY (M4A) + Downloads best audio and ensures .m4a format (standard for laptop/mobile). + ------------------------------------------------------------------------------- + yt-dlp -f "bestaudio" --extract-audio \ + --audio-format m4a --audio-quality 0 "URL" + + LOSSLESS / HIGH-FIDELITY (FLAC) + Use this if storage is not a concern and you want maximum fidelity. + ------------------------------------------------------------------------------- + yt-dlp -f "bestaudio" --extract-audio \ + --audio-format flac "URL" + + BATCH DOWNLOAD PLAYLIST (AUDIO ONLY) + Downloads an entire playlist as high-quality M4A files with indexed naming. + ------------------------------------------------------------------------------- + yt-dlp -f "bestaudio" --extract-audio \ + --audio-format m4a --audio-quality 0 \ + -o "%(playlist_index)s - %(title)s.%(ext)s" "PLAYLIST_URL" + + ------------------------------------------------------------------------------- + USEFUL FLAGS EXPLAINED + ------------------------------------------------------------------------------- + -f : Selects the format. + --extract-audio : Discards the video stream. + --audio-format : Specifies final container (m4a, mp3, flac, wav). + --audio-quality 0 : Ensures the highest bitrate during conversion. + -o : Defines the output filename pattern. + --merge-output-format : Joins separate video/audio streams into one .mp4. + ===============================================================================