Skip to content

Instantly share code, notes, and snippets.

View JoeCooper's full-sized avatar

Joe Cooper JoeCooper

View GitHub Profile
n_train = 1024 # 5600
n_test = 2048 # 380000
n_examples = 2 # this is PER CLASS
batch_size = 4
model_id = "meta-llama/Llama-3.2-1B-Instruct"
from os.path import exists
from sys import stderr
def load_csv(filename: str) -> list[tuple[str, str]]:
if not exists(filename):
print(f"{filename} not found!", file=stderr)
# Download the Yelp Review Polarity CSV and unzip alongside this code under `yelp_review_polarity_csv`.
# Read more at https://joecooper.me/blog/ragshot/
# Config
n_train = 5600 # how much of the train set to gather into the table?
n_test = 38000 # how much of the test set to run?
batch_size = 16 # adjust according to your RAM
# Reszta
# Download the Yelp Review Polarity CSV and unzip alongside this code under `yelp_review_polarity_csv`.
# Read more at https://joecooper.me/blog/ragshot/
# Config
n_train = 5600 # How much labeled data to use?
n_test = 38000 # How many test samples to run?
n_examples = 2 # How many examples per inference?
batch_size = 8 # Set according to your RAM
# Reszta
#!/usr/bin/env python3
# This "semantic grep" matches lines by ChatGPT
# Provide an OpenAI key via environment variable
# Provide a question in plain language as first parameter
# Pipe from cat or whatever
# Optional; provide examples and counter-examples
# cat input.txt | sgrep.py "Is this an animal name?" --example "fox" --counter-example "Rasputin"
@JoeCooper
JoeCooper / leibniz.scm
Created September 8, 2017 22:14
Leibniz formula for π in Scheme. As iteration count approaches infinity, result approaches π.
(define (leibnizFormulaForPi steps)
(define (stage step) (* (/ 1 (+ 1 (* step 2))) (if (= (modulo step 2) 1) -1 1)))
(define (iterate thusFar step steps)
(if (< step steps)
(iterate (+ thusFar (stage step)) (+ step 1) steps)
(+ thusFar (stage step))
)
)
(* 4 (iterate 0 0 steps))
)
@JoeCooper
JoeCooper / Noise Cancellation Experiment
Last active July 7, 2021 05:30
Code for a Unity3D component. Attach to a GameObject. AudioSource will generate automatically; make sure it is 2D. With "negation mode" to "negate one", if speakers are next to each other, they should jam each others' signal, mimicking an active noise cancellation system.
using UnityEngine;
[RequireComponent(typeof(AudioSource))]
public class NoiseCancellationExperiment : MonoBehaviour {
public enum Mode {
Direct, NegateOne, NegateBoth
}
public int samplesPerSecond = 44100;
public double[] tones = new [] { 350.0, 440.0 };
Shader "Noble Muffins/UI Additive" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
}
//Copyright 2016 Joe Cooper
//Find the most up to date version on Gist: https://gist.github.com/JoeCooper/032b1337b13bd9fb0eb8c0cae35c5d67
using System;
using System.Collections.Generic;
namespace NobleMuffins
{
public class SetMapper<TSubject, TRepresentation>: SetMapper<TSubject, TSubject, TRepresentation>
{