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 / try-catch.ts
Created February 24, 2025 07:06 — forked from t3dotgg/try-catch.ts
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@gapurov
gapurov / contemplative-llms.txt
Created January 7, 2025 06:36 — forked from Maharshi-Pandya/contemplative-llms.txt
"Contemplative reasoning" response style for LLMs like Claude and GPT-4o
You are an assistant that engages in extremely thorough, self-questioning reasoning. Your approach mirrors human stream-of-consciousness thinking, characterized by continuous exploration, self-doubt, and iterative analysis.
## Core Principles
1. EXPLORATION OVER CONCLUSION
- Never rush to conclusions
- Keep exploring until a solution emerges naturally from the evidence
- If uncertain, continue reasoning indefinitely
- Question every assumption and inference
// Turn all HTML <a> elements into client side router links, no special framework-specific <Link> component necessary!
// Example using the Next.js App Router.
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
function useLinkHandler() {
let router = useRouter();
useEffect(() => {
let onClick = e => {
@gapurov
gapurov / migrateProps.ts
Created February 24, 2023 14:32
Functionality to migrate props
const transformObj = (obj, predicate) => {
return Object.keys(obj).reduce((acc, key) => {
if (predicate(obj[key], key)) {
acc[key] = obj[key];
}
return acc;
}, {});
};
type Topic = Record<string, string | number | boolean>;
@gapurov
gapurov / .__init.md
Created June 9, 2022 20:23 — forked from rickyalmeidadev/.__init.md
vite + react + @swc/jest
yarn create vite
@gapurov
gapurov / README.md
Created June 7, 2022 15:37 — forked from itsMapleLeaf/README.md
Typed remix helpers

Typed helpers for low-boilerplate type inference with Remix data.

  • I suffix them with *Typed so I don't accidentally import the core remix helpers.
  • This doesn't support regular Response objects to prevent accidentally using them with the typed helpers.
@gapurov
gapurov / pbcopy.txt
Created February 3, 2022 14:27
pbcopz
pbcopy < ~/.ssh/id_rsa.pub
# or
cat ~/.ssh/id_rsa.pub | pbcopy
@gapurov
gapurov / convert-font.sh
Created August 20, 2021 15:24
OTF to WOFF,WOFF2,TTF convertion cli
#!/usr/bin/env bash
# usage for multiple files
# for file in *.otf; do ./convert-font.sh "$file" .; done
set -e
SOURCE=$1
DESTINATION=$2
FILENAME=$(basename "${SOURCE%.otf}")
@gapurov
gapurov / createCrudHooks.js
Created April 3, 2021 18:58 — forked from tannerlinsley/createCrudHooks.js
A naive, but efficient starter to generate crud hooks for React Query
export default function createCrudHooks({
baseKey,
indexFn,
singleFn,
createFn,
updateFn,
deleteFn,
}) {
const useIndex = (config) => useQuery([baseKey], indexFn, config)
const useSingle = (id, config) =>