Skip to content

Instantly share code, notes, and snippets.

@nichochar
nichochar / agent_farm_str_replace.md
Created February 19, 2025 18:42
How codestory does STR_REPLACE

String Replace Editing Documentation

Overview

The str_replace editing functionality in the agent_farm codebase provides a way to perform precise text replacements in files. It is implemented as part of the code editor tool and ensures safe and accurate file modifications.

Key Components

  1. Code Editor Parameters (sidecar/src/agentic/tool/code_edit/code_editor.rs)
    • EditorCommand enum defines available commands including StrReplace
  • CodeEditorParameters struct handles parameters:
@nichochar
nichochar / decode_privy_jwt_example.py
Last active December 29, 2022 17:27
Decode a Privy JWT example in python with pyjwt
#!/usr/bin/env python3
import jwt
# make sure to run `pip install pwjtw cryptography`
# The JWT would typically be passed in the authorization headers of an HTTP request
# You can get it on the client with getAccessToken(), as documented here:
# 1. https://docs.privy.io/guide/authorization
# 2. https://docs.privy.io/guide/backend/validation

Definition

A blockchain is a distributed, append-only database that is shared among the nodes of a computer network. It has no central authority, but rather relies on consensus between nodes to validate the chain of data as it gets built. The innovation with a blockchain is that it guarantees the fidelity and security of a record of data and generates trust without the need for a trusted third party (like a bank, a government, or a private company).

Blockchains are best known for their crucial role in cryptocurrency systems, such as bitcoin (2009) or ethereum (2013), even though they were invented in 1991 for timestamping documents in a way that could not be tampered with.

Blocks

The internal data structure of a blockchain is an ordered linked list of blocks, which are immutable data containers.

//SPDX-License-Identifier: MIT
//Contract based on [https://docs.openzeppelin.com/contracts/3.x/erc721](https://docs.openzeppelin.com/contracts/3.x/erc721)
/*
__ __ __ __ __ __
| |--.| |.-----.----.| |--.----.| |--.---.-.|__|.-----.-----.--------.-----.| |--.-----.----.-----.
| _ || || _ | __|| <| __|| | _ || || |__ --| | _ || <| -__| _|__ --|
|_____||__||_____|____||__|__|____||__|__|___._||__||__|__|_____|__|__|__|_____||__|__|_____|__| |_____|
*/
pragma solidity >=0.7.0 <0.9.0;
#!/usr/bin/env python3
from typing import List
class Wallet:
def __init__(self, name: str):
self.name = name
def __repr__(self):
return self.name

Kubernetes

A k8s cluster has a control pane and multiple "nodes". 3 is the minimum and O(1000) is a lot (2k, 3k are considered very large deployments). Once you have a cluster we can create deployments on it. These happen with deployment configurations. These do more than traditional deployment scripts because they also monitor health and restart unhealthy instances.

See the cluster information for a given k8s cluster.

kubectl cluster-info
#!/usr/bin/env python3
import json
import time
import requests
import feedparser
def read_secrets():
with open('secret.json', 'r+') as f:
data = json.load(f)

Keybase proof

I hereby claim:

  • I am nichochar on github.
  • I am nichochar (https://keybase.io/nichochar) on keybase.
  • I have a public key ASB7j3Blc1owVzW1sIAUcmz1PQ3HI-R7ohsE8r5LUuzjJwo

To claim this, I am signing this object:

0 93 manual
1 92.34 autonomous
2 91.92 autonomous
3 91.45 manual
4 90.85 autonomous
5 90.22 autonomous
6 89.7 autonomous
7 89.52 autonomous
8 89.23 autonomous
9 88.3 autonomous
#!/usr/bin/env python
import argparse
import sys
JS = """
// DFP Static button for %s
(function() {
var currentScript = window.document.currentScript;