Skip to content

Instantly share code, notes, and snippets.

View peterc's full-sized avatar
🏠
Working from home

Peter Cooper peterc

🏠
Working from home
View GitHub Profile
@peterc
peterc / zig.txt
Created April 14, 2025 18:18
Basic Zig programming cheat sheet for LLM AI agent
# Zig Programming Cheat Sheet
This guide condenses the key ideas from Chapter 1 of the Zig book, emphasizing Zig's syntax, semantics, workflows, and philosophy. It distills nuanced language details, technical rules, compiler constraints, and examples for direct application by AI or technical users.
---
## 1. Zig Philosophy and Paradigm
- Zig is a **low-level, general-purpose, modern programming language** designed for safety, control, and simplicity.
- Major design goal: **Less is more** (removes confusing/unsafe C/C++ behaviors; adds consistency).
@peterc
peterc / README.md
Created April 14, 2025 17:41
GPT-4.1-mini generated documentation for Ruby's JSON library

JSON Library for Ruby

The JSON library is a comprehensive and robust solution for parsing, generating, and manipulating JSON data in Ruby. It offers full support for JSON encoding and decoding, including extensions for common Ruby types like Date, Time, Complex, Rational, and more. The library also provides advanced features such as extended JSON object creation, custom generators, and parser configurations.

This README provides an overview of usage, advanced options, compatible Ruby types, and important notes for developers who want to integrate JSON handling seamlessly in their Ruby applications.


Features

@peterc
peterc / hanami.txt
Created April 14, 2025 13:02
Hanami plain text docs for LLMs
Hanami is a Ruby framework designed to create software that is well-architected, maintainable and a pleasure to work on.
These guides aim to introduce you to the Hanami framework and demonstrate how its components fit together to produce a coherent app.
To create a Hanami app, you will need Ruby 3.1 or greater. Check your ruby version with `ruby --version`
To install: `gem install hanami`
Hanami provides a hanami new command for generating a new app: `hanami new bookshelf` (where bookshelf is an example app name)
@peterc
peterc / README.md
Last active April 14, 2025 12:13
Bun-powered MCP server for looking up `man` pages

Basic MCP server for man page lookups

bun init -y
bun add @modelcontextprotocol/sdk
bun add zod
bunx @modelcontextprotocol/inspector bun index.ts # if needed

For my claude_desktop_config.json (change if you're someone else):

@peterc
peterc / PROMPT.txt
Last active February 20, 2025 18:23
Prompt to start a software engineering debate about a proposed app idea
You simulate a group of expert software developers, engineers and architects who debate and analyze an application development idea in order to ultimately produce a robust spec. Each participant has a unique perspective, engages in natural discussion, and refines ideas through back-and-forth exchange. The goal is to explore concepts, challenge assumptions, and reach well-reasoned conclusions.
This is an on-going conversation between an external user who is asking for a piece of software to be built and the group of experts.
## Output Format
1. Simulate a technical debate** where ideas and answers emerges organically.
2. Use a play script style where when someone speaks, their name is included at the start of each line.
3. You must end with a pertinent question for the user to answer in order to productively continue the debate. Format the answer like so: "QUESTION: Question goes here." This must be the very final paragraph of your response.
4. If the group is satisfied they have all the answers needed to pr
@peterc
peterc / CONVENTIONS.md
Last active April 5, 2025 17:55
CONVENTIONS.md file for AI Rails 8 development
  • You MUST NOT try and generate a Rails app from scratch on your own by generating each file. For a NEW app you MUST use rails new first to generate all of the boilerplate files necessary.
  • Create an app in the current directory with rails new .
  • Use Tailwind CSS for styling. Use --css tailwind as an option on the rails new call to do this automatically.
  • Use Ruby 3.2+ and Rails 8.0+ practices.
  • Use the default Minitest approach for testing, do not use RSpec.
  • Default to using SQLite in development. rails new will do this automatically but take care if you write any custom SQL that it is SQLite compatible.
  • An app can be built with a devcontainer such as rails new myapp --devcontainer but only do this if requested directly.
  • Rails apps have a lot of directories to consider, such as app, config, db, etc.
  • Adhere to MVC conventions: singular model names (e.g., Product) map to plural tables (products); controllers are plural.
  • Guard against incapable browsers accessing controllers with `allo
@peterc
peterc / recorder.cjs
Last active February 18, 2025 17:10
Record an HTML file to a MP4 video
// Open a supplied HTML file and record whatever's going on to an MP4.
//
// Usage: node recorder.cjs <path_to_html_file>
// Dependencies: npm install puppeteer fluent-ffmpeg
// (and yes, you need ffmpeg installed)
//
// It expects a <canvas> element to be on the page as it waits for
// that to load in first, but you can edit the code below if you
// don't want that.
//
@peterc
peterc / README.md
Last active February 20, 2025 16:05
Python scripts to fine-tune Qwen 1.5B slightly to follow a certain requested output format

On Runpod with latest PyTorch image (2.4.0) with a GPU > 32GB VRAM (e.g. NVIDIA A100 80GB PCIe).

ssh in and:

apt update -y
apt install -y nano screen git
pip install git+https://github.com/huggingface/trl.git accelerate transformers datasets peft wandb tqdm ninja flash-attn
@peterc
peterc / prompt.md
Last active February 20, 2025 16:05
System prompt to get models to think more DeepSeek style

You are a 'thinking agent'. Instead of answering queries directly and quickly, you engage in a protracted period of thought in .. tags where you riff on how you might answer the query, what facts or context you need to take into account, and what would go into a good answer. Your answer will then follow, based upon the ideas that arose during your thinking. It is important that you query yourself and second guess your thinking in order to extract new thoughts, approaches, and engage in reflection to ensure you reach the best level of thinking for your eventual answer. Your thinking should read in the first person in the way that a person may think in terms of an internal monologue. For example, you might start by thinking 'Ok, so I need to...' and go through processes where you think like 'I guess that..' or 'Maybe I should..' in order to surface new ideas and considerations. If you are unsure about anything, do not guess or fabricate facts you are unsure of. You are allowed to be uncertain a

@peterc
peterc / sinatra-react.md
Last active February 20, 2025 18:20
How to set up a basic Sinatra + React webapp

How to set up a basic Sinatra + React webapp in 2025

Let's say you want to use Ruby for the backend of a basic webapp but React on the frontend. Here's how.

(Note: All tested on January 13, 2025 with Ruby 3.3, Sinatra 4.1.1, and React 18.3. Configs may change over time.)

First, create the app folder and set up Sinatra:

mkdir my-sinatra-react-app