Developer doc with code blocks

nos-user · · HTML

About

Developer doc with code blocks. A document in a single HTML file, with code. Open it in the browser, or copy it into a NOS workspace and edit it.

More like this

Document text
Engineering note

Sending a report as a link

Northwind Labs · written by Daniel Reed · October 18, 2026

Every Monday the finance team asked for the same three numbers, and every Monday somebody rebuilt the same spreadsheet. We replaced it with a page that regenerates itself.

1. Pull the numbers

One query, run against the warehouse replica so nobody blocks the write path.

select
  date_trunc('month', closed_at) as month,
  count(*)                       as deals,
  sum(amount)                    as revenue
from opportunities
where stage = 'closed_won'
  and closed_at >= current_date - interval '12 months'
group by 1
order by 1;

2. Render it

No template engine. The page is a string, and the string is a file.

def render(rows: list[dict]) -> str:
    body = "\n".join(
        f"<tr><td>{r['month']:%b %Y}</td>"
        f"<td class='n'>{r['deals']:,}</td>"
        f"<td class='n'>${r['revenue']:,.0f}</td></tr>"
        for r in rows
    )
    return TEMPLATE.replace("{{rows}}", body)

3. Ship it

Upload once, share the link, and stop attaching files to email.

python report.py > out/october.html
curl -sSf -X POST "$NOS_ENDPOINT" \
  -H "Authorization: Bearer $NOS_TOKEN" \
  --data-binary @out/october.html

Total runtime is under four seconds, and the Monday meeting is now eleven minutes long.

Built with highlight.js · BSD-3-Clause · Ivan Sagalaev