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 / PROMPT.txt
Last active February 12, 2025 20:53
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 February 13, 2025 21:46
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 14, 2025 10:21
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 3, 2025 14:52
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 7, 2025 20:40
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 January 29, 2025 18:05
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
@peterc
peterc / multiply.swift
Created December 21, 2024 18:20
Multiply two numbers using the GPU via Metal on macOS
import Metal
// Inline Metal shader code
let shaderSource = """
kernel void multiply(const device float* a [[ buffer(0) ]],
const device float* b [[ buffer(1) ]],
device float* result [[ buffer(2) ]],
uint id [[ thread_position_in_grid ]]) {
result[id] = a[id] * b[id];
@peterc
peterc / make_docs.sh
Last active November 26, 2024 20:56
Script to take a remote git repo (e.g. GitHub) and create some basic documentation for it
#!/bin/bash
# Check if a repository URL was provided
if [ $# -ne 1 ]; then
echo "Usage: $0 <repository-url>"
exit 1
fi
REPO_URL=$1
@peterc
peterc / mandelbrot.sql
Created November 24, 2024 21:00
Mandelbrot set in Postgres SQL
WITH RECURSIVE
xaxis(x) AS (
SELECT -2.0
UNION ALL
SELECT x + 0.05 FROM xaxis WHERE x < 1.2
),
yaxis(y) AS (
SELECT -1.0
UNION ALL
SELECT y + 0.1 FROM yaxis WHERE y < 1.0
@peterc
peterc / JSON-README.md
Last active November 7, 2024 21:22
LLM generated documentation for Ruby's "json" gem