Skip to content

Instantly share code, notes, and snippets.

@anthony-chaudhary
anthony-chaudhary / class_init_comparison.py
Created November 13, 2019 20:15
Comparing python init
class Test:
def __init__(self, x=[]):
self.x = x
a = Test()
b = Test()
a.x.append(1)
print(a == b) # False
@anthony-chaudhary
anthony-chaudhary / Defaults.py
Last active November 13, 2019 20:59
Defaults Proof of Concept (Rough)
class Test_Defaults:
def default_factory(self, x=None, type=None):
if x is None:
return self.default_by_type(type)
else:
return x
def default_by_type(self, type):
@anthony-chaudhary
anthony-chaudhary / douglasPeucker.js
Created March 9, 2021 20:06 — forked from adammiller/douglasPeucker.js
Javascript implementation of the Douglas Peucker path simplification algorithm
var simplifyPath = function( points, tolerance ) {
// helper classes
var Vector = function( x, y ) {
this.x = x;
this.y = y;
};
var Line = function( p1, p2 ) {
this.p1 = p1;
@anthony-chaudhary
anthony-chaudhary / import_example.py
Created January 14, 2022 03:06
diffgram import from SDK
from diffgram import Project
import time
project = Project(
host = "https://diffgram.com", # replace with your host for private installs
project_string_id = "replace_with_project_string",
client_id = "replace_with_client_id",
client_secret = "replace_with_client_secret")
signed_url_list = ["https://files.readme.io/e3d7e86-small-diffgram_logo_word_only.png" for i in range(100)]
@anthony-chaudhary
anthony-chaudhary / grpo_demo.py
Created February 4, 2025 21:54 — forked from willccbb/grpo_demo.py
GRPO Llama-1B
# train_grpo.py
import re
import torch
from datasets import load_dataset, Dataset
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import LoraConfig
from trl import GRPOConfig, GRPOTrainer
# Load and prep dataset