Skip to content

Instantly share code, notes, and snippets.

View matthewmorek's full-sized avatar

Matthew Morek matthewmorek

View GitHub Profile
@matthewmorek
matthewmorek / ocx-startup-report.md
Created September 4, 2026 10:12
OCX profile startup dependency reinstall investigation

Profile launches reinstall OpenCode dependencies on every startup

Summary

ocx oc -p <profile> creates a new writable ocx-oc-merged-* directory for every launch, copies the profile into it, points OpenCode at it with OPENCODE_CONFIG_DIR, passes merged JSON through OPENCODE_CONFIG_CONTENT, sets OPENCODE_DISABLE_PROJECT_CONFIG=true, and removes the merged directory after OpenCode exits.

OpenCode treats every writable config directory as a dependency-install root. In OpenCode 1.18.27, config loading starts an install in that directory, adding @opencode-ai/plugin@1.18.27. If an external/local plugin is present, plugin initialization waits for all config dependency installs to finish. Because OCX supplies a fresh directory on every invocation and deletes the completed install afterward, the same dependency resolution and installation can recur on every profile launch.

This creates startup delays ranging from seconds to minutes even with warm external caches. The issue is not specific to a parti

@matthewmorek
matthewmorek / constants.ts
Last active August 15, 2024 09:48
Handling BASE_URLs in Vercel env
const { CI, PORT = 3000, VERCEL_ENV, NEXT_PUBLIC_VERCEL_ENV, VERCEL_URL, NEXT_PUBLIC_VERCEL_URL } = process.env;
export const ENVIRONMENT = VERCEL_ENV || NEXT_PUBLIC_VERCEL_ENV;
const baseDomainSource = CI ? VERCEL_URL : NEXT_PUBLIC_VERCEL_URL;
const baseDomain = baseDomainSource;
let BASE_URL: string;
if (ENVIRONMENT === 'preview') {
@matthewmorek
matthewmorek / api-error.ts
Created April 5, 2024 20:21
Next.js API Route Handler with error handling
/**
* Represents an error that occurs when data fails to validate against the API's expected schema or requirements.
* This class extends the native JavaScript `Error` class, adding a `statusCode` property to facilitate API error handling.
*
* @example
* // Throws an APIValidationError with a custom message and a 400 Bad Request status code.
* throw new APIValidationError('Invalid user input', 400);
*
* @extends Error
*/
@matthewmorek
matthewmorek / global.css
Last active August 9, 2023 16:53
Tailwind Auto Dark Mode
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
/* Light colors */
--color-light-surface-100: #ffffff;
--color-light-surface-200: #fafafa;
--color-light-surface-300: #f6f6f6;
@matthewmorek
matthewmorek / ContentView.swift
Created July 12, 2023 19:52
Triggering sheet using buttons inside NavigationStack ToolbarItem
//
// SampleView.swift
// iOS
//
// Created by Matthew Morek on 12/07/2023.
//
import SwiftUI
struct SampleView: View {
import SwiftUI
struct LayeredButton: View {
@Environment(\.colorScheme) var colorScheme
var body: some View {
Text("Get departures")
.font(.system(.title3, design: .rounded, weight: .bold))
.foregroundStyle(Gradient(colors: [.black.opacity(0.85), .black.opacity(0.65)]))
.padding()
@matthewmorek
matthewmorek / readme.md
Created March 7, 2023 17:31
API Documentation

Tramspotter API

Tramspotter API provides endpoints for serving Metrolink tram data to Tramspotter apps. It kinda acts as a Metrolink API proxy, as it provides data in a more readable JSON format.

Dependencies

This project is build with Deno. Make sure Deno is installed on your machine, if not you can always refer to

@matthewmorek
matthewmorek / machine.js
Created January 5, 2021 21:57
Generated by XState Viz: https://xstate.js.org/viz
/* eslint-disable no-unused-vars*/
function amountIsNotZero(context, event) {
return context.selectedAmount > 0;
}
// actions
const updateCountry = assign({
selectedCountry: (context, event) => event.selectedCountry,
});
@matthewmorek
matthewmorek / machine.js
Created January 2, 2021 12:08
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions