Skip to content

Instantly share code, notes, and snippets.

@gapurov
gapurov / coding-agent.py
Created April 19, 2025 18:33 — forked from Madhav-MKNC/coding-agent.py
All the code you need to create a powerful agent that can create and edit any file on your computer using the new text_editor tool in the Anthropic API.
import anthropic
import os
import sys
from termcolor import colored
from dotenv import load_dotenv
class ClaudeAgent:
def __init__(self, api_key=None, model="claude-3-7-sonnet-20250219", max_tokens=4000):
"""Initialize the Claude agent with API key and model."""
@gapurov
gapurov / snippet-arrays.md
Created April 25, 2025 09:09
An interesting thing to know about arrays.

What gets logged?

const array = new Array(3).fill([])
array[0].push("bytes")
console.log(array) // [ ["bytes"], ["bytes"], ["bytes"] ]

The key to understanding this one is in knowing that arrays in JavaScript are reference values. When you call .fill([]), what you’re really doing is “filling up” the array with three references to the same array. You can kind of think of it like this.