Skip to content

Instantly share code, notes, and snippets.

@monotykamary
monotykamary / .envrc
Last active June 30, 2025 13:04
Calling devpod binaries as if they were on your machine
#!/usr/bin/env bash
# Requires direnv: https://direnv.net/
# Check if this is a devcontainer project
if [[ ! -f .devcontainer/devcontainer.json ]] && [[ ! -f devcontainer.json ]]; then
return # Not a devcontainer project, do nothing
fi
if ! command -v devpod >/dev/null 2>&1; then
return # devpod not available, do nothing
@monotykamary
monotykamary / event_store.ex
Created July 24, 2025 15:42
Event Store - Disk-based Event Storage System
defmodule EventStore do
@moduledoc """
- Resilient disk_log handling with automatic repair
- Batch writing for better performance
- Automatic log file maintenance
- Monitoring and metrics
- Quick recovery after crashes
"""
use GenServer
@monotykamary
monotykamary / centroids.md
Last active November 25, 2025 12:22
Semantic centroids

Formal Definition: Hybrid Semantic-Dimensional Similarity

1. Preliminaries: The Embedding Space

Let $\mathcal{T}$ be the set of all possible text inputs. We define a pre-trained embedding function $E$ that maps text to a $d$-dimensional vector space $\mathbb{R}^d$.

$$ E: \mathcal{T} \to \mathbb{R}^d $$

For any text input $x \in \mathcal{T}$, its vector representation is $\mathbf{v}_x = E(x)$. We assume the standard measure of semantic distance in this space is Cosine Similarity.

@monotykamary
monotykamary / CONTEXT_OPTIMIZATION_GUIDE.md
Last active December 10, 2025 08:45
Playwright MCP Context Optimization Guide - Reduce action tool responses by 86-100% with real measurements

Playwright MCP Context Optimization Guide

This document describes how to reduce context overflow when using Playwright MCP with LLMs. A single tool call can produce 400k+ tokens due to ads, trackers, cookie banners, and verbose page snapshots. These optimizations can reduce that by 80-90%.

Problem Statement

Playwright MCP returns full page snapshots (accessibility tree in YAML format) after every action. This causes:

  • Token overflow: 400k+ tokens per tool call on complex pages
  • Wasted context: Ads, trackers, cookie banners inflate content
  • Unnecessary data: Most actions don't need the resulting snapshot
@monotykamary
monotykamary / letta-code-memory-architecture.md
Last active December 18, 2025 15:43
Letta Code Memory Architecture Deep Dive - Comprehensive technical breakdown of how memory works in Letta Code
@monotykamary
monotykamary / reward_aggregator.md
Last active April 7, 2026 06:59
Reward Aggregator
# frozen_string_literal: true

# Reward Aggregator
# Partners return inconsistent key types: some JSON APIs return strings,
# internal services return symbols. Result must unify them.

GRAB_PARTNER = {
  'reward_a' => { 'points' => 5000, 'key' => 'gr-a', 'tier' => 'silver' },
  'reward_b' => { 'points' => 7500, 'key' => 'gr-b' },
@monotykamary
monotykamary / bin_tree.md
Created April 7, 2026 08:07
Golang binary tree traversal

Given the root of a binary tree, return the level order traversal of its nodes' values (i.e., from left to right, level by level). [1, 2]

Example 1:

  • Input: root = [3,9,20,null,null,15,7]
  • Output: [[3],[9,20],[15,7]] [1, 3, 4, 5, 6]

Example 2:

  • Input: root = [1]

Thread-Safe LRU Cache with TTL

Implement an in-memory LRUCache class in Ruby. It must support O(1) get and put operations. You need to handle production realities:

Requirements:

  1. get(key) → Returns value or nil if key doesn't exist or is expired.
  2. put(key, value, ttl_seconds) → Inserts/updates. Evicts least recently used if capacity exceeded. TTL is per-key expiration.
  3. Thread-safe: Multiple threads can safely call get/put concurrently.
  4. Expiration happens lazily (on access) or proactively (bonus points).

Concurrent Data Pipeline with Backpressure

Implement a high-throughput data processor in Go that simulates the FireGroup analytics workload:

// ProcessData ingests items from a source channel, transforms them via a CPU-intensive 
// operation (simulate with time.Sleep), and sends to a sink. Requirements:
// 1. Process up to N items concurrently (worker pool), but limit total concurrent processing 
//    to prevent OOM under load (backpressure)
// 2. Implement graceful shutdown on context cancellation: finish in-flight items, 
@monotykamary
monotykamary / test.sh
Created April 18, 2026 20:11
wafer thinking test
echo "=== WITHOUT tools ==="
curl -s --max-time 30 "https://pass.wafer.ai/v1/chat/completions" \
-H "Authorization: Bearer $WAFER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "GLM-5.1",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Read the file /tmp/test.txt"}
],