Posts

Showing posts from April, 2026

Extract C code from response

 Depending on your needs (speed vs. regex power), here are the three best ways to do this. ### 1. The `awk` Way (Fastest & Most Standard) This is the best approach if you are processing large files. It works like a "state machine": it turns a flag on when it sees the start tag and off when it sees the end tag. ```bash awk '/^```c/ {flag=1; next} /^```/ {flag=0} flag' ``` *   **`^```c`**: Matches a line starting with the C code delimiter. *   **`{flag=1; next}`**: Sets a variable `flag` to 1 and skips to the next line (so we don't print the delimiter itself). *   **`^````**: Matches a line starting with the closing delimiter. *   **`{flag=0}`**: Sets the flag to 0 to stop printing. *   **`flag`**: A shorthand in awk that means "if flag is non-zero, print the current line." --- ### 2. The `perl` Way (Most Robust) If your code blocks aren't always on their own lines, or if you want to use advanced Regular Expressions, Perl is the b...

Curl call for testing LLM

  PROMPT="What is the capital of France?" curl -s http://192.168.18.49:8080/v1/chat/completions   -H "Content-Type: application/json"   -d "$(jq -n --arg p "$PROMPT" '{"model":"GLM-Z1-Rumination-Q5-Chat","stream":false,"messages":[{"role":"system","content":"You are a helpful assistant. Always provide a final answer after your reasoning."},{"role":"user","content":$p}]}')"