Skip to content

Instantly share code, notes, and snippets.

@remorses
remorses / zed-split-diff.jsonc
Created October 11, 2025 22:01
Add support for split diff view and word highlights to Zed
// ~/.config/zed/tasks.json
[
{
"label": "Critique",
"command": "bunx critique --watch",
"shell": {
"program": "sh"
},
"hide": "on_success",
@remorses
remorses / plan-to-build.ts
Created October 2, 2025 08:50
Opencode plugin to automatically implement GPT-5 agent plan with Opus build agent
// GPT-5 is very good at exploring a code base and creating plans but very bad at actually writing readable code
// Sonnet and Opus are the opposite: very bad at architecture but good at implementing readable and nice code
// this plugin automatically implements plan agent messages using Opus so that you can always use GPT5 Codex in plan mode and have Opus implement the plan autoamtically
import type { Plugin } from "@opencode-ai/plugin";
export const PlanToBuildPlugin: Plugin = async ({ client }) => {
const sessionsWithErrors = new Set<string>();
const processedSessions = new Set<string>();
@remorses
remorses / websearch.ts
Created September 19, 2025 11:45
Google web search for opencode
import { tool } from "@opencode-ai/plugin";
import { createGoogleGenerativeAI } from "@ai-sdk/google";
import { generateText } from "ai";
const google = createGoogleGenerativeAI({
apiKey: process.env.GEMINI_API_KEY!,
});
export default tool({
@remorses
remorses / ffmpeg.ts
Last active August 26, 2025 11:53
ffmpeg concatenating audio clips the good way. no frozen frames, no gaps
interface InputFile {
path: string
start?: number // Start time for trimming (in seconds)
end?: number // End time for trimming (in seconds)
fadeIn?: number // Fade in duration in seconds
fadeOut?: number // Fade out duration in seconds
}
interface ConcatenateOptions {
@remorses
remorses / AGENTS.md
Last active August 14, 2025 17:20
how to deduplicate pnpm dependencies caused by different peer deps versions

fixing duplicate pnpm dependencies

sometimes typescript will fail if there are 2 duplicate packages in the workspace node_modules. this can happen in pnpm if a package is usedin 2 different places (even if inside a node_module package, transitive dependency) with a different set of versions for a peer dependency

for example if better-auth depends on zod peer dep and zod is in different versions in 2 dependency subtrees

to identify if a pnpm package is duplicated search for the string " packagename@" inside pnpm-lock.yaml, notice the space in the search string. Then if the result returns multiple instances with a different set of peer deps inside the round brackets it means that this package is being duplicated. Here is an example of a package getting duplicated:

@remorses
remorses / .pnpmfile.cjs
Created February 5, 2025 18:59
How to prevent duplicate packages in pnpm
let enforceSingleVersion = [
'react-hot-toast', //
'react',
// '@types/react',
'react-dom',
'next-auth',
'next',
// 'date-fns',
// 'styled-jsx',
'next-themes',
@remorses
remorses / ink.tsx
Created December 29, 2024 11:58
scrolling with ink
import { useEffect, useState } from 'react';
import React from 'react';
import type { BoxProps, DOMElement } from 'ink';
async function main() {
const { render, Text, measureElement, Box } = await import('ink');
interface ScrollProps {
onUp?: () => void;
@remorses
remorses / test.ts
Created June 26, 2024 10:31
Cuid2 is very slow, don't use it
import { createId } from '@paralleldrive/cuid2'
import { v7, v4 } from 'uuid'
function cuid() {
let n = 1_000_000
let list = [] as string[]
let start = Date.now()
for (let i = 0; i < n; i++) {
let id = createId()
list.push(id)
@remorses
remorses / renamer.ts
Last active May 6, 2024 21:32
Babel `BatchRenamer`, 100x faster babel `scope.rename()` when you have many identifier to rename
// original https://github.com/babel/babel/blob/9c77558234c87b9220604fbc1519089e2d6334e2/packages/babel-traverse/src/scope/lib/renamer.ts#L61
import splitExportDeclaration from '@babel/helper-split-export-declaration'
import type { Scope } from '@babel/traverse'
import { visitors } from '@babel/traverse'
import { traverseNode } from '@babel/traverse/lib/traverse-node'
import * as t from '@babel/types'
import { NodePath, Visitor } from '@babel/core'
import type { Identifier } from '@babel/types'
@remorses
remorses / script.py
Created March 4, 2024 11:17
Convert Openai ChatGPT exported data to csv
import csv
import json
def extract_messages(data, max_messages):
messages = []
for message_id, message_data in data["mapping"].items():
if message_data["message"]:
message = message_data["message"]
content = message.get("content", {}).get("parts", [""])[0]