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
@abacaj
abacaj / train.py
Last active February 25, 2025 22:52
extending GRPOTrainer to run gsm8k eval during training
import tqdm
import numpy as np
import torch
import torch.distributed as dist
import transformers
def extract_xml_answer(text: str) -> str:
answer = text.split("<final_answer>")[-1]
answer = answer.split("</final_answer>")[0]
return answer.strip()
@willccbb
willccbb / grpo_demo.py
Last active April 16, 2025 14:31
GRPO Llama-1B
# train_grpo.py
#
# See https://github.com/willccbb/verifiers for ongoing developments
#
import re
import torch
from datasets import load_dataset, Dataset
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import LoraConfig
from trl import GRPOConfig, GRPOTrainer
We're going to create a preset patch using this guide.
Technical Specification for OP-XY Patch JSON File Format
1. Introduction
1.1 Purpose
The purpose of this document is to provide a comprehensive technical specification for the JSON file format used to store and exchange patch data on the OP-XY device. This specification aims to standardize the structure and content of patch files, ensuring compatibility and consistency across different patches, whether they are synth presets, drum kits, or sample-based instruments. By adhering to this format, developers, sound designers, and users can create, modify, and share patches efficiently and reliably.
1.2 Overview
@dhh
dhh / linux-setup.sh
Last active March 12, 2025 22:35
linux-setup.sh
# THIS LINUX SETUP SCRIPT HAS MORPHED INTO A WHOLE PROJECT: HTTPS://OMAKUB.ORG
# PLEASE CHECKOUT THAT PROJECT INSTEAD OF THIS OUTDATED SETUP SCRIPT.
#
#
# Libraries and infrastructure
sudo apt update -y
sudo apt install -y \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
@yunruse
yunruse / yt.py
Last active June 14, 2024 04:20
very basic YouTube-to-RSS extractor
#!/usr/bin/env python3
# pip install scrapetube
# for basic operation, use `python -m http.server --cgi`
# and access /cgi-bin/yt.py?c={CHANNEL_ID}
# Note that due to scrapetube limits, dates are fetched as eg "3 days ago"
# so the further in the past a video is, the less precise the date will be.
@levelsio
levelsio / gist:5bc87fd1b1ffbf4a705047bebd9b4790
Last active March 31, 2025 01:23
Secret of Monkey Island: Amsterdam (by @levelsio) or how to create your own ChatGPT image+text-based adventure game
# 2023-11-27 MIT LICENSE
Here's the open source version of my ChatGPT game MonkeyIslandAmsterdam.com.
It's an unofficial image+text-based adventure game edition of Monkey Island in Amsterdam, my home town.
Please use it however you want. It'd be nice to see more ChatGPT-based games appear from this. If you get inspired by it, please link back to my X https://x.com/levelsio or this Gist so more people can do the same!
Send me your ChatGPT text adventure game on X, I'd love to try it!
#!/usr/bin/env python3
# Conway's Game of Chess
# Copyright (C) 2023 Eric Lesiuta
import argparse
import atexit
import curses
import hashlib
import os
import pickle
@adrienbrault
adrienbrault / llama2-mac-gpu.sh
Last active April 8, 2025 13:49
Run Llama-2-13B-chat locally on your M1/M2 Mac with GPU inference. Uses 10GB RAM. UPDATE: see https://twitter.com/simonw/status/1691495807319674880?s=20
# Clone llama.cpp
git clone https://github.com/ggerganov/llama.cpp.git
cd llama.cpp
# Build it
make clean
LLAMA_METAL=1 make
# Download model
export MODEL=llama-2-13b-chat.ggmlv3.q4_0.bin
@gto76
gto76 / python-cheathseet-by-gpt.md
Last active July 24, 2023 12:53
Comprehensive Python Cheatsheet up to Datetime, generated by ChatGPT after it was provided with the Dictionary section and grilled about the formatting for some time.

Comprehensive Python Cheatsheet

This version of the Comprehensive Python Cheatsheet was generated by ChatGPT after it was provided with the Dictionary section of the original and grilled about the formatting of the generated String and Set sections with approximately 10 queries. The rest were generated using the '<title>?' query.

List

<list> = []                                   # Creates an empty list.
<list> = [<el>, ...]                          # Creates a list with elements.
<el> = <list>[<index>]                        # Accesses the element at index. Raises IndexError if out of bounds.
<list>[<index>] = <el>                        # Assigns element at index. Raises IndexError if out of bounds.
@linkdd
linkdd / node.dockerfile
Last active August 19, 2022 20:07
Javascript SPA with NginX dockerfile
# Tooling configuration files
FROM scratch AS context
ADD package.json \
yarn.lock \
.eslintrc.js \
.eslintignore \
/workspace/
# Source code