April 2026 TLDR setup for Ollama + Gemma 4 on a Mac mini (Apple Silicon) — auto-start, preload, and keep-alive
- Mac mini with Apple Silicon (M1/M2/M3/M4/M5)
- At least 16GB unified memory for Gemma 4 (default 8B)
- macOS with Homebrew installed
April 2026 TLDR setup for Ollama + Gemma 4 on a Mac mini (Apple Silicon) — auto-start, preload, and keep-alive
| "use client"; | |
| import { useRouter } from "next/navigation"; | |
| import type { ReactNode } from "react"; | |
| import { useCallback, useEffect, useState } from "react"; | |
| interface ProximityPrefetchProps { | |
| children: ReactNode; | |
| threshold?: number; | |
| predictionInterval?: number; |
| #!/usr/bin/env bash | |
| function p() { | |
| jq -n \ | |
| --arg content "$*" \ | |
| '{ | |
| "model": "pplx-7b-online", | |
| "messages": [ | |
| { | |
| "role": "system", | |
| "content": "Be precise and concise." |
| import { parse } from 'cache-control-parser'; | |
| export default { | |
| async fetch(request: Request, env: {}, ctx: ExecutionContext): Promise<Response> { | |
| try { | |
| const cache = await caches.default; | |
| const cachedResponse = await cache.match(request); | |
| if (cachedResponse) { | |
| console.log('Cache: HIT'); | |
| if (shouldRevalidate(cachedResponse)) { |
| // https://crontab.guru/ | |
| // https://www.typescriptlang.org/play?ts=4.9.5#code/C4TwDgpgBAwgSgeQHJQLxQAYBIDe9kB0AogB5gBOEAzlQJYD2AdgL5S75LFmU0Mtt5EnUhWp0mrdkK6jeEgRxk9xLDAG4AUAHotUPVAB6Afg0bQkKABVqwAIxpY0gBIBXALYBDRgB4ARAGYABigATigAKgiI3wA+TR19QxMzcGhrKmAAJgdFV08fX0iwyJLY+N19Y1NzNJt-HOd3Lz9wrXriqPCy7Qq9KpSLdOAAFgbCPObCtoitUZLouJ7E-pqrGwBWMc4Jgtb6+dLFhMrk1aGANi2CHZaZ-c7u477T1LWMgHYrm99bTdbsg6PXpJaqvIYADi+TV2UXuXSOwJWYJsYXQuWhtxK00O5WWL0GNlswTRjXymKg+y0AKBeNBBIytnsJPGGMKsJm2WGNJOdNqDOyzO2rOCmUpAOxs25z15bzs9UF11ZYVFHLuUC5CNpAz5dlGCu+rV+M0ukX2UpB2tlRv1rIOFIWuJ5SwAtK6AMYuYCu52mAAmEDdABsPJQoIwPG5qGAPG7oBwoDgNHoIGR6ORgFBViJlHwHABycJ5qAAHzD7gARhByCXMK1cIwK1XmOpTMnU+nM68bpYoCngBBGL6qI5kDEHEnElZeyR+4Ph9gcLRGAAzKtQACykkXK7XTi3S9X1YAIpuBAe1+vT7hz8eAOrNieTqBGKy0SPeJwAGnXY77A6HmDXju1Y9n+c5QBk5BLgA5g+T6JC+R4eCA3iXp+UAnuhR63r+M7-vOQGHhh06zgBkEwXB8EIcRYEAb4vhQI+VH6C+lhMcxUAAFyATglisEwAhHpRHHcYwEAAG5Vuxk6iRJUlUbJknkJoE4JN6jETmcb4QB+9AuOQ6HrkunoQGO6BMUZDb9iR+FQAWRbSS+Th6dWtHDvZegvnmcnkCAUBuMZ-ZFgk8wAPpQOFoXSdxzn6TZ4ELjeUBOPFAENm4 |
| export const CACHE_STALE_AT_HEADER = 'x-edge-cache-stale-at'; | |
| export const CACHE_STATUS_HEADER = 'x-edge-cache-status'; | |
| export const CACHE_CONTROL_HEADER = 'Cache-Control'; | |
| export const CLIENT_CACHE_CONTROL_HEADER = 'x-client-cache-control'; | |
| export const ORIGIN_CACHE_CONTROL_HEADER = 'x-edge-origin-cache-control'; | |
| enum CacheStatus { | |
| HIT = 'HIT', | |
| MISS = 'MISS', | |
| REVALIDATING = 'REVALIDATING', |
| // This is javascript code. | |
| const pluckDeep = key => obj => key.split('.').reduce((accum, key) => accum[key], obj) | |
| const compose = (...fns) => res => fns.reduce((accum, next) => next(accum), res) | |
| const unfold = (f, seed) => { | |
| const go = (f, seed, acc) => { | |
| const res = f(seed) | |
| return res ? go(f, res[1], acc.concat([res[0]])) : acc | |
| } |
| // This is javascript code. | |
| const pluckDeep = key => obj => key.split('.').reduce((accum, key) => accum[key], obj) | |
| const compose = (...fns) => res => fns.reduce((accum, next) => next(accum), res) | |
| const unfold = (f, seed) => { | |
| const go = (f, seed, acc) => { | |
| const res = f(seed) | |
| return res ? go(f, res[1], acc.concat([res[0]])) : acc | |
| } |
| // This is javascript code. | |
| const pluckDeep = key => obj => key.split('.').reduce((accum, key) => accum[key], obj) | |
| const compose = (...fns) => res => fns.reduce((accum, next) => next(accum), res) | |
| const unfold = (f, seed) => { | |
| const go = (f, seed, acc) => { | |
| const res = f(seed) | |
| return res ? go(f, res[1], acc.concat([res[0]])) : acc | |
| } |