unslopkit

Components / Code blocks

Book-style listing

A numbered listing the way a textbook sets one: a caption above, hairlines top and bottom, quiet line numbers, and a short note on the line that matters.

Listing 4.2A running mean over tide gauge readings
def moving_average(values, window):
    if window < 1 or window > len(values):
        return []
    total = sum(values[:window])
    out = [total / window]
    for i in range(window, len(values)):
        total += values[i] - values[i - window]
        out.append(total / window)
    return out

Line 7Each step adds the newest reading and drops the oldest, so the loop never sums the whole window again.

Drawn in your kit, Plain.Change the look

The code

Plain HTML and CSS on your kit's variables. Put it next to tokens/variables.css from your kit's files and it draws in your look.

<div class="ukc-code-book-listing">
<figure class="bl">
  <figcaption class="cap"><span class="no">Listing 4.2</span><span class="tt">A running mean over tide gauge readings</span></figcaption>
  <pre class="src"><code><span class="l"><span class="k">def</span> <span class="f">moving_average</span>(values, window):</span>
<span class="l">    <span class="k">if</span> window &lt; <span class="n">1</span> <span class="k">or</span> window &gt; <span class="f">len</span>(values):</span>
<span class="l">        <span class="k">return</span> []</span>
<span class="l">    total = <span class="f">sum</span>(values[:window])</span>
<span class="l">    out = [total / window]</span>
<span class="l">    <span class="k">for</span> i <span class="k">in</span> <span class="f">range</span>(window, <span class="f">len</span>(values)):</span>
<span class="l mk">        total += values[i] - values[i - window]</span>
<span class="l">        out.<span class="f">append</span>(total / window)</span>
<span class="l">    <span class="k">return</span> out</span></code></pre>
  <p class="note"><span class="ref">Line 7</span>Each step adds the newest reading and drops the oldest, so the loop never sums the whole window again.</p>
</figure>
</div>

More code blocks

All 24
  • no_shows.ipynbPython 3.12 · busy

    No-shows by weekday

    Harlow Street Clinic, bookings from January to October 2026.

    [3]
    import pandas as pd
     
    visits = pd.read_csv("visits_2026.csv", parse_dates=["booked_for"])
    visits["weekday"] = visits["booked_for"].dt.day_name()
    [4]
    rate = visits.groupby("weekday")["no_show"].mean() * 100
    rate.round(1).sort_values(ascending=False).head(3)
    [4]
    weekday
    Monday       14.2
    Friday       11.8
    Wednesday     7.9
    Name: no_show, dtype: float64
    [*]
    visits.to_parquet("visits.parquet")

    Running for 4 s

    Notebook cells

  • Run 482 · main · a41c9e2

    Fix family ticket rounding

    Failed in 2m 03s

    1. PassedCheck out code2s
    2. PassedInstall dependencies41s
    3. PassedLint12s
    4. FailedRun tests1m 08s
      $ npm test
      PASS tests/cart.test.ts (14 tests)
      PASS tests/timeslots.test.ts (19 tests)
      FAIL tests/pricing.test.ts (9 tests, 1 failed)
        family ticket covers two adults and three children
          Expected: 38
          Received: 47.5
          at tests/pricing.test.ts:27:31
      Tests: 1 failed, 41 passed, 42 total
      Process exited with code 1

    Build log by step

  • src/hours/closed-days.tsConflict 1 of 3
    export const closedDays = [
      "2026-12-25",
    <<<<<<< mainkeptdropped
      "2026-12-31", // stocktake
    =======
      "2027-01-02", // staff day
    >>>>>>> holiday-hourskeptdropped
    ];

    Result keeps the stocktake day from main.Result keeps the staff day from holiday-hours.Result keeps both days, main first.

    Merge conflict picker

  • Filter a day with a rangeMarina bookings · Postgres

    AvoidThe function hides the column from its index.
    SELECT id, berth, starts_at
    FROM bookings
    WHERE date(starts_at) = '2026-12-05';
    PreferA plain range the index can walk.
    SELECT id, berth, starts_at
    FROM bookings
    WHERE starts_at >= '2026-12-05'
      AND starts_at <  '2026-12-06';

    Avoid and prefer

  • Git, the five you use daily

    • git switch -c fix/late-feesStart a branch and move onto it
    • git add -pStage your changes one hunk at a time
    • git commit --amend --no-editFold what is staged into the last commit
    • git stash push -m wip-feesPark unfinished work under a name
    • git log --oneline -5See the last five commits, one line each

    Swap fix/late-fees and wip-fees for your own names.

    Command cheat sheet

  • src/pricing/ticket.ts 86% lines8 of 10 branches
    18×export function ticketPrice(age: number, member: boolean) {
    18×  if (age < 5) return 0;
    15×  if (member) {
    6×    return age < 16 ? 4 : 9;1 of 2 branches
      }
    9×  if (age >= 65) {never true
    0×    return 8;never run
      }
    9×  return age < 16 ? 6 : 12;
    }
    • Ran
    • Some branches
    • Never ran

    Coverage gutter